How to get transaction changes by hash
Prerequisites
Before getting started, make sure you have the following ready:
- Node v.14+
- NPM
Step 1: Setup Blocklens
First register your Blocklens account and get your Blocklens API Key.
Once you have your Blocklens API Key, install the Blocklens SDK in your project.
npm i blocklens-sdk
Step 2: Get transaction changes by hash
In order to get transaction changes by hash, Blocklens provides you a getTransactionChanges endpoint to do so.
Here you'll need a parameter: transaction_hash
.
Once you've obtained the transaction_hash
, you can copy the following code:
import Blocklens from "blocklens-sdk";
const blocklens = new Blocklens();
blocklens.init({ apiKey: "YOUR_API_KEY" });
const runApis = async () => {
const response = await blocklens.APTOS_MAINNET.getTransactionChanges("0x12259c8b5a0f51320bb1b64dfb2b1b61e24aaa127318b0cf92d209525f0d5447");
console.log(response);
};
runApis();
Step 3: Run the script
ts-node index.ts
In your terminal, you should see the following JSON response with the data: In your terminal, you should see the following JSON response with the data blocks:
[
{
"cursor": "string",
"page": 0,
"limit": 0,
"total_items": 0,
"data": [
{
"block_height": 1,
"timestamp": 1,
"transaction_version": 1,
"transaction_type": "block_metadata_transaction",
"transaction_hash": "0xbf3d139d0bbe68f1db6d393b135c2ed12ab5ec1635f08b26994180d1e6434dd1",
"type": "write_resource",
"address": "0x1",
"state_key_hash": "0x7b1615bf012d3c94223f3f76287ee2f7bdf31d364071128b256aeff0841b626d",
"block_hash": "0x33ff405ce7f5e1cff01eccff5c5ee93a532f69c7ce641ab907d6908ab3807da1",
"change_index": "1",
"data": "{\"type\":\"0x1::timestamp::CurrentTimeMicroseconds\",\"data\":{\"microseconds\":\"1695436685674336\"}}",
"data_type": "0x1::timestamp::CurrentTimeMicroseconds",
"handle": "0x1b854694ae746cdbd8d44186ca4929b2b337df21d1c74633be19b2710552fdca",
"key": "0x0619dc29a0aac8fa146714058e8dd6d2d0f3bdf5f6331907bf91f3acd81e6935",
"resource": "null",
"success": true,
"value": "0xbe43205d6f5877010000000000000000",
"vm_status": "Executed successfully"
}
]
}
]
Congratulations 🥳 you just found the get transaction changes by hash on multiple chains with only a few lines of code using the Blocklens Wallet API!
API Reference
If you want to know more details on the endpoint and optional parameters, check out:
Support
If you face any trouble following the tutorial, feel free to reach out to our community engineers in our Discord or Forum to get 24/7 developer support.