Skip to main content

How to get erc20 token mints by transaction hash

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 mints by transaction hash

In order to get erc20 token mints by transaction hash, Blocklens provides you a getErc20MintsByTransaction endpoint to do so.

Here you'll need a parameter: transaction_hash.

Once you've obtained the transaction_hash, 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.ETH_MAINNET.getErc20MintsByTransaction("0x12259c8b5a0f51320bb1b64dfb2b1b61e24aaa127318b0cf92d209525f0d5447");
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.eyJpZCI6NTUzNDk2MzA2ODAwNjYsInBhZ2UiOjEsInRyYW5zYWN0aW9uIjoiMHgxMjI1OWM4YjVhMGY1MTMyMGJiMWI2NGRmYjJiMWI2MWUyNGFhYTEyNzMxOGIwY2Y5MmQyMDk1MjVmMGQ1NDQ3IiwiaWF0IjoxNjk3NjAzMTgyfQ.ulOnhUJWtk2rOSAdbWkoi02pPANT7cXJIC81FIOAw44",
"page": 1,
"limit": 1,
"total_items": 1,
"data": [
{
"token_name": "Robotina token",
"token_symbol": "ROX",
"token_decimals": 18,
"contract_address": "0x574F84108a98c575794F75483d801d1d5DC861a5",
"transaction_hash": "0x12259c8b5a0f51320bb1b64dfb2b1b61e24aaa127318b0cf92d209525f0d5447",
"transaction_index": 68,
"log_index": 66,
"block_hash": "0xb7bb25a4f22b1cef36c0a90d2358ec386cf4bc5ec5bdb1ac63d8c32543a9d140",
"block_number": 5534963,
"to_wallet": "0x940b249c5154540bad93E7De0BaABd852bf49F13",
"value": "20287507752809394514200",
"value_decimal": "20287.5077528093945142",
"timestamp": 1525134310
}
]
}

Congratulations 🥳 you just found the get erc20 token mints by transaction hash 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.