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)

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)

2.3 Transfer Token

Transfers native or ERC20 tokens.

Function Name

transfer_token
  • Arguments

    to (str): The address to transfer the token to (CronosIds with the `.cro` suffix are supported, e.g. `xyz.cro`)
    amount (int): The amount of the token to transfer.
    contract_address (str): Optional. The contract address of the token to transfer.
  • Example Code

    from crypto_com_developer_platform_client import Token
    
    tx = Token.transfer_token('example-recipient', example-number)
    print(tx)

2.4 Wrap Token

Wrap tokens.

Function Name

wrap_token
  • Arguments

    amount (float): The amount of the token to wrap.
  • Example Code

    from crypto_com_developer_platform_client import Token
    
    tx = Token.wrap_token(example-amount)
    print(tx)

2.5 Swap Token

Swap tokens.

Function Name

swap_token
  • Arguments

    from_contract_address (str): The token to swap from.
    to_contract_address (str): The token to swap to.
    amount (int): The amount of the token to swap.
  • Example Code

    from crypto_com_developer_platform_client import Token
    
    tx = Token.swap_token('example-from', 'example-to', 'example-amount')
    print(tx)

2.6 Get ERC721 Token Balance

Fetches the ERC721 token balance for a wallet and contract.

Function Name

get_erc721_balance
  • Arguments

    wallet_address (str): The address to get the balance for.
    contract_address (str): The ERC721 contract address.
  • Example Code

    from crypto_com_developer_platform_client import Token
    
    balance = Token.get_erc721_balance('example-wallet','example-contract')
    print(balance)

2.7 Get ERC721 Token Owner

Fetches the owner of a specific ERC721 token.

Function Name

get_token_owner
  • Arguments

    contract_address (str): The ERC721 contract address.
    token_id (str): The token ID.
  • Example Code

    from crypto_com_developer_platform_client import Token
    
    owner = Token.get_token_owner('example-contract', 'example-token-id')
    print(owner)

2.8 Get Token URI

Fetches the token URI of a specific ERC721 token.

Function Name

get_token_uri
  • Arguments

    contract_address (str): The ERC721 contract address.
    token_id (str): The token ID.
  • Example Code

    from crypto_com_developer_platform_client import Token
    
    uri = Token.get_token_uri('example-contract', 'example-token-id')
    print(uri)

2.9 Get ERC721 Metadata

Fetches metadata for a specific ERC721 contract.

Function Name

get_erc721_metadata
  • Arguments

    contract_address (str): The ERC721 contract address.
  • Example Code

    from crypto_com_developer_platform_client import Token
    
    metadata = Token.get_erc721_metadata('example-contract')
    print(metadata)

2.10 Get ERC20 Metadata

Fetches metadata for a specific ERC20 contract.

Function Name

get_erc20_metadata
  • Arguments

    contract_address (str): The ERC20 contract address.
  • Example Code

    from crypto_com_developer_platform_client import Token
    
    metadata = Token.get_erc20_metadata('example-contract')
    print(metadata)

Last updated

Was this helpful?