0xWeb
Search
⌃K
🪙

Token Services

Token Data

Dequanto includes JSONs with >5000 popular tokens - names, addresses, chains, decimals.
import { TokensService } from '@dequanto/tokens/TokensService';
let service = new TokensService('eth');
let usdc = await service.getKnownToken('USDC');
console.log(usdc);
/* output
{
symbol: 'USDC',
name: 'USD Coin',
platform: 'eth',
address: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
decimals: 6
}
*/

ERC20 Contracts

Ready to use strongly-typed erc20 contract class.
import { TokensService } from '@dequanto/tokens/TokensService';
let service = new TokensService('eth');
let usdc = await service.erc20('USDC');
let balance: bigint = await usdc.balanceOf('0x....')

Token Price

An article regarding token prices - get-token-price-at-a-specific-block-onchain🔗

Token Swap

See TokenSwapService🔗 for details.
Paraswap is implemented as the default exchange
import { TokenSwapService } from '@dequanto/tokens/TokenSwapService'
import { EthWeb3Client } from '@dequanto/clients/EthWeb3Client';
let client = new EthWeb3Client();
let exchange = new TokenSwapService(client);
let account = { key: '' }
let tx = await exchange.swap(account, {
from: 'USDC',
to: 'WETH',
amount: 1000
});
let receipt = await tx.wait();

Token Transfer

Transfer tokens by a specific amount, all or with the remainder.
See TokenTransferService🔗 for details.
import { TokenTransferService} from '@dequanto/tokens/TokenTransferService'
import { EthWeb3Client } from '@dequanto/clients/EthWeb3Client';
let client = new EthWeb3Client();
let service = new TokenTransferService(client);
let account = { key: '' }
let tx = await service.transferAll(account, '0x...', 'USDC');
let receipt = await tx.wait();