Skip to main content

How to get coins

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 coins

In order to get coins, Blocklens provides you a getCoins 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.getCoins();
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.eyJpZCI6IjB4Y2E3YzBhNzQ1NjNiODUwZTJmYTY3ZjI3OTMxZDY0NGZmZTdhMzMwYjBkYjU3ZjdiMmI0M2Y1MTkxZThkMmUyYzo6Y29pbjo6VCIsInBhZ2UiOjEsImlhdCI6MTY5NzA1ODc1OX0._zLaCwGmxaaX0KV7eaVHclHQwaKozP_S511pnfrgYg0",
"total_items": 1,
"data": [
{
"coin_type": "0xfbab9fb68bd2103925317b6a540baa20087b1e7a7a4eb90badee04abb6b5a16f::blt::Blt",
"coin_type_hash": "5b80c81a6efc345224c452e164ca52522d272da50c531f1315f5ba2b8fac15f5",
"creator_address": "0xfbab9fb68bd2103925317b6a540baa20087b1e7a7a4eb90badee04abb6b5a16f",
"decimals": 8,
"id": "0xfbab9fb68bd2103925317b6a540baa20087b1e7a7a4eb90badee04abb6b5a16f::blt::Blt",
"name": "Blocto Token",
"supply_aggregator_table_handle": "null",
"supply_aggregator_table_key": "null",
"symbol": "BLT",
"transaction_created_timestamp": 1695197394,
"transaction_version_created": "268952473"
}
]
}

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