-
Notifications
You must be signed in to change notification settings - Fork 3
Description
Right now there's no way to get basic metadata about a chain's native token which means that the integrating apps have to manually cache their own values for:
- Name
- Symbol
- Decimals
- Supply
- Icon
Context
It's not a given that an integrator knows what the native token of a chain is. If they are developing something a cross-evm explorer they might want to use every chain we support, but not want to have to hard-code info for every chain.
For instance:
const results = await Promise.all(Object.values(EvmChains).map(chain => {
return client.evm.tokens.getTokens({
network: chain,
});
}));That would allow them to dynamically build a list of chains they support, and their native tokens.
There's also no way to fetch native token supply without it, so you have to hardcode them which will rarely be the true value because they're almost all moving targets:
switch(chain){
case EVMChains.Ethereum:
case EVMChains.Unichain:
return NextResponse.json({supply: 120_000_000});
case EVMChains.BSC:
return NextResponse.json({supply: 137_000_000});
case EVMChains.Polygon:
return NextResponse.json({supply: 10_540_000_000});
case EVMChains.Base:
return NextResponse.json({supply: 961_000_000_000});
case EVMChains.Avalanche:
return NextResponse.json({supply: 460_000_000});
case EVMChains.ArbitrumOne:
return NextResponse.json({supply: 10_000_000_000});
case EVMChains.Optimism:
return NextResponse.json({supply: 4_290_000_000});
case SVMChains.Solana:
return NextResponse.json({supply: 615_340_000});
case TVMChains.Tron:
return NextResponse.json({supply: 98_670_000_000});
}Possible implementation
I would remove the contract requirement from the route and let it be optional where if not specified it would return the native token information.