Skip to main content

How to get coin activities of type

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 of type

In order to get coin activities of type, Blocklens provides you a getCoinActivitiesByType endpoint to do so.

Here you'll need a parameter: coin_type.

Once you've obtained the coin_type, 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.getCoinActivitiesByType("0x1::aptos_coin::AptosCoin");
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.eyJpZCI6MjkwODMzNjQ3MDAwMDAwLCJwYWdlIjoxLCJjb2luX3R5cGUiOiIweDE6OmFwdG9zX2NvaW46OkFwdG9zQ29pbiIsImlhdCI6MTY5NzA1ODUxNH0.m8DviletHI5yriRfjV-2vF_9CXCaaYm_BDYLPtHT9aA",
"total_items": 1,
"data": [
{
"activity_type": "0x1::coin::DepositEvent",
"amount": 497487,
"block_height": 101437980,
"coin_type": "0x1::aptos_coin::AptosCoin",
"entry_function_id_str": "0xc7efb4076dbe143cbcd98cfaaa929ecfc8f299203dfff63b95ccb6bfe19850fa::router::swap_exact_input",
"event_account_address": "0x1b3e13157f930afdfc1182115663c217b9bf15c0d8f4a5e397c02426a13c93fe",
"event_creation_number": 2,
"event_index": 1,
"event_sequence_number": 38,
"id": 290834610000001,
"is_gas_fee": false,
"is_transaction_success": true,
"owner_address": "0x1b3e13157f930afdfc1182115663c217b9bf15c0d8f4a5e397c02426a13c93fe",
"timestamp": 1696884823,
"transaction_version": 290834610
}
]
}

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