How to get transaction changes 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 changes from version to version
In order to get transaction changes from version to version, Blocklens provides you a getTransactionChangesFromVersionToVersion 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.getTransactionChangesFromVersionToVersion({"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.eyJpZCI6MjcxODkxOTgwMDAwMDAwLCJwYWdlIjoxLCJmcm9tX3ZlcnNpb24iOjI3MTg5MTk4MCwidG9fdmVyc2lvbiI6MjcxODkxOTgxLCJpYXQiOjE2OTcwNjA1MTl9._xAxAQzKrAoixGfr3hwvsvkshcx8vhKG1EwlNUY_A6I",
"page": 1,
"limit": 20,
"total_items": 1,
"data": [
{
"block_height": 95397542,
"timestamp": 1695436683,
"transaction_version": 271891981,
"transaction_type": "user_transaction",
"transaction_hash": "0x361a18bc1ee54c2f29067a40f0c33457347cfe95166ba89d078f0157b637285c",
"type": "write_table_item",
"address": "null",
"state_key_hash": "0xd33f6ca8e6e6e40f8cf31184f5a3b36ea8bc7acbc2d95cba0a07409def9c8798",
"block_hash": "0x7114cc9d55eb93377a5f8a1f375807a6ebec3f65826217ddb02a71af777e71e7",
"change_index": "11",
"data": "null",
"data_type": "null",
"handle": "0x56efc89bbf2806f6ebe1c7cece92c00ea2d775eef46f6e1798116bf0cbb0519a",
"key": "0x11fbd91e4a718066891f37958f0b68d10e720f2edf8d57854fb20c299a119a8c",
"resource": "null",
"success": true,
"value": "0x7a524f6300000000f92bc956b9e25f38a2e4829b58f03ca9724233985cdda3f818bc3e62d6ed7d9c00000000000000000000",
"vm_status": "Executed successfully"
}
]
}
Congratulations 🥳 you just found the get transaction changes 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.