#
Smart contract methodsNode RPC call example:
#
ArgsSmart 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 DeployContractTx
transaction to deploy a custom contract specified by code
and nonce
or a predefined contract specified by codeHash
. Use contract_estimateDeploy
method to estimate gas consumption of the future DeployContractTx
transaction and address of the future contract.
Parameters for custom contract:
from
: sender addresscode
: compiled WebAssembly code of a custom contractargs
: dynamic list of parameters of constructor which is specific to a particular contractnonce
: unique nonce for the custom contract (allows you to generate unique addresses for contracts with the samecode
andargs
)maxFee
: must cover a sum oftxFee
+gasCost
(see more aboutmaxFee
)
Example:
Parameters for predefined contract:
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 CallContractTx
transaction to call specified contract's method. Use contract_estimateCall
method to estimate gas consumption of the future CallContractTx
transaction.
Parameters:
from
: sender addresscontract
: contract addressmethod
: name of the called contract's methodamount
: amount of coins transferred to the contract addressargs
: dynamic list of parameters relevant to specified 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 TerminateContractTx
transaction to terminate the contract. Use contract_estimateTerminate
method to estimates gas consumption of the future TerminateContractTx
transaction.
Parameters:
from
: sender addresscontract
: contract addressargs
: dynamic list of parameters relevant to specified 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 benull
for 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
: hash of mined transaction
Example:
Response example:
contract
: address of the called contractmethod
: called method of the smart contractsuccess
: whether transaction changed the state or notgasUsed
: amount of gas usedtxHash
: contract transaction hasherror
: error textgasCost
: gas cost, iDNAtxFee
: transaction cost, iDNA
Errors:
index out of range
:args
array 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:
Example:
The minimum gasPrice
is 0.01
/NetworkSize
.