How to get transaction signatures from block to block
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 signatures from block to block
In order to get transaction signatures from block to block, Blocklens provides you a getTransactionSignaturesFromBlockToBlock endpoint to do so.
Here you'll need parameters: from_block
, to_block
.
Once you've obtained all the from_block
, to_block
, 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.getTransactionSignaturesFromBlockToBlock({"from_block":18246150,"to_block":18246151});
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": "string",
"page": 0,
"limit": 0,
"total_items": 0,
"data": [
{
"block_height": 1,
"transaction_version": 1,
"transaction_hash": "0xbf3d139d0bbe68f1db6d393b135c2ed12ab5ec1635f08b26994180d1e6434dd1",
"transaction_type": "block_metadata_transaction",
"type": "ed25519_signature",
"public_key": "key",
"signature": "0x5f93f5019c612b6cb59d1649b7f363f108ab37b3ebfdc76ed59c841b1451e3f1b22d502f2c4e597b1bbd39396ab9e42e0dc68463971465c3c45bf880c08f5007",
"timestamp": 1
}
]
}
]
Congratulations 🥳 you just found the get transaction signatures from block to block 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.