You can use this instance to call any messages in the contract ABI file with the correct args. The function will return a payload (hex value), this signature includes all the information of the message.
const tx = api.tx.contract.call(
contractAddress,
endowment, // deposit amount, can be 0: BigNumber
200000, // gas fee
payload // the payload when calling specific message
);
The last step: sign and send the tx. You can get the transaction status and all the event details inside the code and also check them on CENNZnet UI with block hash.
4. Common issues
The signer should have enough funds to sign a transaction. You can get tokens through faucet.
The network(Localhost or Rimu) of deploying contract and calling contract should be the same one.
For spin2win contract, should make sure the contract has enough funds to allocate assets. You can also top up the contract, using contract address, through faucet.
1. Build and deploy the contract
You can follow this doc to build and deploy the contract: spin2win.
2. Contract address and ABI file
After you build and deploy the contract you will get two items to be used in the next step:
For
Contract ABI
of spin2win:You will see there is only one method in the contract, and the method name is
spin
, and only one parameter forspin
, the type isAccountId
.3. Calling contract
Construct a ContractABI instance:
You can use this instance to call any messages in the contract ABI file with the correct args. The function will return a
payload
(hex value), this signature includes all the information of the message.Create transaction:
Creating
api
andset signer
.Calling
api.tx.contract.call
to gettx
object:The last step:
sign and send the tx
. You can get the transaction status and all the event details inside the code and also check them on CENNZnet UI withblock hash
.4. Common issues