How to get transaction payloads
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
In order to get transaction payloads, Blocklens provides you a getTransactionPayloads endpoint to do so.
import Blocklens from "blocklens-sdk";
const blocklens = new Blocklens();
blocklens.init({ apiKey: "YOUR_API_KEY" });
const runApis = async () => {
const response = await blocklens.APTOS_MAINNET.getTransactionPayloads();
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.eyJpZCI6MjgzMzMyMTk0LCJwYWdlIjoxLCJpYXQiOjE2OTcwNjEwODh9.YFHGJGj_9uHVfiAj8GIN_6Namy5B6r4-UGrvlXzmIVk",
"page": 1,
"limit": 20,
"total_items": 1,
"data": [
{
"block_height": 98983173,
"timestamp": 1696299683,
"transaction_version": 283332247,
"transaction_hash": "0xda8bb6f92dfdc93bca750bfe79807a0020457981d9e3cfd7cf9d63e229b9b9d5",
"transaction_type": "user_transaction",
"function": "0x7e783b349d3e89cf5931af376ebeadbfab855b3fa239b7ada8f5a92fbea6b387::pyth::update_price_feeds_with_funder",
"type_arguments": "[]",
"arguments": "[[\"0x504e41550100000003b801000000030d004b70f2568e71eb91a4c81ab621786b20da1e00fce16b67652adb0642c4dd957d5d365b81365b319ae694d119fe0983a0967a9e62371b2981f4b95545e39174ce01026ca213b39a13cbf06c0b095e1f8c9570e9092a4bd64d55bb91c00eeebeb6c1382ce3c09a2f407733742529c9d538549e599bf52f53adc2b0feadebc8197bf9c6010396a4990373169013f850f4cc93b80840479eae218c1da4373c0b3c6e010a6b4e3a818f8765becc2e6cd56a393ed55828f4f67627cc1004c6b5a5a484fe942eda0006fbb43add5ae3317900f1d41aa9b587e1b3ab63e10832b9c8b2997d8392dc0ec33a13d6a0ca093",
"block_hash": "0x274fa233485a9c04dc397164107c037e1d4a3dca8340b2eb14be94d195f664a4",
"success": true,
"type": "entry_function_payload",
"vm_status": "Executed successfully"
}
]
}
Congratulations 🥳 you just found the get transaction payloads 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.