How to get transaction changes from time to time
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 time to time
In order to get transaction changes from time to time, Blocklens provides you a getTransactionChangesFromTimeToTime endpoint to do so.
Here you'll need parameters: from_time
, to_time
.
Once you've obtained all the from_time
, to_time
, 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.getTransactionChangesFromTimeToTime({"from_time":"1696048259","to_time":"1696048260"});
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.eyJpZCI6Mjc5OTgyMjcwMDAwMDAzLCJwYWdlIjoxLCJmcm9tX3RpbWUiOiIxNjk2MDQ4MjU5IiwidG9fdGltZSI6IjE2OTYwNDgyNTkiLCJpYXQiOjE2OTcwNjA0ODR9.BFKhFZsqz4mg18L0fa9UeATUBLPAorDCkpEX_vGuSmM",
"page": 1,
"limit": 20,
"total_items": 1,
"data": [
{
"block_height": 97922847,
"timestamp": 1696048259,
"transaction_version": 279982271,
"transaction_type": "user_transaction",
"transaction_hash": "0xee852ea50aaaa3a05faa59544cf132ce9537cb107e7212748eb3a8bd003ac60b",
"type": "write_table_item",
"address": "null",
"state_key_hash": "0xc322dfcd449816cf5b7e212d7f359b5dc13ef190658a0e57b2081574fa4a2b7f",
"block_hash": "0x5cbc98d7ca9a0493bf14606b1adfc4f2e60b995dddafb372b93ba1b330dfa73f",
"change_index": "11",
"data": "null",
"data_type": "null",
"handle": "0xd1321c17eebcaceee2d54d5f6ea0f78dae846689935ef53d1f0c3cff9e2d6c49",
"key": "0x20ff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace",
"resource": "null",
"success": true,
"value": "0x83a417650000000083a417650000000020ff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace00f164c9e526000000e9b53c040000000001080000000000000080a417650000000000f05fbfe2260000005122c3030000000001080000000000000080a4176500000000",
"vm_status": "Executed successfully"
}
]
}
Congratulations 🥳 you just found the get transaction changes from time to time 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.