BlockSec Documents
Search…
⌃K

Pre-execution API

📌
Please get in touch with us for the access token before using the pre-execution API.
The APIs can be invoked 100 times each day, with a rate limit of 60 times each minute for each access token. Currently, pre-execution APIs support ETH and BSC. The support of more chains will come soon.
📬
Contact us if need to increase the limitation.

Pre-execution with raw transactions

Request

  • Endpoint: https://api.blocksec.com/v1/mopsus/prerun/raw
  • Method: POST
    • Request data format
{
"bundle":[ "0xf86d8205f085029f64e98282659094388c818ca8b9251b393131c08a736a67ccb1929787a2507840d1e38f8025a02ebb225fe0858da50af8ac78e15b3fe136578f091685f04fe35da1a8cccd21aea070b88e2d9e82adb77af5daf85a06b2676e213e9bfd5e79aa98144d4c4c6ef798"]
}
A maximum of three transactions are allowed in a bundle.

Response

{
"code": 0,
"message": "OK",
"data": {
"txns": [
{
"balanceChanges": [
{
"account": "0x388c818ca8b9251b393131c08a736a67ccb19297",
"assets": [
{
"address": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
"amount": "45687423640920975",
"decimals": 18,
"value": "69.06293707"
}
]
},
{
"account": "0x25d88437df70730122b73ef35462435d187c466f",
"assets": [
{
"address": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
"amount": "-45687423640920975",
"decimals": 18,
"value": "-69.06293707"
}
]
}
],
"baseFee": "9103732876",
"block": 15845006,
"chainID": 1,
"error": "",
"events": [
{
"address": "0x388c818ca8b9251b393131c08a736a67ccb19297",
"data": "0x00000000000000000000000000000000000000000000000000a2507840d1e38f",
"topics": [
"0x27f12abfe35860a9a927b465bb3d4a9c23c8428174b83f278fe45ed7b4da2662"
]
}
],
"from": "0x25d88437df70730122b73ef35462435d187c466f",
"gasLimit": 26000,
"gasPrice": "11264125314",
"gasUsed": 22111,
"hash": "0x8aba23d5005aa00b7ace5ec485c924f299cc290a3a3b7291857d20c4922fef64",
"input": "0x",
"internalTxns": [],
"nonce": 1520,
"position": 0,
"status": true,
"to": "0x388c818ca8b9251b393131c08a736a67ccb19297",
"transactionFee": "249061074817854",
"type": "Legacy",
"value": "45687423640920975"
}
]
}
}
  • Note
    • code zero means the request is successful.
    • baseFee, transactionFee, and value are in Wei
    • The value of assets is in USD. This field can be empty if the asset's price cannot be obtained.
    • The amount of assets is the original value.
    • If the decimals of assets are less than zero, the token is not a standard ERC-20 token.
    • 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee represents native token.
  • Example
Replace accessToken with a real one.
curl --location --request POST 'https://api.blocksec.com/v1/mopsus/prerun/raw' \
--header 'Access-Token: $accessToken' \
--header 'Content-Type: application/json' \
--data-raw '{
"bundle":[
"0xf86d8205f085029f64e98282659094388c818ca8b9251b393131c08a736a67ccb1929787a2507840d1e38f8025a02ebb225fe0858da50af8ac78e15b3fe136578f091685f04fe35da1a8cccd21aea070b88e2d9e82adb77af5daf85a06b2676e213e9bfd5e79aa98144d4c4c6ef798"
]
}'

Pre-execution with custom parameters

Request

  • Endpoint: https://api.blocksec.com/v1/mopsus/prerun/custom
  • Method: POST
  • Request data format
{
"chainID": 1,
"bundle": [{
"sender": "0x151b381058f91cf871e7ea1ee83c45326f61e96d",
"receiver": "0x55dbac71d136a8ad02edd815b1e1b9217e4a9e22",
"gasLimit": 21000,
"gasPrice": "20634341671000",// Wei
"value": "9000000000000000", // Wei
"input": "0x"
}]
}
  • receiver: can be an empty string if the transaction is to create a contract.
  • The gasPrice & value is in Wei.
A maximum of three transactions are allowed in a bundle.

Response

{
"code": 0,
"message": "OK",
"data": {
"txns": [
{
"balanceChanges": [
{
"account": "0x151b381058f91cf871e7ea1ee83c45326f61e96d",
"assets": [
{
"address": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
"amount": "-90000000000000000000",
"decimals": 18,
"value": "-136047.6"
}
]
},
{
"account": "0x55dbac71d136a8ad02edd815b1e1b9217e4a9e22",
"assets": [
{
"address": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
"amount": "90000000000000000000",
"decimals": 18,
"value": "136047.6"
}
]
}
],
"baseFee": "8438268121",
"block": 15845014,
"chainID": 1,
"error": "",
"events": [],
"from": "0x151b381058f91cf871e7ea1ee83c45326f61e96d",
"gasLimit": 21000,
"gasPrice": "20634341671",
"gasUsed": 21000,
"hash": "0x3bc7ecae2e0ef7d4523eb456c450670a527df4af43cde4036f485d81341958a2",
"input": "0x",
"internalTxns": [],
"nonce": 285388,
"position": 0,
"status": true,
"to": "0x55dbac71d136a8ad02edd815b1e1b9217e4a9e22",
"transactionFee": "433321175091000",
"type": "Legacy",
"value": "90000000000000000000"
}
]
}
}
  • Note
    • 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee represents native token.

Error Information

The code in the response shows whether the request is successful. The value zero means a successful request.
  • A successful request
{
"code": 0,
"message": "OK",
"data": {...}
}
  • A failed request
{
"code": 1,
"message": "Authentication failed. Make sure to use the correct Access-Token"
}