Simulate transaction

The output of the transaction will have the exact transaction outputs and events that running an actual signed transaction would have. However, it will not have the associated state hashes, as they are not updated in storage. This can be used to estimate the maximum gas units for a submitted transaction.

To use this, you must:

  • Create a SignedTransaction with a zero-padded signature.

  • Submit a SubmitTransactionRequest containing a UserTransactionRequest containing that signature.

To use this endpoint with BCS, you must submit a SignedTransaction encoded as BCS. See SignedTransaction in types/src/transaction/mod.rs.

Query Parameters::

estimate_gas_unit_price boolean

If set to true, the gas unit price in the transaction will be ignored and the estimated value will be used

estimate_max_gas_amount boolean

If set to true, the max gas value in the transaction will be ignored and the maximum possible gas will be used

estimate_prioritized_gas_unit_price boolean

If set to true, the transaction will use a higher price than the original estimate.

Request body:

A request to submit a transaction

sender string<hex> required

A hex encoded 32 byte Aptos account address.

sequence_number string<uint64> required

A string containing a 64-bit unsigned integer.

max_gas_amount string<uint64> required

A string containing a 64-bit unsigned integer.

gas_unit_price string<uint64> required

A string containing a 64-bit unsigned integer.

expiration_timestamp_secs string<uint64> required

A string containing a 64-bit unsigned integer.

payload object required

Payload which runs a single entry function, or

Payload which runs a script that can run multiple functions, or

An enum of the possible transaction payloads

signature object required

A single Ed25519 signature, or

A Ed25519 multi-sig signature, or

Multi agent signature for multi agent transactions

Response Header:

X-APTOS-BLOCK-HEIGHT integer

Current block height of the chain

X-APTOS-CHAIN-ID integer

Chain ID of the current chain

X-APTOS-EPOCH integer

Current epoch of the chain

X-APTOS-LEDGER-OLDEST-VERSION integer

Oldest non-pruned ledger version of the chain

X-APTOS-LEDGER-TIMESTAMPUSEC integer

Current timestamp of the chain

X-APTOS-LEDGER-VERSION integer

Current ledger version of the chain

X-APTOS-OLDEST-BLOCK-HEIGHT integer

Oldest non-pruned block height of the chain

Response Body:

Array

Example:

// Request
curl -X POST -H 'Content-Type: application/json' https://aptos.blockpi.network/aptos/v1/your_api_key/v1/transactions/simulate
--data
{
  "sender": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 ",
  "sequence_number": "32425224034",
  "max_gas_amount": "32425224034",
  "gas_unit_price": "32425224034",
  "expiration_timestamp_secs": "32425224034",
  "payload": {
    "type": "entry_function_payload",
    "function": "0x1::aptos_coin::transfer",
    "type_arguments": [
      "string"
    ],
    "arguments": [
      null
    ]
  },
  "signature": {
    "type": "ed25519_signature",
    "public_key": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 ",
    "signature": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 "
  }
}

// Result
{

}

Last updated