Skip to main content

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

In order to get events from version to version, Blocklens provides you a getEventsFromVersionToVersion 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.getEventsFromVersionToVersion({"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:

{
"page": 1,
"limit": 20,
"cursor": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MjcxODkxOTgwMDAwMDAwLCJwYWdlIjoxLCJmcm9tX3ZlcnNpb24iOjI3MTg5MTk4MCwidG9fdmVyc2lvbiI6MjcxODkxOTgxLCJpYXQiOjE2OTcwNTk0MTd9.VlM9vFeqbJoZ7aX51M253aIeudDRiDezWfFbIAqUtF8",
"total_items": 1,
"data": [
{
"block_height": 95397542,
"timestamp": 1695436683,
"transaction_version": 271891981,
"transaction_hash": "0x361a18bc1ee54c2f29067a40f0c33457347cfe95166ba89d078f0157b637285c",
"transaction_type": "user_transaction",
"creation_number": 5,
"account_address": "0x7d7e436f0b2aafde60774efb26ccc432cf881b677aca7faaf2a01879bd19fb8",
"sequence_number": 3349968,
"type": "0x7d7e436f0b2aafde60774efb26ccc432cf881b677aca7faaf2a01879bd19fb8::events::AggregatorOpenRoundEvent",
"event_index": 2,
"amount": -9223372036854776000,
"module_name": "null",
"struct_name": "null",
"data": "{\"aggregator_address\":\"0x5af65afeeab555f8b742ce7fc2c539a5cb6a6fb2a6e6d96bc1b075fb28067808\",\"job_keys\":[\"0xbdc778983f92375edc7374a599d152ca88a3586b9878bb2cc428c286dc3db2d3\",\"0x7f7855e3b4233cf75f969654a1b3719eccdf0f5da99d28da2cc7a71a5551dea7\",\"0x85be04ef283a92d5e59dea6ee4d436f551c06e7e0714da10587d52a83d6c2d8c\",\"0x3ed7a14246f4fd0b542f4d12bdc96bdf80d84d5332f377e47b827272ef7c8e48\",\"0x26f82cb35a5fa9e4e836e9e76399056314f30070580e6f478521db9d00d82cb\",\"0x9fc5d25f68e6a6740ffae2778b918926df73e8d296ea81ba36be5e5a0c6641",
"block_hash": "0x7114cc9d55eb93377a5f8a1f375807a6ebec3f65826217ddb02a71af777e71e7",
"success": true,
"vm_status": "Executed successfully"
}
]
}

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