Skip to main content

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

In order to get transactions from time to time, Blocklens provides you a getTransactionsFromTimeToTime 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.getTransactionsFromTimeToTime({"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.eyJpZCI6Mjc5OTgyMjYxLCJwYWdlIjoxLCJmcm9tX3RpbWUiOiIxNjk2MDQ4MjU5IiwidG9fdGltZSI6IjE2OTYwNDgyNTkiLCJpYXQiOjE2OTcwNjEyNjB9.mw3VFHoDlxZQ7aX4lh6OtqoN39TlBqpaa9V03K2Ns4Y",
"page": 1,
"limit": 20,
"total_items": 1,
"data": [
{
"block_height": 97922847,
"timestamp": 1696048259,
"version": 279982272,
"type": "state_checkpoint_transaction",
"hash": "0x1adfaeab579710755df94577da225f5e1bff4700d749b2cca3889663545f9885",
"sender": "null",
"receiver": "null",
"function": "null",
"amount": 0,
"gas_used": 0,
"accumulator_root_hash": "0xf1e8ce6ffb971b87e317fb15ce04515a57eee071e89b8730d5b303ccdb85e3c8",
"block_hash": "0x5cbc98d7ca9a0493bf14606b1adfc4f2e60b995dddafb372b93ba1b330dfa73f",
"epoch": -2147483648,
"event_root_hash": "0x414343554d554c41544f525f504c414345484f4c4445525f4841534800000000",
"expiration_time": "2023-09-30 04:30:59",
"gas_unit_price": 0,
"max_gas_limit": 0,
"proposer": "null",
"round": -2147483648,
"sequence_number": 0,
"signature": "null",
"smart_contract": "null",
"state_change_hash": "0xafb6e14fe47d850fd0a7395bcfb997ffacf4715e0f895cc162c218e4a7564bc6",
"success": true,
"vm_status": "Executed successfully"
}
]
}

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