Smart contract methods#
Node RPC call example:
Smart contract methods may have a dynamic list of parameters args that is specific to each smart contract:
Index: index of parameterFormat: format of parameterbyte,uint64,string,bigint,hex(default),dna(float representation).Value: parameter value interpreted according to the specified format
contract_deploy and contract_estimateDeploy methods#
Method contract_deploy creates DeployTx transaction to deploy a smart contract specified by CodeHash. Use contract_estimateDeploy to estimate gas consumption of the contract_deploy transaction.
Parameters:
from: sender addresscodeHash: predefined smart contract codeamount: amount of coins that will be blocked at the smart contract stakeargs: dynamic list of parameters relevant to the specified smart contractmaxFee: must cover a sum oftxFee+gasCost(see more aboutmaxFee)
Example:
contract_call and contract_estimateCall methods#
Method contract_call creates CallTx transaction to call a smart contract's method. Use contract_estimateCall method to estimate gas consumption of the contract_call transaction.
Parameters:
from: sender addresscontract: smart contract addressmethod: smart contract's method to callamount: amount of coins transferred to the smart contract addressargs: dynamic list of parameters relevant to specified smart contract's methodbroadcastBlock: block number when a postponed transaction should be published by the node
Example:
contract_terminate and contract_estimateTerminate methods#
Method contract_terminate creates TerminateTx transaction to terminate the smart contract. Use contract_estimateTerminate method to estimates gas consumption of the contract_terminate transaction.
Parameters:
from: sender addresscontract: smart contract addressargs: dynamic list of parameters relevant to specified smart contract's method
Example:
contract_readData method#
Returns requested data of the smart contract's state.
Parameters:
contract: smart contract addresskey: key of the requested dataformat: data format
Example:
contract_iterateMap method#
Returns requested array data (map) of the smart contract's state and continuation token to iterate the data.
Parameters:
contract: smart contract addressmap: the name of the requested array data (see maps available for the specific smart contract)continuationToken: iteration token should benullfor the first callkeyFormat: key format of the requested array datavalueFormat: data format of the requested array data
Example:
contract_readMap method#
Returns requested value for the given key from the array data (map) of the smart contract's state.
Parameters:
contract: smart contract addressmap: the name of the requested array data (see maps available for the specific smart contract)key: key of the requested array datavalueFormat: data format of the requested array data
Example:
contract_readonlyCall method#
Calls specified smart contract's method without changing the state.
Parameters:
contract: smart contract addressmethod: key of the requested dataformat: data formatargs: dynamic list of parameters
Example:
contract_getStake method#
Returns amount of coins blocked at the stake of the smart contract
Parameters:
Contract: smart contract address
Example:
bcn_txReceipt method#
Returns receipt of the specified transaction
Parameters:
hash: transaction hash
Example:
Response example:
Errors:
index out of range:argsarray has a missing element with requiredindex.
contract_events method#
Returns the list of events of the specified smart contract
Parameters:
contract: smart contract address
Example:
contract_subscribeToEvent and contract_unsubscribeFromEvent methods#
Subscribes/unsubscribes from the specified event of the smart contract
Parameters:
contract: smart contract addressevent: event name
Example:
bcn_feePerGas method#
The method returns the current GasPrice.
Example: