0xWeb
  • 0xWeb
  • πŸ’»Installation
  • πŸ—ƒοΈBlockchains
  • πŸ“¦Package Manager
    • πŸ“‚Folder structure
    • πŸš€Dequanto dependency
    • πŸŽ†Installing contracts
    • πŸ”’Versioning
  • πŸ”Wallet
    • πŸ”‘Keys notice
    • πŸ™‚Accounts
  • πŸ’»CLI
    • Commands Overview
  • πŸ—„οΈGnosis Safe
    • πŸ™†β€β™‚οΈZero Trust Wallet
  • πŸš€Dequanto
    • ℹ️Info
    • πŸ•ΈοΈRPC Client Pool
    • πŸ—οΈTx Builder
    • πŸ“€Tx Writer
    • ⛓️Blockchain Explorers
    • πŸͺ™Token Services
    • πŸ—ƒοΈIndexer
    • ✨Utilities
  • ⛑️Hardhat
    • ℹ️Info
    • ⬇️Installation
    • 🧩Compile
    • πŸ’«Deploy
  • 0️Openzeppelin
    • Openzeppelin contracts
Powered by GitBook
On this page
  • Token Data
  • ERC20 Contracts
  • Token Price
  • Token Swap
  • Token Transfer
  1. Dequanto

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

Token Swap

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.

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();
PreviousBlockchain ExplorersNextIndexer

Last updated 3 years ago

An article regarding token prices - πŸ”—

See πŸ”— for details.

is implemented as the default exchange

See πŸ”— for details.

πŸš€
πŸͺ™
get-token-price-at-a-specific-block-onchain
TokenSwapService
Paraswap
TokenTransferService