How to get transaction payloads from version to version
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 payloads from version to version
In order to get transaction payloads from version to version, Blocklens provides you a getTransactionPayloadFromVersionToVersion endpoint to do so.
Here you'll need parameters: from_version
, to_version
.
Once you've obtained all the from_version
, to_version
, 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.getTransactionPayloadFromVersionToVersion({"from_version":271891980,"to_version":271891981});
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": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MjcxODkxOTgwLCJwYWdlIjoxLCJmcm9tX3ZlcnNpb24iOjI3MTg5MTk4MCwidG9fdmVyc2lvbiI6MjcxODkxOTgxLCJpYXQiOjE2OTcwNjA5NTd9.pO_iKPPbdXV8ZSkxHvrnK_CzWIhvaDj9x9ddyEixg30",
"page": 1,
"limit": 20,
"total_items": 1,
"data": [
{
"block_height": 95397542,
"timestamp": 1695436683,
"transaction_version": 271891981,
"transaction_hash": "0x361a18bc1ee54c2f29067a40f0c33457347cfe95166ba89d078f0157b637285c",
"transaction_type": "user_transaction",
"function": "0x7d7e436f0b2aafde60774efb26ccc432cf881b677aca7faaf2a01879bd19fb8::crank_pop_action::run",
"type_arguments": "[\"0x1::aptos_coin::AptosCoin\"]",
"arguments": "[\"0xbc9576fedda51d33e8129b5f122ef4707c2079dfb11cd836e86adcb168cbd473\",\"8\"]",
"block_hash": "0x7114cc9d55eb93377a5f8a1f375807a6ebec3f65826217ddb02a71af777e71e7",
"success": true,
"type": "entry_function_payload",
"vm_status": "Executed successfully"
}
]
}
Congratulations 🥳 you just found the get transaction payloads from version to version 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.