How to get coin activities
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
In order to get coin activities, Blocklens provides you a getCoinActivities 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.getCoinActivities();
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.eyJpZCI6MjkwODM0NDcyMDAwMDAxLCJwYWdlIjoxLCJpYXQiOjE2OTcwNTg3Mjl9.Bgj81t_ABCZJjIhKiEfxFY-L9WzJgcHIiOooWMODwFw",
"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 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.