invokescript
# invokescript Method
Returns the result after passing a script through the VM.
[!Note]
This method is 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.
You must install the plugin RpcServer before you can invoke the method.
Parameter Description
script: A script runnable in the VM. This is the same script that is returned in invokefunction
signers: Optional. List of contract signature accounts.
account: signature account
scopes: signature's valid scopes, allowed values are:
None: Only transactions are signed and no contracts are allowed to use this signature.
CalledByEntry: It only applies to the chain call entry. That is, if the user invokes contract A, and then contract A calls contract B, only contract A can use the signature. It is recommended as the default value for the wallet.
CustomContracts: Custom contract. The signature can be used in the specified contract. It can be used in conjunction with CalledByEntry.
CustomGroups: Custom contract groups that can be used in a specified contract group. It can be used in conjunction with CalledByEntry.
Global: Global. Global. The risk is extremely high because the contract may transfer all assets in the address. Only choose it when the contract is extremely trusted.
allowedcontracts: contracts of the signature can take effect, if scopes is CustomContracts
allowedgroups: pubkeys of the signature can take effect, if scopes is CustomGroups
use diagnostic: Whether to return the simulated invocation information and storage change information. The default value is
false
.
Example
Request body:
Response body:
script:合约的调用脚本,在 Neo 官网上可以解析 https://neo.org/converter
state:
HALT
means the vm executed successfully, andFAULT
means the vm exited due to an exception.gasconsumed: the system fee consumed for invocation.
exception: The exception messages occurred during contract execution. It is
null
when there is no exception.notifications: The event messages occurred during contract execution. They can be checked by getapplicationlog for on-chain transactions.
diagnostics: The process information and storage changes of the contract invocation. This request does not change the real storage on the blockchain, but only simulates the storage changes after the transaction is sent on the blockchain.
stack: the contract execution result. If the value is String or ByteArray, it is encoded by Base64.
tx: the transaction's hex string of this invocation, need open wallet and added signers correctly, otherwise the string will not be returned.
pendingsignature: It is returned if the transaction requires multiple signatures and the currently open wallet does not include all accounts of signers.
About iterator
If the execution result of contract includes iterators, whether to return session
is decided by the value of SessionEnabled
in config.json
of the plugin RpcServer
. If SessionEnabled
is true
, session
is returned to get further details of the Iterator. Otherwise, if SessionEnabled
is false
, session
is not returned.
In the following example, SessionEnabled
is true
: