Skip to main content

How to get transaction payloads 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 payloads from time to time

In order to get transaction payloads from time to time, Blocklens provides you a getTransactionPayloadFromTimeToTime 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.getTransactionPayloadFromTimeToTime({"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.eyJpZCI6Mjc5OTgyMjYyLCJwYWdlIjoxLCJmcm9tX3RpbWUiOiIxNjk2MDQ4MjU5IiwidG9fdGltZSI6IjE2OTYwNDgyNTkiLCJpYXQiOjE2OTcwNjA5MDd9.o8i0dJ6WgiEOg1klpojrxNTRmpBADaIjcDfPvpi2JTU",
"page": 1,
"limit": 20,
"total_items": 1,
"data": [
{
"block_height": 97922847,
"timestamp": 1696048259,
"transaction_version": 279982271,
"transaction_hash": "0xee852ea50aaaa3a05faa59544cf132ce9537cb107e7212748eb3a8bd003ac60b",
"transaction_type": "user_transaction",
"function": "0x7e783b349d3e89cf5931af376ebeadbfab855b3fa239b7ada8f5a92fbea6b387::pyth::update_price_feeds_with_funder",
"type_arguments": "[]",
"arguments": "[[\"0x504e41550100000003b801000000030d00ff76c531c904a741974edd1be701e8b2b2b9f88a642826cb510d1844d4044c1640dc20158a65a30e92784c11727ed5183d2a20ae19badde1766a17ba91fd0f4a000140d57043311d4ea9f8c4e802d305fe41dfa214e650dae922f9645ddceece28b90bd05fbab48bacbe5163a0ae4c3606defdb8189508e07b375b04c4f3fdebcb240002415eb01f6867e4962d04c3f35703df88871d7faa15fb538c1e390b36b42736c347b18ff8a318dc839de25e533c513a413d6a3d54377fb0447be83811a28a3aad00033879f6ff49598aefc00ce5336adede2947b5ee5488b33466fa62f022f27e904d66b712420f544",
"block_hash": "0x5cbc98d7ca9a0493bf14606b1adfc4f2e60b995dddafb372b93ba1b330dfa73f",
"success": true,
"type": "entry_function_payload",
"vm_status": "Executed successfully"
}
]
}

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