Skip to main content

How to get transactions 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 transactions from version to version

In order to get transactions from version to version, Blocklens provides you a getTransactionsFromVersionToVersion 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.getTransactionsFromVersionToVersion({"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.eyJpZCI6MjcxODkxOTgwLCJwYWdlIjoxLCJmcm9tX3ZlcnNpb24iOjI3MTg5MTk4MCwidG9fdmVyc2lvbiI6MjcxODkxOTgxLCJpYXQiOjE2OTcwNjEyOTV9.xIGY-hgxHenrd6VH21-WELzz5sgQxBC4ylj_8z-S3pI",
"page": 1,
"limit": 20,
"total_items": 1,
"data": [
{
"block_height": 95397542,
"timestamp": 1695436683,
"version": 271891981,
"type": "user_transaction",
"hash": "0x361a18bc1ee54c2f29067a40f0c33457347cfe95166ba89d078f0157b637285c",
"sender": "0xca62eccbbdb22b5de18165d0bdf2d7127569b91498f0a7f6944028793cef8137",
"receiver": "null",
"function": "crank_pop_action::run",
"amount": 0,
"gas_used": 36,
"accumulator_root_hash": "0xe4151ccefb702bab6b60a783db53103564725960adbdb7498e07bbbfd1c2cc53",
"block_hash": "0x7114cc9d55eb93377a5f8a1f375807a6ebec3f65826217ddb02a71af777e71e7",
"epoch": -2147483648,
"event_root_hash": "0xcc8d2d3b04edcce222aa662365c8c79ef9f2a4b321954ad938c6fee0ead8f27e",
"expiration_time": "2023-09-23 03:06:19",
"gas_unit_price": 150,
"max_gas_limit": 0,
"proposer": "null",
"round": -2147483648,
"sequence_number": 3425933,
"signature": "{\"public_key\":\"0x4350d74f7ad7d92de20aa3adbf91edaecd08cdfce75fe3e5add4d3e79bcfff8c\",\"signature\":\"0x4ba65e044d8c239505a9cb4a7440bdbee2dab1d95ca675736d565788a014f3f0edf82a4b97dcf01fb5f46e4baf87e1d0d7dda2ee6056430171d95bc279d57d00\",\"type\":\"ed25519_signature\"}",
"smart_contract": "0x7d7e436f0b2aafde60774efb26ccc432cf881b677aca7faaf2a01879bd19fb8",
"state_change_hash": "0x2716b21c40647344e10a1515a12c27cde9be361aed5eff79b1a10cfc20df22d5",
"success": true,
"vm_status": "Executed successfully"
}
]
}

Congratulations 🥳 you just found the get transactions 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.