Get Transaction by Hash
Look up a transaction by its hash. This is the same hash that is returned by the API when submitting a transaction (see PendingTransaction).
When given a transaction hash, the server first looks for the transaction in storage (on-chain, committed). If no on-chain transaction is found, it looks the transaction up by hash in the mempool (pending, not yet committed).
To create a transaction hash by yourself, do the following:
- Hash message bytes: “RawTransaction” bytes + BCS bytes of Transaction.
- Apply hash algorithm
SHA3-256to the hash message bytes. - Hex-encode the hash bytes with
0xprefix.
curl --request GET \
--url 'https://mainnet.aptos.validationcloud.io/v1/<YOUR_API_KEY_HERE>/v1/transactions/by_hash/{txn_hash}'import requests
url = "https://mainnet.aptos.validationcloud.io/v1/<YOUR_API_KEY_HERE>/v1/transactions/by_hash/{txn_hash}"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://mainnet.aptos.validationcloud.io/v1/<YOUR_API_KEY_HERE>/v1/transactions/by_hash/{txn_hash}', 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/by_hash/{txn_hash}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://mainnet.aptos.validationcloud.io/v1/<YOUR_API_KEY_HERE>/v1/transactions/by_hash/{txn_hash}"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://mainnet.aptos.validationcloud.io/v1/<YOUR_API_KEY_HERE>/v1/transactions/by_hash/{txn_hash}")
.asString();require 'uri'
require 'net/http'
url = URI("https://mainnet.aptos.validationcloud.io/v1/<YOUR_API_KEY_HERE>/v1/transactions/by_hash/{txn_hash}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
"type": "pending_transaction",
"hash": "<string>",
"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 "
}
}{
"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
}15 Compute Units.
Path Parameters
Hash of transaction to retrieve
Response
- Option 1
- Option 2
- Option 3
- Option 4
- Option 5
A transaction waiting in mempool
"pending_transaction"
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 "
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.
"32425224034"
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.
"32425224034"
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.
"32425224034"
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.
"32425224034"
Payload which runs a single entry function
- Option 1
- Option 2
- Option 3
- Option 4
Show child attributes
Show child attributes
A single Ed25519 signature
- Option 1
- Option 2
- Option 3
Show child attributes
Show child attributes
curl --request GET \
--url 'https://mainnet.aptos.validationcloud.io/v1/<YOUR_API_KEY_HERE>/v1/transactions/by_hash/{txn_hash}'import requests
url = "https://mainnet.aptos.validationcloud.io/v1/<YOUR_API_KEY_HERE>/v1/transactions/by_hash/{txn_hash}"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://mainnet.aptos.validationcloud.io/v1/<YOUR_API_KEY_HERE>/v1/transactions/by_hash/{txn_hash}', 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/by_hash/{txn_hash}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://mainnet.aptos.validationcloud.io/v1/<YOUR_API_KEY_HERE>/v1/transactions/by_hash/{txn_hash}"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://mainnet.aptos.validationcloud.io/v1/<YOUR_API_KEY_HERE>/v1/transactions/by_hash/{txn_hash}")
.asString();require 'uri'
require 'net/http'
url = URI("https://mainnet.aptos.validationcloud.io/v1/<YOUR_API_KEY_HERE>/v1/transactions/by_hash/{txn_hash}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
"type": "pending_transaction",
"hash": "<string>",
"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 "
}
}{
"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
}