Class ContractBalancesExtensions
Extension methods for querying account and contract balances.
Inherited Members
Namespace: Hiero
Assembly: Hiero.dll
Syntax
public static class ContractBalancesExtensions
Methods
| Edit this page View SourceGetAccountBalanceAsync(ConsensusClient, EntityId, CancellationToken, Action<IConsensusContext>?)
Retrieves the balance in tinybars from the network for a given address.
Declaration
public static Task<ulong> GetAccountBalanceAsync(this ConsensusClient client, EntityId address, CancellationToken cancellationToken = default, Action<IConsensusContext>? configure = null)
Parameters
| Type | Name | Description |
|---|---|---|
| ConsensusClient | client | The Consensus Node Client to query. |
| EntityId | address | The hedera network address to retrieve the balance of. |
| CancellationToken | cancellationToken | Optional cancellation token. |
| Action<IConsensusContext> | configure | Optional callback method providing an opportunity to modify the execution configuration for just this method call. It is executed prior to submitting the request to the network. |
Returns
| Type | Description |
|---|---|
| Task<ulong> | The balance of the associated address. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | If required arguments are missing. |
| InvalidOperationException | If required context configuration is missing. |
| PrecheckException | If the gateway node rejected the request upon submission. |
GetAccountBalancesAsync(ConsensusClient, EntityId, CancellationToken, Action<IConsensusContext>?)
Retrieves the crypto and token balances from the network for a given address.
Declaration
public static Task<AccountBalances> GetAccountBalancesAsync(this ConsensusClient client, EntityId address, CancellationToken cancellationToken = default, Action<IConsensusContext>? configure = null)
Parameters
| Type | Name | Description |
|---|---|---|
| ConsensusClient | client | The Consensus Node Client to query. |
| EntityId | address | The hedera network address to retrieve the balance of. |
| CancellationToken | cancellationToken | Optional cancellation token. |
| Action<IConsensusContext> | configure | Optional callback method providing an opportunity to modify the execution configuration for just this method call. It is executed prior to submitting the request to the network. |
Returns
| Type | Description |
|---|---|
| Task<AccountBalances> | An object containing the crypto balance associated with the account in addition to a list of all tokens held by the account with their balances. |
GetContractBalanceAsync(ConsensusClient, EntityId, CancellationToken, Action<IConsensusContext>?)
Retrieves the balance in tinybars from the network for a given contract.
Declaration
public static Task<ulong> GetContractBalanceAsync(this ConsensusClient client, EntityId contract, CancellationToken cancellationToken = default, Action<IConsensusContext>? configure = null)
Parameters
| Type | Name | Description |
|---|---|---|
| ConsensusClient | client | The Consensus Node Client to query. |
| EntityId | contract | The hedera network contract address to retrieve the balance of. |
| CancellationToken | cancellationToken | Optional cancellation token. |
| Action<IConsensusContext> | configure | Optional callback method providing an opportunity to modify the execution configuration for just this method call. It is executed prior to submitting the request to the network. |
Returns
| Type | Description |
|---|---|
| Task<ulong> | The balance of the associated contract. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | If required arguments are missing. |
| InvalidOperationException | If required context configuration is missing. |
| PrecheckException | If the gateway node rejected the request upon submission. |
GetContractBalancesAsync(ConsensusClient, EntityId, CancellationToken, Action<IConsensusContext>?)
Retrieves the crypto and token balances from the network for a given contract.
Declaration
public static Task<AccountBalances> GetContractBalancesAsync(this ConsensusClient client, EntityId contract, CancellationToken cancellationToken = default, Action<IConsensusContext>? configure = null)
Parameters
| Type | Name | Description |
|---|---|---|
| ConsensusClient | client | The Consensus Node Client to query. |
| EntityId | contract | The hedera network address of the contract to retrieve the balance of. |
| CancellationToken | cancellationToken | Optional cancellation token. |
| Action<IConsensusContext> | configure | Optional callback method providing an opportunity to modify the execution configuration for just this method call. It is executed prior to submitting the request to the network. |
Returns
| Type | Description |
|---|---|
| Task<AccountBalances> | An object containing the crypto balance associated with the contract in addition to a list of all tokens held by the contract with their balances. |