debeem-wallet

The class constructor needs to pass in a chainId. Before you create an instance, you can get the currently supported chainId list in the following way:

//	query currently supported chain/network
const supportedChains : Array<number> = new TokenService( 1 ).supportedChains();

// should return a supported chain list, for example:
[ 1, 10, 56, 100, 137, 250, 324, 8217, 8453, 42161, 43114, 1313161554 ]

// create an instance based on the specified chain/network
const tokenService = new TokenService( {chainId} );

Hierarchy (view full)

Implements

Constructors

Accessors

  • get nativeTokenAddress(): string
  • get the contract address of the native token

    //	should always return:
    '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee'

    Returns string

  • get supportedChainMap(): RpcSupportedChainMap
  • get supported chain map

    const supportedChainMap : RpcSupportedChainMap = new TokenService( 1 ).getSupportedChainMap();
    // should return:
    {
    1 : "mainnet", // Ethereum mainnet
    42161 : "arb1", // Arbitrum One
    1313161554 : "aurora", // Aurora Mainnet
    43114 : "avax", // Avalanche C-Chain, token : AVAX
    8453 : "base", // Base
    56 : "bnb", // BNB Smart Chain Mainnet
    324 : "zksync", // zkSync Era Mainnet
    250 : "ftm", // Fantom Opera
    100 : "gno", // Gnosis
    8217 : "cypress", // Klaytn Mainnet Cypress
    10 : "oeth", // OP Mainnet
    137 : "matic", // Polygon Mainnet
    }

    Returns RpcSupportedChainMap

  • get supportedNetworks(): string[]
  • get supported chain/network short name list

    Returns string[]

Basic Methods

Extended Methods

  • check if the token exists by contractAddress

    Parameters

    • contractAddress: string

      {string} contract address

    Returns Promise<boolean>

  • get token item

    Parameters

    • contractAddress: string

      {string} contract address

    Returns Promise<null | OneInchTokenItem>

    Example

    //
    // switch chain/network to BNB Smart Chain Mainnet
    //
    const currentChainId = 56;

    const contractAddress : string = new TokenService( currentChainId ).nativeTokenAddress;
    const item = await new TokenService( currentChainId ).getItem( contractAddress );
    // should return:
    {
    chainId: 56,
    symbol: 'BNB',
    name: 'BNB',
    address: '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee',
    decimals: 18,
    logoURI: 'https://tokens.1inch.io/0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c.png',
    providers: [ '1inch', 'Curve Token List' ],
    eip2612: false,
    tags: [ 'native' ]
    }
  • get the decimals value of a token

    Parameters

    • contractAddress: string

      {string} contract address

    Returns Promise<number>

    Example

    //
    // switch chain/network to Ethereum Mainnet
    //
    const currentChainId = 1;

    // contract address of ETH
    const contractAddress : string = new TokenService( currentChainId ).nativeTokenAddress;
    const decimals = await new TokenService( currentChainId ).getItemDecimals( contractAddress );
    // should return:
    18

    Example

    //
    // switch chain/network to Ethereum Mainnet
    //
    const currentChainId = 1;

    // contract address of Tether USD
    const contractAddress : string = `0xdac17f958d2ee523a2206206994597c13d831ec7`;
    const decimals = await new TokenService( currentChainId ).getItemDecimals( contractAddress );
    // should return:
    6
  • get the logo url of a token

    Parameters

    • contractAddress: string

      {string} contract address

    Returns Promise<null | OneInchTokenLogoItem>

    Example

    //
    // switch chain/network to Ethereum Mainnet
    //
    const currentChainId = 1;

    const contractAddress : string = new TokenService( currentChainId ).nativeTokenAddress;
    const logoUrl = await new TokenService( currentChainId ).getItemLogo( contractAddress );
    // should return:
    {
    oneInch : "https://tokens.1inch.io/0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee.png",
    metaBeem : "https://tokens.metabeem.io/0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee.png",
    base64 : "data:image/png;base64,UklGRlYLAABXRUJQVlA4TEkLAAAv/8A/EC8FoW0kQZKnD8Dzh3p/Mx0aENpIkiS5ZjEcf5hvTYWDt...",
    }
  • check if the input value is the contract address of the native token

    Parameters

    • contractAddress: string

      {string}

    Returns boolean