Simulate Transaction

The output of the transaction will have the exact transaction outputs and events that running an actual signed transaction would have.

This method will use 50 Compute Units.


Simulate transaction

post

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_max_gas_amountbooleanOptional

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

estimate_gas_unit_pricebooleanOptional

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

estimate_prioritized_gas_unit_pricebooleanOptional

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

Body

A request to submit a transaction

This requires a transaction and a signature of it

senderstring · hexRequired

A hex encoded 32 byte Aptos account address.

This is represented in a string as a 64 character hex string, sometimes shortened by stripping leading 0s, and adding a 0x.

For example, address 0x0000000000000000000000000000000000000000000000000000000000000001 is represented as 0x1.

Example: 0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1
sequence_numberstring · uint64Required

A string containing a 64-bit unsigned integer.

We represent u64 values as a string to ensure compatibility with languages such as JavaScript that do not parse u64s in JSON natively.

Example: 32425224034
max_gas_amountstring · uint64Required

A string containing a 64-bit unsigned integer.

We represent u64 values as a string to ensure compatibility with languages such as JavaScript that do not parse u64s in JSON natively.

Example: 32425224034
gas_unit_pricestring · uint64Required

A string containing a 64-bit unsigned integer.

We represent u64 values as a string to ensure compatibility with languages such as JavaScript that do not parse u64s in JSON natively.

Example: 32425224034
expiration_timestamp_secsstring · uint64Required

A string containing a 64-bit unsigned integer.

We represent u64 values as a string to ensure compatibility with languages such as JavaScript that do not parse u64s in JSON natively.

Example: 32425224034
payloadone ofRequired

An enum of the possible transaction payloads

all ofOptional
and
or
all ofOptional
and
or
all ofOptional
or
all ofOptional
and
signatureone ofRequired

An enum representing the different transaction signatures available

all ofOptional
and
or
all ofOptional
and
or
all ofOptional
and
Responses
post
POST /v1/<YOUR_API_KEY_HERE>/v1/transactions/simulate HTTP/1.1
Host: mainnet.aptos.validationcloud.io
Content-Type: application/json
Accept: */*
Content-Length: 546

{
  "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": [
      "text"
    ],
    "arguments": []
  },
  "signature": {
    "type": "ed25519_signature",
    "public_key": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 ",
    "signature": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 "
  }
}
[
  {
    "version": "32425224034",
    "hash": "text",
    "state_change_hash": "text",
    "event_root_hash": "text",
    "state_checkpoint_hash": "text",
    "gas_used": "32425224034",
    "success": true,
    "vm_status": "text",
    "accumulator_root_hash": "text",
    "changes": [
      {
        "type": "delete_module",
        "address": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 ",
        "state_key_hash": "text",
        "module": "0x1::aptos_coin"
      }
    ],
    "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": [
        "text"
      ],
      "arguments": []
    },
    "signature": {
      "type": "ed25519_signature",
      "public_key": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 ",
      "signature": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 "
    },
    "events": [
      {
        "guid": {
          "creation_number": "32425224034",
          "account_address": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 "
        },
        "sequence_number": "32425224034",
        "type": "text",
        "data": null
      }
    ],
    "timestamp": "32425224034"
  }
]

Last updated

Was this helpful?