Skip to Content

🚧 These packages are still in development and may change rapidly as they are developed.

TypeScriptsimulateTransaction

simulateTransaction

This function is used to simulate a transaction before submitting it to the Aptos blockchain.

Usage

import { AptosJSProClient } from "@aptos-labs/js-pro"; const client = new AptosJSProClient({ /* ... */ }); const transaction = await client.buildTransaction({ data: { function: "0x1::aptos_account::transfer", functionArguments: [account.accountAddress, 100], }, }); const simulationResult = await client.simulateTransaction({ transaction });

Parameters

The simulateTransaction function has two types of parameters: SimulateSimpleTransactionParameters or SimulateMultiAgentTransactionParameters.

SimulateSimpleTransactionParameters

NameTypeDefault
signerPublicKeyPublicKey
transactionAnyRawTransaction
feePayerPublicKeyPublicKey
optionsInputSimulateTransactionOptions
networkNetworkInfo

The network to use for the request. If not set, the network of the AptosJSProClient instance will be used.

SimulateMultiAgentTransactionParameters

NameTypeDefault
signerPublicKeyPublicKey
transactionAnyRawTransaction
secondarySignersPublicKeys(PublicKey | undefined)[]
feePayerPublicKeyPublicKey
optionsInputSimulateTransactionOptions
networkNetworkInfo

The network to use for the request. If not set, the network of the AptosJSProClient instance will be used.

Return Type

NameTypeDefault
typeTransactionResponseType.User
versionstring
hashstring
state_change_hashstring
event_root_hashstring
state_checkpoint_hashstring | null
gas_usedstring
successboolean

Whether the transaction was successful

vm_statusstring

The VM status of the transaction, can tell useful information in a failure

accumulator_root_hashstring
changesWriteSetChange[]

Final state of resources changed by the transaction

senderstring
sequence_numberstring
replay_protection_noncestring
max_gas_amountstring
gas_unit_pricestring
expiration_timestamp_secsstring
payloadTransactionPayloadResponse
signatureTransactionSignature
eventsEvent[]

Events generated by the transaction

timestampstring
Last updated on