How to get activities of type 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 activities of type from time to time
In order to get activities of type from time to time, Blocklens provides you a getActivitiesOfTypeFromTimeToTime endpoint to do so.
Here you'll need parameters: coin_type
, from_time
, to_time
.
Once you've obtained all the coin_type
, 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.getActivitiesOfTypeFromTimeToTime("0x1::aptos_coin::AptosCoin", {"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:
{
"page": 1,
"limit": 20,
"cursor": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6Mjc5OTgyMjYxOTk5OTk5LCJwYWdlIjoxLCJmcm9tX3RpbWUiOiIxNjk2MDQ4MjU5IiwidG9fdGltZSI6IjE2OTYwNDgyNTkiLCJjb2luX3R5cGUiOiIweDE6OmFwdG9zX2NvaW46OkFwdG9zQ29pbiIsImlhdCI6MTY5NzA1NzM1NX0.3ga2qX3puzACh07A_Oh5C0KM89jam4VZKNNInp4VTsA",
"total_items": 1,
"data": [
{
"activity_type": "0x1::coin::DepositEvent",
"amount": 7,
"block_height": 97922847,
"coin_type": "0x1::aptos_coin::AptosCoin",
"entry_function_id_str": "0x7e783b349d3e89cf5931af376ebeadbfab855b3fa239b7ada8f5a92fbea6b387::pyth::update_price_feeds_with_funder",
"event_account_address": "0x7e783b349d3e89cf5931af376ebeadbfab855b3fa239b7ada8f5a92fbea6b387",
"event_creation_number": 3,
"event_index": 1,
"event_sequence_number": 6479336,
"id": 279982271000001,
"is_gas_fee": false,
"is_transaction_success": true,
"owner_address": "0x7e783b349d3e89cf5931af376ebeadbfab855b3fa239b7ada8f5a92fbea6b387",
"timestamp": 1696048259,
"transaction_version": 279982271
}
]
}
Congratulations 🥳 you just found the get activities of type 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.