Find a token contract address
Learn how to find the contract address for an asset on Balanced.
Balanced supports a variety of assets on ICON and other connected chains. To interact with them via the smart contracts, you’ll need to know their contract addresses.
Find the address for tokens on ICON
Use this script to fetch contract addresses for supported tokens on ICON.
- Call the
getNonce
method on the DEX contract to get the number of pools available. - Iterate from 0 to nonce and call the
getPoolsStat
method on the DEX contract to get the pool details.
You’ll receive a JSON object like this in response:
{
base: '0x0',
base_decimals: '0x12',
base_token: 'cx2609b924e33ef00b648a409245c7ea394c467824',
min_quote: '0x8ac7230489e80000',
name: 'sICX/ICX',
price: '0x11e9e1727d1d3ec4',
quote: '0xc84259d10e02b80a1a17',
quote_decimals: '0x12',
quote_token: null,
total_supply: '0xc84259d10e02b80a1a17',
id: '0x1'
},
base_token
and quote_token
are the contract addresses of the tokens in the pool. quote_token
is null
here because ICX is the native coin of the ICON blockchain.
If name
is null
, call the symbol
method on the token contract to get the token name.
Find the address for tokens from other blockchains
Use this script to fetch contract addresses for all supported tokens from external chains.
You can call the getAssets
method on the Asset Manager contract to receive a JSON object like this in response:
[
{
"0x100.icon/hx0000000000000000000000000000000000000000": "cxe2da9f10bc6e2754347bde2ef73379bd398fd9f3",
"0x2105.base/0x0000000000000000000000000000000000000000": "cx288d13e1b63563459a2ac6179f237711f6851cb5",
"0x2105.base/0x04C0599Ae5A44757c0af6F9eC3b93da8976c150A": "cxce7b23917ddf57656010decd6017fe5016de681b",
"0x2105.base/0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913": "cx22319ac7f412f53eabe3c9827acf5e27e9c6a95f",
"0x2105.base/0xc1CBa3fCea344f92D9239c08C0568f6F2F0ee452": "cxb940dbfbc45c92f3a0cde464c4331102e7a84da8",
...
Each key/value pair represents a supported asset on a specific blockchain:
- Key = the token contract address on its original chain
- Value = the token contract address on ICON
To find the name of a token, call the symbol
method on the token contract.