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.
curl --request POST \
--url 'https://mainnet.aptos.validationcloud.io/v1/<YOUR_API_KEY_HERE>/v1/transactions/simulate' \
--header 'Content-Type: application/json' \
--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": [
"<unknown>"
]
},
"signature": {
"type": "ed25519_signature",
"public_key": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 ",
"signature": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 "
}
}
'import requests
url = "https://mainnet.aptos.validationcloud.io/v1/<YOUR_API_KEY_HERE>/v1/transactions/simulate"
payload = {
"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": ["<unknown>"]
},
"signature": {
"type": "ed25519_signature",
"public_key": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 ",
"signature": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 "
}
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
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: ['<unknown>']
},
signature: {
type: 'ed25519_signature',
public_key: '0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 ',
signature: '0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 '
}
})
};
fetch('https://mainnet.aptos.validationcloud.io/v1/<YOUR_API_KEY_HERE>/v1/transactions/simulate', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://mainnet.aptos.validationcloud.io/v1/<YOUR_API_KEY_HERE>/v1/transactions/simulate",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'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' => [
'<unknown>'
]
],
'signature' => [
'type' => 'ed25519_signature',
'public_key' => '0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 ',
'signature' => '0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 '
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://mainnet.aptos.validationcloud.io/v1/<YOUR_API_KEY_HERE>/v1/transactions/simulate"
payload := strings.NewReader("{\n \"sender\": \"0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 \",\n \"sequence_number\": \"32425224034\",\n \"max_gas_amount\": \"32425224034\",\n \"gas_unit_price\": \"32425224034\",\n \"expiration_timestamp_secs\": \"32425224034\",\n \"payload\": {\n \"type\": \"entry_function_payload\",\n \"function\": \"0x1::aptos_coin::transfer\",\n \"type_arguments\": [\n \"<string>\"\n ],\n \"arguments\": [\n \"<unknown>\"\n ]\n },\n \"signature\": {\n \"type\": \"ed25519_signature\",\n \"public_key\": \"0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 \",\n \"signature\": \"0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 \"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://mainnet.aptos.validationcloud.io/v1/<YOUR_API_KEY_HERE>/v1/transactions/simulate")
.header("Content-Type", "application/json")
.body("{\n \"sender\": \"0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 \",\n \"sequence_number\": \"32425224034\",\n \"max_gas_amount\": \"32425224034\",\n \"gas_unit_price\": \"32425224034\",\n \"expiration_timestamp_secs\": \"32425224034\",\n \"payload\": {\n \"type\": \"entry_function_payload\",\n \"function\": \"0x1::aptos_coin::transfer\",\n \"type_arguments\": [\n \"<string>\"\n ],\n \"arguments\": [\n \"<unknown>\"\n ]\n },\n \"signature\": {\n \"type\": \"ed25519_signature\",\n \"public_key\": \"0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 \",\n \"signature\": \"0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 \"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://mainnet.aptos.validationcloud.io/v1/<YOUR_API_KEY_HERE>/v1/transactions/simulate")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"sender\": \"0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 \",\n \"sequence_number\": \"32425224034\",\n \"max_gas_amount\": \"32425224034\",\n \"gas_unit_price\": \"32425224034\",\n \"expiration_timestamp_secs\": \"32425224034\",\n \"payload\": {\n \"type\": \"entry_function_payload\",\n \"function\": \"0x1::aptos_coin::transfer\",\n \"type_arguments\": [\n \"<string>\"\n ],\n \"arguments\": [\n \"<unknown>\"\n ]\n },\n \"signature\": {\n \"type\": \"ed25519_signature\",\n \"public_key\": \"0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 \",\n \"signature\": \"0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 \"\n }\n}"
response = http.request(request)
puts response.read_body[
{
"version": "32425224034",
"hash": "<string>",
"state_change_hash": "<string>",
"event_root_hash": "<string>",
"gas_used": "32425224034",
"success": true,
"vm_status": "<string>",
"accumulator_root_hash": "<string>",
"changes": [
{
"type": "delete_module",
"address": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 ",
"state_key_hash": "<string>",
"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": [
"<string>"
],
"arguments": [
"<unknown>"
]
},
"events": [
{
"guid": {
"creation_number": "32425224034",
"account_address": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 "
},
"sequence_number": "32425224034",
"type": "<string>",
"data": "<unknown>"
}
],
"timestamp": "32425224034",
"state_checkpoint_hash": "<string>",
"signature": {
"type": "ed25519_signature",
"public_key": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 ",
"signature": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 "
}
}
]{
"message": "<string>",
"error_code": "account_not_found",
"vm_error_code": 123
}{
"message": "<string>",
"error_code": "account_not_found",
"vm_error_code": 123
}{
"message": "<string>",
"error_code": "account_not_found",
"vm_error_code": 123
}{
"message": "<string>",
"error_code": "account_not_found",
"vm_error_code": 123
}{
"message": "<string>",
"error_code": "account_not_found",
"vm_error_code": 123
}{
"message": "<string>",
"error_code": "account_not_found",
"vm_error_code": 123
}50 Compute Units.
Query Parameters
Body
A request to submit a transaction
This requires a transaction and a signature of it
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.
"0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 "
Response
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.
"0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 "
curl --request POST \
--url 'https://mainnet.aptos.validationcloud.io/v1/<YOUR_API_KEY_HERE>/v1/transactions/simulate' \
--header 'Content-Type: application/json' \
--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": [
"<unknown>"
]
},
"signature": {
"type": "ed25519_signature",
"public_key": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 ",
"signature": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 "
}
}
'import requests
url = "https://mainnet.aptos.validationcloud.io/v1/<YOUR_API_KEY_HERE>/v1/transactions/simulate"
payload = {
"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": ["<unknown>"]
},
"signature": {
"type": "ed25519_signature",
"public_key": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 ",
"signature": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 "
}
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
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: ['<unknown>']
},
signature: {
type: 'ed25519_signature',
public_key: '0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 ',
signature: '0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 '
}
})
};
fetch('https://mainnet.aptos.validationcloud.io/v1/<YOUR_API_KEY_HERE>/v1/transactions/simulate', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://mainnet.aptos.validationcloud.io/v1/<YOUR_API_KEY_HERE>/v1/transactions/simulate",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'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' => [
'<unknown>'
]
],
'signature' => [
'type' => 'ed25519_signature',
'public_key' => '0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 ',
'signature' => '0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 '
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://mainnet.aptos.validationcloud.io/v1/<YOUR_API_KEY_HERE>/v1/transactions/simulate"
payload := strings.NewReader("{\n \"sender\": \"0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 \",\n \"sequence_number\": \"32425224034\",\n \"max_gas_amount\": \"32425224034\",\n \"gas_unit_price\": \"32425224034\",\n \"expiration_timestamp_secs\": \"32425224034\",\n \"payload\": {\n \"type\": \"entry_function_payload\",\n \"function\": \"0x1::aptos_coin::transfer\",\n \"type_arguments\": [\n \"<string>\"\n ],\n \"arguments\": [\n \"<unknown>\"\n ]\n },\n \"signature\": {\n \"type\": \"ed25519_signature\",\n \"public_key\": \"0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 \",\n \"signature\": \"0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 \"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://mainnet.aptos.validationcloud.io/v1/<YOUR_API_KEY_HERE>/v1/transactions/simulate")
.header("Content-Type", "application/json")
.body("{\n \"sender\": \"0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 \",\n \"sequence_number\": \"32425224034\",\n \"max_gas_amount\": \"32425224034\",\n \"gas_unit_price\": \"32425224034\",\n \"expiration_timestamp_secs\": \"32425224034\",\n \"payload\": {\n \"type\": \"entry_function_payload\",\n \"function\": \"0x1::aptos_coin::transfer\",\n \"type_arguments\": [\n \"<string>\"\n ],\n \"arguments\": [\n \"<unknown>\"\n ]\n },\n \"signature\": {\n \"type\": \"ed25519_signature\",\n \"public_key\": \"0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 \",\n \"signature\": \"0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 \"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://mainnet.aptos.validationcloud.io/v1/<YOUR_API_KEY_HERE>/v1/transactions/simulate")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"sender\": \"0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 \",\n \"sequence_number\": \"32425224034\",\n \"max_gas_amount\": \"32425224034\",\n \"gas_unit_price\": \"32425224034\",\n \"expiration_timestamp_secs\": \"32425224034\",\n \"payload\": {\n \"type\": \"entry_function_payload\",\n \"function\": \"0x1::aptos_coin::transfer\",\n \"type_arguments\": [\n \"<string>\"\n ],\n \"arguments\": [\n \"<unknown>\"\n ]\n },\n \"signature\": {\n \"type\": \"ed25519_signature\",\n \"public_key\": \"0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 \",\n \"signature\": \"0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 \"\n }\n}"
response = http.request(request)
puts response.read_body[
{
"version": "32425224034",
"hash": "<string>",
"state_change_hash": "<string>",
"event_root_hash": "<string>",
"gas_used": "32425224034",
"success": true,
"vm_status": "<string>",
"accumulator_root_hash": "<string>",
"changes": [
{
"type": "delete_module",
"address": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 ",
"state_key_hash": "<string>",
"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": [
"<string>"
],
"arguments": [
"<unknown>"
]
},
"events": [
{
"guid": {
"creation_number": "32425224034",
"account_address": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 "
},
"sequence_number": "32425224034",
"type": "<string>",
"data": "<unknown>"
}
],
"timestamp": "32425224034",
"state_checkpoint_hash": "<string>",
"signature": {
"type": "ed25519_signature",
"public_key": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 ",
"signature": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 "
}
}
]{
"message": "<string>",
"error_code": "account_not_found",
"vm_error_code": 123
}{
"message": "<string>",
"error_code": "account_not_found",
"vm_error_code": 123
}{
"message": "<string>",
"error_code": "account_not_found",
"vm_error_code": 123
}{
"message": "<string>",
"error_code": "account_not_found",
"vm_error_code": 123
}{
"message": "<string>",
"error_code": "account_not_found",
"vm_error_code": 123
}{
"message": "<string>",
"error_code": "account_not_found",
"vm_error_code": 123
}