BlockSec Documents
Search…
⌃K

Transaction Simulation API

Simulate arbitrary transactions at arbitrary blocks with arbitrary inputs
📌
Please contact us for the access token before using the Phalcon APIs.
Each Phalcon API can be invoked 100 times daily, with a rate limit of 60 times each minute for each access token. Currently, Phalcon APIs support ETH and BSC.
📬
Contact us if need to increase the limitation.

Introduction

Phalcon provides APIs to simulate a transaction (or a bundle of transactions) at arbitrary blocks with arbitrary inputs. Note that, at most three transactions are supported in the bundle.
For a simulated transaction, Phalcon APIs will return the balance changes, invoked internal transactions, triggered events, and other self-explainable transaction information. Phalcon APIs support the simulation of a bundle of transactions, the result will be an array in the txs of the datafield in the response.
The code in the response indicates the status of the request. When the code is zero, it means the request is successful. Otherwise, the request is failed, and the message denotes the failure reason.

Simulate a bundle of transactions by existing transaction hash

Request

This API simulates the execution of a bundle of transactions by the existing transaction hash, but with different block number and posotion with the original transaction. For instance, there is a transaction with the hash value `0x0d3f4c59d1d5f3f86952a8c4ecb5ad0b729991f26039b99239da614a7e31b04f` that was successfully executed on block 12816002 with position 137. With this API, the transaction can be simulated at an arbitrary block (e,g, 12816003) with an arbitrary position (e.g., position 0).
API endpoint: https://api.blocksec.com/v1/phalcon/simulate/hash
curl --location --request POST 'https://api.blocksec.com/v1/phalcon/simulate/hash' \
--header 'Access-Token: $AccessToken' \
--header 'Content-Type: application/json' \
--data-raw '{
"chainID": 1,
"block":12816002,
"position":130,
"bundle":[
"0x0d3f4c59d1d5f3f86952a8c4ecb5ad0b729991f26039b99239da614a7e31b04f"
]
}'
  • block: the block number in which the simulation runs
  • position: the position in the block
  • bundle: the transaction hash that will be simulated. The transaction hash should exist on supported blockchains. Note, at most three transactions are supported in the bundle.

Response

{
"code": 0,
"message": "OK",
"data": {
"txns": [
{
"balanceChanges": [
{
"account": "0xc94ebb328ac25b95db0e0aa968371885fa516215",
"assets": [
{
"address": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
"amount": "-9352931370595622",
"decimals": 18
}
]
},
{
"account": "0x9e4033b888c54471be675aa020739a4c8bc07cac",
"assets": [
{
"address": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
"amount": "9352931370595622",
"decimals": 18
}
]
}
],
"block": 12816002,
"chainID": 1,
"error": "",
"events": [],
"from": "0xc94ebb328ac25b95db0e0aa968371885fa516215",
"gasLimit": 21000,
"gasPrice": "19000000000",
"gasUsed": 21000,
"hash": "0x134cd27d77fa56137095509e39dcf0e27b47810b45bf499cf8517f82f144660b",
"input": "0x",
"internalTxns": [],
"maxFee": "19000000000",
"nonce": 235507,
"position": 131,
"priorityFee": "19000000000",
"status": true,
"timestamp": "2021-07-13T01:51:54Z",
"to": "0x9e4033b888c54471be675aa020739a4c8bc07cac",
"transactionFee": "399000000000000",
"type": "Legacy",
"value": "9352931370595622"
},
{
"balanceChanges": [
{
"account": "0x78f8d8f58cd595bb229a1ec63f10c582ff5cec1f",
"assets": [
{
"address": "0xa3bed4e1c75d00fa6f4e5e6922db7261b5e9acd2",
"amount": "-3479756688028391746647",
"decimals": 18
}
]
},
{
"account": "0xf64d731fc9c73cc8a815ffd2397a8346b3260cdf",
"assets": [
{
"address": "0xa3bed4e1c75d00fa6f4e5e6922db7261b5e9acd2",
"amount": "3479756688028391746647",
"decimals": 18
}
]
}
],
"block": 12816002,
"chainID": 1,
"error": "",
"events": [
{
"address": "0xa3bed4e1c75d00fa6f4e5e6922db7261b5e9acd2",
"data": "0x0000000000000000000000000000000000000000000000bca3532f388210ac57",
"topics": [
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
"0x00000000000000000000000078f8d8f58cd595bb229a1ec63f10c582ff5cec1f",
"0x000000000000000000000000f64d731fc9c73cc8a815ffd2397a8346b3260cdf"
]
}
],
"from": "0x78f8d8f58cd595bb229a1ec63f10c582ff5cec1f",
"gasLimit": 51874,
"gasPrice": "19000000000",
"gasUsed": 19583,
"hash": "0x0d3f4c59d1d5f3f86952a8c4ecb5ad0b729991f26039b99239da614a7e31b04f",
"input": "0xa9059cbb000000000000000000000000f64d731fc9c73cc8a815ffd2397a8346b3260cdf0000000000000000000000000000000000000000000000bca3532f388210ac57",
"internalTxns": [],
"maxFee": "19000000000",
"nonce": 54,
"position": 130,
"priorityFee": "19000000000",
"status": true,
"timestamp": "2021-07-13T01:51:54Z",
"to": "0xa3bed4e1c75d00fa6f4e5e6922db7261b5e9acd2",
"transactionFee": "372077000000000",
"type": "Legacy",
"value": "0"
}
]
}
}

Simulate a bundle of transactions by raw transaction

Request

API endpoint: https://api.blocksec.com/v1/phalcon/simulate/raw
curl --location --request POST 'https://api.blocksec.com/v1/phalcon/simulate/raw' \
--header 'Access-Token: $AccessToken' \
--header 'Content-Type: application/json' \
--data-raw '{
"chainID": 1,
"block":12816002,
"position":130,
"bundle":[
"0xf8a93685046c7cfe0082caa294a3bed4e1c75d00fa6f4e5e6922db7261b5e9acd280b844a9059cbb000000000000000000000000f64d731fc9c73cc8a815ffd2397a8346b3260cdf0000000000000000000000000000000000000000000000bca3532f388210ac5725a01a998fbcd3d7fda17de24fa98442ca03c9a29020bedc09bf8080af5d98a7f82ea0786dbbca0b11a2aa931beeaa8301e10f98b3737afaec3642c6ef15f2bce39730",
"0xf86e830397f385046c7cfe00825208949e4033b888c54471be675aa020739a4c8bc07cac87213a7107f3f5268026a099c04cf9771645219bbce1224c960ce2bd557b453401e924eeaa7f6bbf9dacd5a02c03fa8873a4cdace6fcfc07f3c5e4a6352f89c7a17e28f6c5f113f176e2c247"
]
}'
  • block: the block number in which the simulation runs
  • position: the position in the block
  • bundle: the raw transaction. Note, at most three transactions are supported in the bundle.

Response

{
"code": 0,
"message": "OK",
"data": {
"txns": [
{
"balanceChanges": [
{
"account": "0xc94ebb328ac25b95db0e0aa968371885fa516215",
"assets": [
{
"address": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
"amount": "-9352931370595622",
"decimals": 18
}
]
},
{
"account": "0x9e4033b888c54471be675aa020739a4c8bc07cac",
"assets": [
{
"address": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
"amount": "9352931370595622",
"decimals": 18
}
]
}
],
"block": 12816002,
"chainID": 1,
"error": "",
"events": [],
"from": "0xc94ebb328ac25b95db0e0aa968371885fa516215",
"gasLimit": 21000,
"gasPrice": "19000000000",
"gasUsed": 21000,
"hash": "0x134cd27d77fa56137095509e39dcf0e27b47810b45bf499cf8517f82f144660b",
"input": "0x",
"internalTxns": [],
"maxFee": "19000000000",
"nonce": 235507,
"position": 131,
"priorityFee": "19000000000",
"status": true,
"timestamp": "2021-07-13T01:51:54Z",
"to": "0x9e4033b888c54471be675aa020739a4c8bc07cac",
"transactionFee": "399000000000000",
"type": "Legacy",
"value": "9352931370595622"
},
{
"balanceChanges": [
{
"account": "0x78f8d8f58cd595bb229a1ec63f10c582ff5cec1f",
"assets": [
{
"address": "0xa3bed4e1c75d00fa6f4e5e6922db7261b5e9acd2",
"amount": "-3479756688028391746647",
"decimals": 18
}
]
},
{
"account": "0xf64d731fc9c73cc8a815ffd2397a8346b3260cdf",
"assets": [
{
"address": "0xa3bed4e1c75d00fa6f4e5e6922db7261b5e9acd2",
"amount": "3479756688028391746647",
"decimals": 18
}
]
}
],
"block": 12816002,
"chainID": 1,
"error": "",
"events": [
{
"address": "0xa3bed4e1c75d00fa6f4e5e6922db7261b5e9acd2",
"data": "0x0000000000000000000000000000000000000000000000bca3532f388210ac57",
"topics": [
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
"0x00000000000000000000000078f8d8f58cd595bb229a1ec63f10c582ff5cec1f",
"0x000000000000000000000000f64d731fc9c73cc8a815ffd2397a8346b3260cdf"
]
}
],
"from": "0x78f8d8f58cd595bb229a1ec63f10c582ff5cec1f",
"gasLimit": 51874,
"gasPrice": "19000000000",
"gasUsed": 19583,
"hash": "0x0d3f4c59d1d5f3f86952a8c4ecb5ad0b729991f26039b99239da614a7e31b04f",
"input": "0xa9059cbb000000000000000000000000f64d731fc9c73cc8a815ffd2397a8346b3260cdf0000000000000000000000000000000000000000000000bca3532f388210ac57",
"internalTxns": [],
"maxFee": "19000000000",
"nonce": 54,
"position": 130,
"priorityFee": "19000000000",
"status": true,
"timestamp": "2021-07-13T01:51:54Z",
"to": "0xa3bed4e1c75d00fa6f4e5e6922db7261b5e9acd2",
"transactionFee": "372077000000000",
"type": "Legacy",
"value": "0"
}
]
}
}

Simulate a bundle of transactions with customized inputs

This API provides the capability to simulate a transaction with customized inputs, e.g., from, to, input, value, etc.
API endpoint: https://api.blocksec.com/v1/phalcon/simulate/custom

request

curl --location --request POST 'https://api.blocksec.com/v1/phalcon/simulate/custom' \
--header 'Access-Token: $AccessToken' \
--header 'Content-Type: application/json' \
--data-raw '{
"chainID": 1,
"block":12816002,
"position":130,
"bundle":[
{
"from":"0xc94ebb328ac25b95db0e0aa968371885fa516215",
"to":"0x9e4033b888c54471be675aa020739a4c8bc07cac",
"input":"",
"value":"9352931370595622",
"gasLimit":21000,
"gasPrice":"19000000000"
},
{
"from":"0x78f8d8f58cd595bb229a1ec63f10c582ff5cec1f",
"to":"0xa3bed4e1c75d00fa6f4e5e6922db7261b5e9acd2",
"input":"0xa9059cbb000000000000000000000000f64d731fc9c73cc8a815ffd2397a8346b3260cdf0000000000000000000000000000000000000000000000bca3532f388210ac57",
"value":"0",
"gasLimit":51874,
"gasPrice":"19000000000"
}
]
}'
  • to: could be zero, means creating a contract
  • value and gasPrice are in wei
  • bundle : the customized inputs in the bundle. Note, at most three transactions are supported in the bundle.
{
"code": 0,
"message": "OK",
"data": {
"txns": [
{
"balanceChanges": [
{
"account": "0x78f8d8f58cd595bb229a1ec63f10c582ff5cec1f",
"assets": [
{
"address": "0xa3bed4e1c75d00fa6f4e5e6922db7261b5e9acd2",
"amount": "-3479756688028391746647",
"decimals": 18
}
]
},
{
"account": "0xf64d731fc9c73cc8a815ffd2397a8346b3260cdf",
"assets": [
{
"address": "0xa3bed4e1c75d00fa6f4e5e6922db7261b5e9acd2",
"amount": "3479756688028391746647",
"decimals": 18
}
]
}
],
"block": 12816002,
"chainID": 1,
"error": "",
"events": [
{
"address": "0xa3bed4e1c75d00fa6f4e5e6922db7261b5e9acd2",
"data": "0x0000000000000000000000000000000000000000000000bca3532f388210ac57",
"topics": [
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
"0x00000000000000000000000078f8d8f58cd595bb229a1ec63f10c582ff5cec1f",
"0x000000000000000000000000f64d731fc9c73cc8a815ffd2397a8346b3260cdf"
]
}
],
"from": "0x78f8d8f58cd595bb229a1ec63f10c582ff5cec1f",
"gasLimit": 51874,
"gasPrice": "19000000000",
"gasUsed": 19583,
"hash": "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470",
"input": "0xa9059cbb000000000000000000000000f64d731fc9c73cc8a815ffd2397a8346b3260cdf0000000000000000000000000000000000000000000000bca3532f388210ac57",
"internalTxns": [],
"maxFee": "19000000000",
"nonce": 54,
"position": 131,
"priorityFee": "19000000000",
"status": true,
"timestamp": "2021-07-13T01:51:54Z",
"to": "0xa3bed4e1c75d00fa6f4e5e6922db7261b5e9acd2",
"transactionFee": "372077000000000",
"type": "Legacy",
"value": "0"
},
{
"balanceChanges": [
{
"account": "0xc94ebb328ac25b95db0e0aa968371885fa516215",
"assets": [
{
"address": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
"amount": "-9352931370595622",
"decimals": 18
}
]
},
{
"account": "0x9e4033b888c54471be675aa020739a4c8bc07cac",
"assets": [
{
"address": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
"amount": "9352931370595622",
"decimals": 18
}
]
}
],
"block": 12816002,
"chainID": 1,
"error": "",
"events": [],
"from": "0xc94ebb328ac25b95db0e0aa968371885fa516215",
"gasLimit": 21000,
"gasPrice": "19000000000",
"gasUsed": 21000,
"hash": "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470",
"input": "0x",
"internalTxns": [],
"maxFee": "19000000000",
"nonce": 235507,
"position": 130,
"priorityFee": "19000000000",
"status": true,
"timestamp": "2021-07-13T01:51:54Z",
"to": "0x9e4033b888c54471be675aa020739a4c8bc07cac",
"transactionFee": "399000000000000",
"type": "Legacy",
"value": "9352931370595622"
}
]
}
}