speculative_exec The speculative_exec
endpoint allows contract developers to test and debug their contracts against the live network using real production data.
Note: speculative_exec
executes a Deploy at a specified block.
This method will use 150
Compute Units .
Parameters
block_identifier [object] [optional]. The block hash or height on top of which to execute the deploy. If not supplied, the most recent block will be used.
deploy [object] A Deploy consists of an item containing a smart contract along with the requester's signature(s).
Copy {
"id" : -573285493134384228 ,
"jsonrpc" : "2.0" ,
"method" : "speculative_exec" ,
"params" : {
"deploy" : {
"hash" : "9d1f8eb023d61333b9053e95487d5f9215d05af91f68a35258a2fc315e58c79e" ,
"header" : {
"ttl" : "30m" ,
"account" : "01f03bbc42a3d5901c7232987ba84ab2c6d210973a0cfe742284dcb1d8b4cbe1c3" ,
"body_hash" : "2ae593f71142f5e20a1af3e9cae69c9455a28299a55608c7afae0fe0a3c087f6" ,
"gas_price" : 1 ,
"timestamp" : "2024-05-29T11:27:49.544Z" ,
"chain_name" : "casper" ,
"dependencies" : []
} ,
"payment" : {
"ModuleBytes" : {
"args" : [
[
"amount" ,
{
"bytes" : "0400ca9a3b" ,
"parsed" : "1000000000" ,
"cl_type" : "U512"
}
]
] ,
"module_bytes" : ""
}
} ,
"session" : {
"StoredContractByHash" : {
"args" : [
[
"account" ,
{
"bytes": "4000000043333536303944444232464237373144454335423730344546424533433946374245413132373346333543334230314633433037343132394243433246344345",
"parsed" : "C35609DDB2FB771DEC5B704EFBE3C9F7BEA1273F35C3B01F3C074129BCC2F4CE" ,
"cl_type" : "String"
}
] ,
[
"balance" ,
{
"bytes" : "758f000000000000" ,
"parsed" : 36725 ,
"cl_type" : "I64"
}
]
] ,
"hash" : "d16aa9c6a7dc03d0f422eafeb244dcc782a3b7372bc2b2245c4e04f9c93f3e8f" ,
"entry_point" : "change_balance"
}
} ,
"approvals" : [
{
"signer" : "01f03bbc42a3d5901c7232987ba84ab2c6d210973a0cfe742284dcb1d8b4cbe1c3" ,
"signature": "011e0b5c36719206ee181c802befa2a0e42c0ad5a7dca143dff98abebbc8c262be0b9c6bd3f33dcc9077938f427f409ae6d484bd6ea8f216af195649c0baaded04"
}
]
}
}
}
Returns
api_version
String The RPC API version.
block_hash
Object The Block hash on top of which the deploy was executed.
execution_result
Object The map of Block hash to execution result.
Copy
{
"jsonrpc" : "2.0" ,
"result" : {
"api_version" : "1.5.6" ,
"block_hash" : "9e5ad0c52fed3b6e69f8f53a3f3a52fc5dbfda8308235b7c54b1c0cf2512af35" ,
"execution_result" : {
"Success" : {
"effect" : {
"operations" : [] ,
"transforms" : [
{
"key" : "account-hash-6174cf2e6f8fed1715c9a3bace9c50bfe572eecb763b0ed3f644532616452008" ,
"transform" : "Identity"
}
...
]
} ,
"transfers" : [] ,
"cost" : "171914831"
}
}
} ,
"id" : -573285493134384260
}
Note for using examples below:
speculative_exec
executes a Deploy at a specified block. When you test one of the examples below it may be expired due to timestamp, you can find the latest deploys to use for Casper testnet here and mainnet here .
If you copy the Raw data from the cspr.live explorer, you will need to remove part of the Deploy
object from "api_version"
onwards in your request.
mainnet
Copy curl https://mainnet.casper.validationcloud.io/v1/ < YOUR_API_KEY_HER E > \
-X POST \
-H "Content-Type: application/json" \
-d '{
"id": -573285493134384228,
"jsonrpc": "2.0",
"method": "speculative_exec",
"params": {
"deploy": {
"hash": "9d1f8eb023d61333b9053e95487d5f9215d05af91f68a35258a2fc315e58c79e",
"header": {
"ttl": "30m",
"account": "01f03bbc42a3d5901c7232987ba84ab2c6d210973a0cfe742284dcb1d8b4cbe1c3",
"body_hash": "2ae593f71142f5e20a1af3e9cae69c9455a28299a55608c7afae0fe0a3c087f6",
"gas_price": 1,
"timestamp": "2024-05-29T11:27:49.544Z",
"chain_name": "casper",
"dependencies": []
},
"payment": {
"ModuleBytes": {
"args": [
[
"amount",
{
"bytes": "0400ca9a3b",
"parsed": "1000000000",
"cl_type": "U512"
}
]
],
"module_bytes": ""
}
},
"session": {
"StoredContractByHash": {
"args": [
[
"account",
{
"bytes": "4000000043333536303944444232464237373144454335423730344546424533433946374245413132373346333543334230314633433037343132394243433246344345",
"parsed": "C35609DDB2FB771DEC5B704EFBE3C9F7BEA1273F35C3B01F3C074129BCC2F4CE",
"cl_type": "String"
}
],
[
"balance",
{
"bytes": "758f000000000000",
"parsed": 36725,
"cl_type": "I64"
}
]
],
"hash": "d16aa9c6a7dc03d0f422eafeb244dcc782a3b7372bc2b2245c4e04f9c93f3e8f",
"entry_point": "change_balance"
}
},
"approvals": [
{
"signer": "01f03bbc42a3d5901c7232987ba84ab2c6d210973a0cfe742284dcb1d8b4cbe1c3",
"signature": "011e0b5c36719206ee181c802befa2a0e42c0ad5a7dca143dff98abebbc8c262be0b9c6bd3f33dcc9077938f427f409ae6d484bd6ea8f216af195649c0baaded04"
}
]
}
}
}'
testnet
Copy curl https://testnet.casper.validationcloud.io/v1/ < YOUR_API_KEY_HER E > \
-X POST \
-H "Content-Type: application/json" \
-d '{
"id": -573285493134384228,
"jsonrpc": "2.0",
"method": "speculative_exec",
"params": {
"deploy": {
"hash": "5ca4cf386fe60e8765bef051f8e8b99cca6ee1fe3945308777f84513bcfb599b",
"header": {
"ttl": "2h",
"account": "01b331699e7581c196288e3183a337bd813f722c913b456a896e18e2790f7ec7c8",
"body_hash": "cbfe6833d14b720635c42a527ae0b528a182e13774a5744bc40fe33ed5001b28",
"gas_price": 1,
"timestamp": "2024-05-29T11:41:22.150Z",
"chain_name": "casper-test",
"dependencies": []
},
"payment": {
"ModuleBytes": {
"args": [
[
"amount",
{
"bytes": "0400e1f505",
"parsed": "100000000",
"cl_type": "U512"
}
]
],
"module_bytes": ""
}
},
"session": {
"Transfer": {
"args": [
[
"amount",
{
"bytes": "04009ce4a6",
"parsed": "2800000000",
"cl_type": "U512"
}
],
[
"target",
{
"bytes": "01ffed0444ece4f9909f4145ac9f058c0980432362f10ccdc2467d091b8a184e94",
"parsed": "01ffed0444ece4f9909f4145ac9f058c0980432362f10ccdc2467d091b8a184e94",
"cl_type": "PublicKey"
}
],
[
"id",
{
"bytes": "017b00000000000000",
"parsed": 123,
"cl_type": {
"Option": "U64"
}
}
]
]
}
},
"approvals": [
{
"signer": "01b331699e7581c196288e3183a337bd813f722c913b456a896e18e2790f7ec7c8",
"signature": "01650eddb1380b94b6c6522a02dc7a170b790c612c4adf828e6acae5c02d0ebcdf192b3da9236e75b090c629fdee610cc852904084d58ca40a066875c6b88ac402"
}
]
}
}
}'