Links

erc20_metadata

Get the metadata (name, symbol, decimals) of the given erc20 contract address.
name ,symbol and decimals are optional methods in the ERC-20 token standard. Therefore, not all contracts will respond correctly to calls requesting this information. While the incorrectness or absence of name and symbolcan be an inconvenience, having the correct decimalsis crucial in displaying token balances or converting user inputs accurately when communicating with the contract.
Supported on Ethereum, BNB Chain, Optimism, and Arbitrum.

Parameters

Object - An object with the following fields (required):
  • contractAddress(hex string, required) - the contract address for erc20 token.

Returns

Object - An object with the following fields:
  • id(integer number) - json-rpc id.
  • jsonrpc(string) - json-rpc version.
  • result(object) - an object with the following fields:
    • name(string) - the name of the token.
    • symbol(string) - the symbol of the token.
    • decimals(integer number) - the number of decimals of the token.

Example

Request

curl
TypeScript
curl https://api.blockvision.org/v2/your-api-key \
-X POST \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "erc20_metadata",
"params": {
"contractAddress": "0xdAC17F958D2ee523a2206206994597C13D831ec7"
},
"id": 1
}'
import { BlockVisionProvider, BvNetwork } from 'blockvision.js'
​
// Optional parameters, but default to eth-mainnet and default api-key.
const bv = new BlockVisionProvider(BvNetwork.ETH_MAINNET)
​
// Access the BlockVision FT API
bv.getERC20Metadata({
contractAddress: '0x8C6bf16C273636523C29Db7DB04396143770F6A0'
}).then(console.log)

Response

{
"jsonrpc": "2.0",
"id": 1,
"result": {
"symbol": "Test",
"decimals": 18,
"name": "Demo"
}
}