Contract
Contract class
Contract class is used to create an object which does operations related to a contract such as deploying, interacting with network. One can also list query, execute methods available for the contract using this class.
Constructor
Contract constructor requires 1 argument, contract name. If contract .wasm
file is not present in artifacts then this constructor will throw an error.
_10const contract = new CounterContract();
deploy()
Deploys the contract.
_10const deploy_response = await contract.deploy(contract_owner);
Gives following response:
_10{_10 codeId: <code-id-val>,_10 contractCodeHash: <code-hash-val>,_10 deployTimestamp: <timestamp>_10}
instantiate()
Instantiate the contract.
_10const contract_info = await contract.instantiate(_10 {_10 "name": "ERC20", "symbol": "ERC", "decimals": 10,_10 "initial_balances": [{_10 "address": contract_owner.account.address,_10 "amount": "100000000"_10 }]_10 }, "deploy test", contract_owner);
Gives following response:
_10{_10 contractAddress: <contract-address>,_10 instantiateTimestamp: <timestamp>_10}
To list contract's execute methods, print contract.tx
.
_10wasmkit> contract.tx_10{ Approve: [Function (anonymous)], Transfer: [Function (anonymous), TransferFrom: [Function (anonymous), Burn: [Function (anonymous)] }
query methods
To list contract's query methods, print contract.query
.
_10wasmkit> contract.query_10{ Balance: [Function (anonymous), Allowance: [Function (anonymous)] }