Skip to main content

How to get erc20 token transfer

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 ERC20 token transfer

In order to get erc20 token transfer, Blocklens provides you a getErc20Transfers 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.ETH_MAINNET.getErc20Transfers();
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:

{
"cursor": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MTgyODMyODYwMTA0MDAwMzAwLCJwYWdlIjoxLCJpYXQiOjE2OTcwNjM3MDN9.Hga35u1FflOHncjzj9I4HNkZvifdML_ahBBFsCsIkyU",
"page": 1,
"limit": 20,
"total_items": 1,
"data": [
{
"token_name": "Tether USD",
"token_symbol": "USDT",
"token_decimals": 6,
"contract_address": "0xdAC17F958D2ee523a2206206994597C13D831ec7",
"transaction_hash": "0x6e89c31b249429536434b8633c3f9e2ed10a39f36c17d6a0b32dd863118c0c0d",
"transaction_index": 140,
"log_index": 380,
"block_hash": "0x9dce9c505115b31b6afcae07d5b3ddc2bdf4ca89469682cc79cbc64fe12bce7b",
"block_number": 18283286,
"from_wallet": "0xb2B7e97453B29BCA5489E9b341F16c2bA9B0c1F3",
"to_wallet": "0xF7CCf5eB0079Fa7f9ef164B2B475889534d83563",
"value": "30488286",
"value_decimal": "30.488286",
"timestamp": 1696496531
}
]
}

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