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.ETH_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.eyJpZCI6MTgyNDYxNTAwMDAxMDcsInBhZ2UiOjEsImZyb21fdGltZSI6IjE2OTYwNDgyNTkiLCJ0b190aW1lIjoiMTY5NjA0ODI2MCIsImlhdCI6MTY5NzA2NDc3Mn0.jG6fXCMY7JHmACnaXuo7wcNp4cQBsYuYNv-oCSox9Pw",
"page": 1,
"limit": 20,
"total_items": 1,
"data": [
{
"hash": "0x04262bf674066a4276479a77c289e249e5c404e5d18a1d5d818d78b4059072a5",
"from": "0x95222290DD7278Aa3Ddd389Cc1E1d165CC4BAfe5",
"to": "0x4675C7e5BaAFBFFbca748158bEcBA61ef3b0a263",
"receipt_contract_address": null,
"receipt_cumulative_gas_used": "23291896",
"receipt_gas_used": "21000",
"input": "0x",
"value": "38349768134159292",
"nonce": "411782",
"gas_price": "6374499230",
"gas": "32000",
"timestamp": 1696048259,
"block_hash": "0x0517e1369f5159852973c47dc335d28b67ccffb238333542f880abc3fe3ab505",
"block_number": 18246150,
"tx_index": 126,
"status": true,
"effective_gas_price": "6374499230",
"logs_bloom": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
}
]
}
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.