:doc:`ManagedBlockchainQuery <../../managedblockchain-query>` / Client / get_token_balance

*****************
get_token_balance
*****************



.. py:method:: ManagedBlockchainQuery.Client.get_token_balance(**kwargs)

  

  Gets the balance of a specific token, including native tokens, for a given address (wallet or contract) on the blockchain.

   

  .. note::

    

    Only the native tokens BTC and ETH, and the ERC-20, ERC-721, and ERC 1155 token standards are supported.

    

  

  See also: `AWS API Documentation <https://docs.aws.amazon.com/goto/WebAPI/managedblockchain-query-2023-05-04/GetTokenBalance>`_  


  **Request Syntax**
  ::

    response = client.get_token_balance(
        tokenIdentifier={
            'network': 'ETHEREUM_MAINNET'|'ETHEREUM_SEPOLIA_TESTNET'|'BITCOIN_MAINNET'|'BITCOIN_TESTNET',
            'contractAddress': 'string',
            'tokenId': 'string'
        },
        ownerIdentifier={
            'address': 'string'
        },
        atBlockchainInstant={
            'time': datetime(2015, 1, 1)
        }
    )
    
  :type tokenIdentifier: dict
  :param tokenIdentifier: **[REQUIRED]** 

    The container for the identifier for the token, including the unique token ID and its blockchain network.

    

  
    - **network** *(string) --* **[REQUIRED]** 

      The blockchain network of the token.

      

    
    - **contractAddress** *(string) --* 

      This is the token's contract address.

      

    
    - **tokenId** *(string) --* 

      The unique identifier of the token.

       

      .. note::

        

        For native tokens, use the 3 character abbreviation that best matches your token. For example, btc for Bitcoin, eth for Ether, etc. For all other token types you must specify the ``tokenId`` in the 64 character hexadecimal ``tokenid`` format.

        

      

    
  
  :type ownerIdentifier: dict
  :param ownerIdentifier: **[REQUIRED]** 

    The container for the identifier for the owner.

    

  
    - **address** *(string) --* **[REQUIRED]** 

      The contract or wallet address for the owner.

      

    
  
  :type atBlockchainInstant: dict
  :param atBlockchainInstant: 

    The time for when the TokenBalance is requested or the current time if a time is not provided in the request.

     

    .. note::

      

      This time will only be recorded up to the second.

      

    

  
    - **time** *(datetime) --* 

      The container of the ``Timestamp`` of the blockchain instant.

       

      .. note::

        

        This ``timestamp`` will only be recorded up to the second.

        

      

    
  
  
  :rtype: dict
  :returns: 
    
    **Response Syntax**

    
    ::

      {
          'ownerIdentifier': {
              'address': 'string'
          },
          'tokenIdentifier': {
              'network': 'ETHEREUM_MAINNET'|'ETHEREUM_SEPOLIA_TESTNET'|'BITCOIN_MAINNET'|'BITCOIN_TESTNET',
              'contractAddress': 'string',
              'tokenId': 'string'
          },
          'balance': 'string',
          'atBlockchainInstant': {
              'time': datetime(2015, 1, 1)
          },
          'lastUpdatedTime': {
              'time': datetime(2015, 1, 1)
          }
      }
      
    **Response Structure**

    

    - *(dict) --* 
      

      - **ownerIdentifier** *(dict) --* 

        The container for the owner identifier.

        
        

        - **address** *(string) --* 

          The contract or wallet address for the owner.

          
    
      

      - **tokenIdentifier** *(dict) --* 

        The container for the identifier for the token including the unique token ID and its blockchain network.

         

        .. note::

          

          Only the native tokens BTC and ETH, and the ERC-20, ERC-721, and ERC 1155 token standards are supported.

          

        
        

        - **network** *(string) --* 

          The blockchain network of the token.

          
        

        - **contractAddress** *(string) --* 

          This is the token's contract address.

          
        

        - **tokenId** *(string) --* 

          The unique identifier of the token.

           

          .. note::

            

            For native tokens, use the 3 character abbreviation that best matches your token. For example, btc for Bitcoin, eth for Ether, etc. For all other token types you must specify the ``tokenId`` in the 64 character hexadecimal ``tokenid`` format.

            

          
    
      

      - **balance** *(string) --* 

        The container for the token balance.

        
      

      - **atBlockchainInstant** *(dict) --* 

        The container for time.

        
        

        - **time** *(datetime) --* 

          The container of the ``Timestamp`` of the blockchain instant.

           

          .. note::

            

            This ``timestamp`` will only be recorded up to the second.

            

          
    
      

      - **lastUpdatedTime** *(dict) --* 

        The container for time.

        
        

        - **time** *(datetime) --* 

          The container of the ``Timestamp`` of the blockchain instant.

           

          .. note::

            

            This ``timestamp`` will only be recorded up to the second.

            

          
    
  
  **Exceptions**
  
  *   :py:class:`ManagedBlockchainQuery.Client.exceptions.ThrottlingException`

  
  *   :py:class:`ManagedBlockchainQuery.Client.exceptions.ValidationException`

  
  *   :py:class:`ManagedBlockchainQuery.Client.exceptions.ResourceNotFoundException`

  
  *   :py:class:`ManagedBlockchainQuery.Client.exceptions.AccessDeniedException`

  
  *   :py:class:`ManagedBlockchainQuery.Client.exceptions.InternalServerException`

  
  *   :py:class:`ManagedBlockchainQuery.Client.exceptions.ServiceQuotaExceededException`

  