Get ERC20 token data
Immutable's Blockchain Data APIs allow developers to retrieve data about fungible/ERC20 tokens on Immutable-supported chains. You can get a list of supported ERC20 tokens supported on a specific chain, or details of a specific token, via Immutable's Token API.
$IMX is the native token to Immutable's zkEVM blockchain. Immutable supports both native and ERC20 interfaces for $IMX for developer convenience. However the Blockchain Data indexer will always represent activities $IMX as native for consistency purposes, independent of what interface was called.
Request parameters
Parameter | Description | Required |
---|---|---|
chainName | String representing the name of the chain. A list of available chains can be found here. | Yes |
contractAddress | The contract address of a ERC20 contract; mandatory if you are requesting details of a specific ERC20 token | No |
List all ERC20 tokens supported by Immutable's indexer
This request returns all supported ERC20 tokens on a user specified blockchain.
- SDK
- API
import { blockchainData } from '@imtbl/sdk';
import { client } from '../lib';
export async function listTokens(): Promise<blockchainData.Types.ListTokensResult> {
return await client.listTokens({
chainName: 'imtbl-zkevm-testnet',
});
}
Using Immutable's API you can get a list of supported ERC20 tokens for an individual chain with the following Get Tokens API call; which will produce a result in the below format. You can also get details of a single ERC20 contract by using the contract address.
GET /chains/{chainName}/tokens/{address}
Example response
{
"result": {
"chain": {
"id": "eip155:13473",
"name": "imtbl-zkevm-testnet"
},
"contract_address": "string",
"root_contract_address": "string",
"symbol": "string",
"decimals": 0,
"image_url": "string",
"name": "string"
}
}
Get the details of a single token
This request returns details of a ERC20 token supported on a user specified blockchain. Use the Get Token API with the following parameters:
import { blockchainData } from '@imtbl/sdk';
import { client } from '../lib';
export async function getToken(
contractAddress: string,
): Promise<blockchainData.Types.GetTokenResult> {
return await client.getToken({
chainName: 'imtbl-zkevm-testnet',
contractAddress,
});
}