web3.js
https://gyazo.com/eb80fc5be891a9c4152791d1a4fdc918
This is the Ethereum JavaScript API which connects to the Generic JSON-RPC spec. Web3オブジェクト
web3オブジェクトの生成
code:web3.js
//コンストラクタでweb3オブジェクトの生成
web3js = new Web3(web3.currentProvider);
コントラクトオブジェクト
web3オブジェクト
require(web3)などでモジュールを用いる
code:cont-ob.js
var cryptoZombies;
function startApp(){
var cryptoZombieAddress = "ADDRESS";
// ContractABIとContractAddressを引数に渡してコントラクトオブジェクト生成
cryptoZombies = new web3js.eth.Contract(cryptoZombiesABI,cryptoZombiesAddress);
}
コントラクト関数の呼び出し
send() 引数:{アカウント}
code:con-func.js
myContract.methods.myMethod(123).call();
myCOntract.methods.myMethod(123).send({from: user});