For the complete documentation index, see llms.txt. This page is also available as Markdown.

Token Module

Token module handles operations related to native tokens, ERC20 tokens, and NFTs.

To learn more about how to use the AI Agent SDK to interact with the token module, please visit AI Agent SDK Token Interaction.

2.1 Get Native Token Balance

Fetches the native token balance of a specific wallet address.

Function Name

get_native_balance
  • Arguments

    address (str): The address to get the balance for (CronosIds with the `.cro` suffix are supported, e.g. `xyz.cro`)
  • Example Code

    from crypto_com_developer_platform_client import Token
    
    balance = Token.get_native_balance('example-wallet')
    print(balance)
  • Returns

    The balance of the native token.
  • Errors

    ValueError: If the Token class is not initialized with a Client instance.
  • Example Return

    {'status': 'Success', 'data': {'balance': 'example-balance'}}

Function Name

getNativeTokenBalance
  • Arguments

    {string} address: The wallet address (or CronosId `.cro`) to check.
  • Example Code

    import { Token } from '@crypto.com/developer-platform-client';
    
    try {
      const balance = await Token.getNativeTokenBalance('example-wallet');
      console.log(balance);
    }
    catch(err) {
      console.log(err);
    }
  • Returns

    {Promise<ApiResponse<Balance>>}: A promise that resolves to the native token balance.
  • Errors

    {Error}: Throws an error if the request fails.
  • Example Return

    { status: 'Success', data: { balance: 'example-balance' } }

2.2 Get ERC20 Token Balance

Fetches the ERC20 token balance of a wallet for a given ERC20 contract.

Function Name

get_erc20_balance
  • Arguments

    wallet_address (str): The address to get the balance for (CronosIds with the `.cro` suffix are supported, e.g. `xyz.cro`)
    contract_address (str): The contract address to get the balance for.
    block_height (str): The block height to get the balance for.
  • Example Code

    from crypto_com_developer_platform_client import Token
    
    balance = Token.get_erc20_balance('example-wallet', 'example-contract', 'latest')
    print(balance)
  • Returns

    The balance of the ERC20 token.
  • Errors

    ValueError: If the Token class is not initialized with a Client instance.
  • Example Return

    {'status': 'Success', 'data': {'balance': 'example-balance'}}

Function Name

getERC20TokenBalance
  • Arguments

    {string} address: The wallet address (or CronosId `.cro`) to check.
    {string} contractAddress: The ERC20 contract address.
    {string} [blockHeight='latest']: Optional block height (default 'latest').
  • Example Code

    import { Token } from '@crypto.com/developer-platform-client';
    
    try {
      const balance = await Token.getERC20TokenBalance('example-wallet', 'example-contract');
      console.log(balance);
    }
    catch(err) {
      console.log(err);
    }
  • Returns

    {Promise<ApiResponse<TokenBalance>>}: A promise that resolves to the ERC20 token balance.
  • Errors

    {Error}: Throws an error if the request fails.
  • Example Return

    { status: 'Success', data: { balance: 'example-balance' } }

2.3 Transfer Token

Transfers native or ERC20 tokens.

Function Name

  • Arguments

  • Example Code

  • Returns

  • Errors

  • Example Return

Function Name

  • Arguments

  • Example Code

  • Returns

  • Errors

  • Example Return

2.4 Wrap Token

Wrap tokens.

Function Name

  • Arguments

  • Example Code

  • Returns

  • Errors

  • Example Return

Function Name

  • Arguments

  • Example Code

  • Returns

  • Errors

  • Example Return

2.5 Swap Token

Swap tokens.

Function Name

  • Arguments

  • Example Code

  • Returns

  • Errors

  • Example Return

Function Name

  • Arguments

  • Example Code

  • Returns

  • Errors

  • Example Return

2.6 Get ERC721 Token Balance

Fetches the ERC721 token balance for a wallet and contract.

Function Name

  • Arguments

  • Example Code

  • Returns

  • Errors

  • Example Return

Function Name

  • Arguments

  • Example Code

  • Returns

  • Errors

  • Example Return

2.7 Get ERC721 Token Owner

Fetches the owner of a specific ERC721 token.

Function Name

  • Arguments

  • Example Code

  • Returns

  • Errors

  • Example Return

Function Name

  • Arguments

  • Example Code

  • Returns

  • Errors

  • Example Return

2.8 Get Token URI

Fetches the token URI of a specific ERC721 token.

Function Name

  • Arguments

  • Example Code

  • Returns

  • Errors

  • Example Return

Function Name

  • Arguments

  • Example Code

  • Returns

  • Errors

  • Example Return

2.9 Get ERC721 Metadata

Fetches metadata for a specific ERC721 contract.

Function Name

  • Arguments

  • Example Code

  • Returns

  • Errors

  • Example Return

Function Name

  • Arguments

  • Example Code

  • Returns

  • Errors

  • Example Return

2.10 Get ERC20 Metadata

Fetches metadata for a specific ERC20 contract.

Function Name

  • Arguments

  • Example Code

  • Returns

  • Errors

  • Example Return

Function Name

  • Arguments

  • Example Code

  • Returns

  • Errors

  • Example Return

Last updated

Was this helpful?