If you want to automatically get the metadata of some ERC20 tokens, definitely check out Chainbase API Get token metadata. You can easily retrieve the metadata for any ERC20 token with its contract address by using Chainbase API.
To better leverage the ability that Chainbase provides, you can register here for a free account and access to different APIs and data cloud.After logging into Chainbase, visit the dashboard to get an overview. Create a new project in the console and get an API key.
network_id = '1'; // See https://docs.chainbase.com/reference/supported-chains to get the id of different chains.contract_addr = '0x7d1afa7b718fb893db30a3abc0cfc608aacfebb0'; // Take Matic Token's contract address as an example.fetch(`https://api.chainbase.online/v1/token/metadata?chain_id=${network_id}&contract_address=${contract_addr}`, { method: 'GET', headers: { 'x-api-key': CHAINBASE_API_KEY, // Replace the field with your API key. 'accept': 'application/json' }}).then(response => response.json()) .then(data => console.log(data.data)) .catch(error => console.error(error));
Using axios in JavaScript. You need to install axios using npm install axios --save in the terminal first.
Copy
Ask AI
network_id = '1'; // See https://docs.chainbase.com/reference/supported-chains to get the id of different chains.contract_addr = '0x7d1afa7b718fb893db30a3abc0cfc608aacfebb0'; // Take Matic Token's contract address as an example.const axios = require('axios');const options = { url: `https://api.chainbase.online/v1/token/metadata?chain_id=${network_id}&contract_address=${contract_addr}`, method: 'GET', headers: { 'x-api-key': CHAINBASE_API_KEY, // Replace the field with your API key. 'accept': 'application/json' }};axios(options) .then(response => console.log(response.data.data)) .catch(error => console.log(error));
Chainbase API Get token metadata takes the chain id and token contract address as parameters, and returns the metadata of the ERC20 token.To get data printed, run command node <filename>.js in the terminal. In this case, the data returned looks as follows.