Gets the balance of a specific token, including native tokens, for a given address (wallet or contract) on the blockchain.
Only the native tokens BTC and ETH, and the ERC-20, ERC-721, and ERC 1155 token standards are supported.
Parameters:
-
token_identifier
(TokenIdentifier)
–
The container for the identifier for the token, including the unique token ID and its blockchain network.
-
owner_identifier
(OwnerIdentifier)
–
The container for the identifier for the owner.
-
at_blockchain_instant
(Optional[BlockchainInstant], default:
None
)
–
The time for when the TokenBalance is requested or the current time if a time is not provided in the request.
This time will only be recorded up to the second.
Raises:
-
AccessDeniedException
–
The Amazon Web Services account doesn’t have access to this resource.
-
InternalServerException
–
The request processing has failed because of an internal error in the service.
-
ResourceNotFoundException
–
The resource was not found.
-
ServiceQuotaExceededException
–
The service quota has been exceeded for this resource.
-
ThrottlingException
–
The request or operation couldn't be performed because a service is throttling requests. The most common source of throttling errors is when you create resources that exceed your service limit for this resource type. Request a limit increase or delete unused resources, if possible.
-
ValidationException
–
The resource passed is invalid.
-
UnknownServiceError
–
The service returned an error code this client does not model.
Source code in docs_src/capo_managedblockchain_query/_services/managed_blockchain_query.py
| def get_token_balance(
self,
token_identifier: "capo_managedblockchain_query.types.token_identifier.TokenIdentifier",
owner_identifier: "capo_managedblockchain_query.types.owner_identifier.OwnerIdentifier",
*,
config_overrides: Optional[ManagedBlockchainQueryClientConfig] = None,
at_blockchain_instant: Optional[
"capo_managedblockchain_query.types.blockchain_instant.BlockchainInstant"
] = None,
) -> "capo_managedblockchain_query.types.get_token_balance_output.GetTokenBalanceOutput":
"""<p>Gets the balance of a specific token, including native tokens, for a given address (wallet or contract) on the blockchain.</p> <note> <p>Only the native tokens BTC and ETH, and the ERC-20, ERC-721, and ERC 1155 token standards are supported.</p> </note>
Args:
token_identifier: <p>The container for the identifier for the token, including the unique token ID and its blockchain network.</p>
owner_identifier: <p>The container for the identifier for the owner.</p>
at_blockchain_instant: <p>The time for when the TokenBalance is requested or the current time if a time is not provided in the request.</p> <note> <p>This time will only be recorded up to the second.</p> </note>
Raises:
capo_managedblockchain_query.errors.access_denied_exception.AccessDeniedException: <p>The Amazon Web Services account doesn’t have access to this resource. </p>
capo_managedblockchain_query.errors.internal_server_exception.InternalServerException: <p>The request processing has failed because of an internal error in the service.</p>
capo_managedblockchain_query.errors.resource_not_found_exception.ResourceNotFoundException: <p>The resource was not found.</p>
capo_managedblockchain_query.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: <p>The service quota has been exceeded for this resource.</p>
capo_managedblockchain_query.errors.throttling_exception.ThrottlingException: <p>The request or operation couldn't be performed because a service is throttling requests. The most common source of throttling errors is when you create resources that exceed your service limit for this resource type. Request a limit increase or delete unused resources, if possible.</p>
capo_managedblockchain_query.errors.validation_exception.ValidationException: <p>The resource passed is invalid.</p>
capo_managedblockchain_query.errors.UnknownServiceError: The service returned an error code this client does not model.
"""
def _handler(
req: "OperationRequest[capo_managedblockchain_query.types.get_token_balance_input.GetTokenBalanceInput]",
) -> OperationResponse[
"capo_managedblockchain_query.types.get_token_balance_output.GetTokenBalanceOutput"
]:
import capo_managedblockchain_query._operations.tieton_chain_query_service.get_token_balance
output, http_response = (
capo_managedblockchain_query._operations.tieton_chain_query_service.get_token_balance.get_token_balance(
req.options, req.input
)
)
return OperationResponse(output=output, response=http_response)
interceptors_, options_ = self.operation_options(
config_overrides, OperationLogging("GetTokenBalance")
)
input_: capo_managedblockchain_query.types.get_token_balance_input.GetTokenBalanceInput = {
"token_identifier": token_identifier,
"owner_identifier": owner_identifier,
}
if at_blockchain_instant is not None:
input_["at_blockchain_instant"] = at_blockchain_instant
response = execute_pipeline(
OperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
response.response.close()
return response.output
|