Skip to main content

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

In order to get coin activities from time to time, Blocklens provides you a getCoinActivitiesFromTimeToTime 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.getCoinActivitiesFromTimeToTime({"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.eyJpZCI6Mjc5OTgyMjYxOTk5OTk5LCJwYWdlIjoxLCJmcm9tX3RpbWUiOiIxNjk2MDQ4MjU5IiwidG9fdGltZSI6IjE2OTYwNDgyNjAiLCJpYXQiOjE2OTcwNTg1OTB9.5Z1bK0c-S2KFbe6fgeruUmMsy2Qq1Zo0uCKz9wCzgtE",
"total_items": 1,
"data": [
{
"activity_type": "0x1::coin::DepositEvent",
"amount": 7,
"block_height": 97922851,
"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": 6479337,
"id": 279982281000001,
"is_gas_fee": false,
"is_transaction_success": true,
"owner_address": "0x7e783b349d3e89cf5931af376ebeadbfab855b3fa239b7ada8f5a92fbea6b387",
"timestamp": 1696048260,
"transaction_version": 279982281
}
]
}

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