Using the v3 Dataset
Overview
The Token Name Service v3 uses The Graph for efficient data querying. The endpoint for accessing data is query.graph.tkn.xyz/subgraphs/name/tkn/v3
. Additionally, the contract data is stored on Data Chain and can be accessed through a proxy contract.
GraphQL Queries
Get Token Information by Symbol
Retrieve detailed information about a token using its symbol.
{
tokens(where: { symbol: "WETH" }) {
id
name
description
symbol
avatar
dweb
discord
decimals
addresses {
tokenAddress
chainID {
id
}
}
}
}
This query returns:
Basic token information (name, symbol, description)
Media assets (avatar, dweb)
Social links (discord)
Technical details (decimals)
Contract addresses across different chains
Get Token Information by Contract Address
Look up token information using a contract address.
query TokenByAddress {
addresses(where: {tokenAddress: "0x5979D7b546E38E414F7E9822514be443A4800529"}) {
addressID
chainID {
id
}
tokenAddress
nonEVMAddress
id
tokenID {
avatar
description
decimals
name
symbol
tokenSupply
twitter
}
}
}
This query returns:
Chain information
Token address details (EVM and non-EVM)
Associated token metadata
Social media links
Contract Queries
The contract data is stored on Data Chain and can be accessed through the proxy contract at 0x7b02d739D95758F09dDc7e44FA951cd45D97247A.
const abi = [/* See full ABI in repository */];
const contractAddress = "0x7b02d739D95758F09dDc7e44FA951cd45D97247A";
const contract = new ethers.Contract(contractAddress, abi, provider);
// Get token ID by symbol
const tokenId = await contract.getTokenIdBySymbol("WETH");
// Get token data
const tokenName = await contract.getTokenData(tokenId, "name");
const tokenDescription = await contract.getTokenData(tokenId, "description");
const tokenDecimals = await contract.getTokenData(tokenId, "decimals");
// Get token address for a specific chain
const addressInfo = await contract.getAddressBySymbolAndChain("WETH", "1"); // chainId 1 for Ethereum mainnet
Additional Resources
Last updated
Was this helpful?