Invokes the contract method Verify
This method is used to test your VM script as if they ran on the blockchain at that point in time. This RPC call does not affect the blockchain in any way.
Unlike the method invokefunction
which executes the contract by the Application trigger, invokecontractverify
executes the contract by the Verification trigger and can pass parameters as params
and signers
. Specific parameter type and number depend on the smart contract to invoke.
Parameters
Object Name | Required | Type | Detail |
---|---|---|---|
SCRIPT HASH | ✅ | String | The smart contract scripthash. |
PARAMS | ✅ | Array | The parameters to be passed into the smart contract operation. |
SIGNERS | ❌ | Array | List of objects containing contract signature accounts. |
SIGNERS
has the following fields:
Key | Required | Type | Detail |
---|---|---|---|
account | ✅ | String | The signature account. |
scopes | ✅ | String | The signature's valid scopes, allowed values: FeeOnly , CalledByEntry , CustomContracts , CustomGroups , Global |
allowedcontracts | ❌ | Array | The contracts of the signature that can take effect if scopes is CustomContracts |
allowedgroups | ❌ | Array | The pubkeys of the signature that can take effect if scopes is CustomGroups |
You need to use the proper byte order of the address passed according to its data type. If the data type is Hash160, use the big endian script hash; if the data type is ByteArray, use the little endian scripthash.
{
"type": "String",
"value": "Hello"
}
{
"type": "Hash160",
"value": "0xf621168b1fce3a89c33a5f6bcf7e774b4657031c"
}
{
"type": "ByteArray",
"value": "7472616e73666572"
}
"params": [
"0x2b6ab054615c2386c9c0e4f35dc5f2d5e35768fa",
[],
[{
"account": "NSk8xEBm3FNAFDueUf21cMugkWidJn5N1n",
"scopes": "CalledByEntry"
}]
]
Result
The invocation contract result.
Result Fields
Key | Type | Detail |
---|---|---|
script | String | The invocation script of the contract. |
state | String | HALT means the vm executed successfully, and FAULT means the vm exited due to an exception. |
gasconsumed | String | The system fee consumed for invocation. |
stack | String | The contract execution result. If the value is String or ByteArray, it is encoded by Base64. |
Example
Request
curl <your-endpoint> \
-X POST \
-H "Content-Type: application/json" \
-d '{"jsonrpc": "2.0", "method": "invokecontractverify", "params": ["0x2b6ab054615c2386c9c0e4f35dc5f2d5e35768fa", [ ], [{"account": "NSk8xEBm3FNAFDueUf21cMugkWidJn5N1n","scopes": "CalledByEntry"}]], "id": 1}'
Return
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"script": "",
"state": "HALT",
"gasconsumed": "4692",
"exception": null,
"stack": [{
"type": "Boolean",
"value": true
}]
}
}