- All Implemented Interfaces:
AutoCloseable
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final Duration(package private) static final Duration(package private) static final int(package private) static final Duration(package private) static final Duration(package private) static final Duration(package private) static final Duration(package private) static final Duration(package private) static final Duration(package private) Hbar(package private) Hbar(package private) final ExecutorService(package private) MirrorNetwork(package private) Network(package private) static final Duration -
Constructor Summary
ConstructorsConstructorDescriptionClient(ExecutorService executor, Network network, MirrorNetwork mirrorNetwork, Duration networkUpdateInitialDelay, boolean shouldShutdownExecutor, Duration networkUpdatePeriod, long shard, long realm) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Initiates an orderly shutdown of all channels (to the Hedera network) in which preexisting transactions or queries continue but more would be immediately cancelled.voidInitiates an orderly shutdown of all channels (to the Hedera network) in which preexisting transactions or queries continue but more would be immediately cancelled.(package private) static ExecutorServiceExtract the executor.static ClientConstruct a Hedera client pre-configured for Mainnet access.static ClientforMainnet(ExecutorService executor) Construct a Hedera client pre-configured for Mainnet access.static ClientforMirrorNetwork(List<String> mirrorNetworkList) Set up the client from selected mirror network.static ClientforMirrorNetwork(List<String> mirrorNetworkList, long shard, long realm) Set up the client from selected mirror network and given realm and shardstatic ClientSet up the client for the selected network.static ClientforNetwork(Map<String, AccountId> networkMap) Construct a client given a set of nodes.static ClientforNetwork(Map<String, AccountId> networkMap, ExecutorService executor) Construct a client given a set of nodes.static ClientConstruct a Hedera client pre-configured for Preview Testnet nodes.static ClientforPreviewnet(ExecutorService executor) Construct a Hedera client pre-configured for Preview Testnet nodes.static ClientConstruct a Hedera client pre-configured for Testnet access.static ClientforTestnet(ExecutorService executor) Construct a Hedera client pre-configured for Testnet access.static ClientfromConfig(Reader json) Configure a client based off the given JSON reader.static ClientfromConfig(String json) Configure a client based off the given JSON string.static ClientfromConfigFile(File file) Configure a client based on a JSON file.static ClientfromConfigFile(String fileName) Configure a client based on a JSON file at the given path.Maximum amount of time closing a network can take.Extract the maximum query payment.The default maximum fee used for transactions.booleanShould the transaction id be regenerated?Maximum amount of time a gRPC request can runCurrent LedgerId of the network; corresponds to ledger ID in entity ID checksum calculations.intMax number of attempts a request executed with this client will do.The maximum amount of time to wait between retriesintMax number of times any node in the network can receive a bad gRPC status before being removed from the network.Extract the node readmit time.The minimum amount of time to wait between retriesExtract the minimum node readmit time.Extract the mirror network node list.Build the REST base URL for the next healthy mirror node.Extract the network.Deprecated.Get the period for updating the Address BookThe maximum backoff time for any node in the network.The minimum backoff time for any node in the network.Deprecated.- UsegetNodeMaxBackoff()instead(package private) Client.OperatorExtract the operator.Get the ID of the operator.Get the key of the operator.longgetRealm()Get the current default realm for new Client instances.Maximum amount of time a request can runlonggetShard()Get the current default shard for new Client instances.booleanShould node failover be enabledbooleanIs automatic entity ID checksum validation enabled.booleanIs tls enabled for consensus nodes.booleanIs certificate verification enabled.booleanIs tls enabled for mirror nodes.Send a ping to the given node.Send a ping to the given node.pingAll()Sends pings to all nodes in the client's network.Sends pings to all nodes in the client's network.Sends pings to all nodes in the client's network asynchronously.pingAllAsync(Duration timeoutPerPing) Sends pings to all nodes in the client's network asynchronously.voidpingAllAsync(Duration timeoutPerPing, BiConsumer<Void, Throwable> callback) Sends pings to all nodes in the client's network asynchronously.voidSends pings to all nodes in the client's network asynchronously.voidpingAllAsync(BiConsumer<Void, Throwable> callback) Sends pings to all nodes in the client's network asynchronously.voidpingAllAsync(Consumer<Void> onSuccess, Consumer<Throwable> onFailure) Sends pings to all nodes in the client's network asynchronously.Send a ping to the given node asynchronously.Send a ping to the given node asynchronously.voidSend a ping to the given node asynchronously.voidpingAsync(AccountId nodeAccountId, Duration timeout, Consumer<Void> onSuccess, Consumer<Throwable> onFailure) Send a ping to the given node asynchronously.voidpingAsync(AccountId nodeAccountId, BiConsumer<Void, Throwable> callback) Send a ping to the given node asynchronously.voidSend a ping to the given node asynchronously.setAllowReceiptNodeFailover(boolean allowReceiptNodeFailover) Enable or disable receipt query failover to other nodes when the submitting node is unresponsive.setAutoValidateChecksums(boolean value) Enable or disable automatic entity ID checksum validation.setCloseTimeout(Duration closeTimeout) Set the maximum amount of time closing a network can take.setDefaultMaxQueryPayment(Hbar defaultMaxQueryPayment) Set the maximum default payment allowable for queries.setDefaultMaxTransactionFee(Hbar defaultMaxTransactionFee) Set the maximum fee to be paid for transactions executed by this client.setDefaultRegenerateTransactionId(boolean regenerateTransactionId) Assign the default regenerate transaction id.setGrpcDeadline(Duration grpcDeadline) Set the maximum amount of time a gRPC request can run.setLedgerId(LedgerId ledgerId) Set the LedgerId to a particular value.setMaxAttempts(int maxAttempts) Set the max number of attempts a request executed with this client will do.setMaxBackoff(Duration maxBackoff) The maximum amount of time to wait between retries.setMaxNodeAttempts(int maxNodeAttempts) Set the max number of times any node in the network can receive a bad gRPC status before being removed from the network.setMaxNodeReadmitTime(Duration maxNodeReadmitTime) Assign the maximum node readmit time.setMaxNodesPerTransaction(int maxNodesPerTransaction) Set the max amount of nodes that will be chosen per request.setMaxQueryPayment(Hbar maxQueryPayment) Deprecated.UsesetDefaultMaxQueryPayment(Hbar)instead.setMaxTransactionFee(Hbar maxTransactionFee) Deprecated.UsesetDefaultMaxTransactionFee(Hbar)instead.setMinBackoff(Duration minBackoff) The minimum amount of time to wait between retries.setMinNodeReadmitTime(Duration minNodeReadmitTime) Assign the minimum node readmit time.setMirrorNetwork(List<String> network) Set the mirror network nodes.setMirrorTransportSecurity(boolean transportSecurity) Deprecated.Mirror nodes can only be accessed using TLSsetNetwork(Map<String, AccountId> network) Replace all nodes in this Client with a new set of nodes (e.g.setNetworkFromAddressBook(NodeAddressBook addressBook) Replace all nodes in this Client with the nodes in the Address Book and update the address book if necessary.setNetworkName(NetworkName networkName) Deprecated.usesetLedgerId(LedgerId)insteadsetNetworkUpdatePeriod(Duration networkUpdatePeriod) Set the period for updating the Address BooksetNodeMaxBackoff(Duration maxBackoff) Set the maximum backoff time for any node in the network.setNodeMinBackoff(Duration minBackoff) Set the minimum backoff time for any node in the network.setNodeWaitTime(Duration nodeWaitTime) Deprecated.- UsesetNodeMinBackoff(Duration)()} insteadsetOperator(AccountId accountId, PrivateKey privateKey) Set the account that will, by default, be paying for transactions and queries built with this client.setOperatorWith(AccountId accountId, PublicKey publicKey, UnaryOperator<byte[]> transactionSigner) Sets the account that will, by default, by paying for transactions and queries built with this client.setRequestTimeout(Duration requestTimeout) Set the maximum amount of time a request can run.setTransportSecurity(boolean transportSecurity) Set if transport security should be used to connect to consensus nodes.setVerifyCertificates(boolean verifyCertificates) Set if server certificates should be verified against an existing address book(package private) voidtrackSubscription(SubscriptionHandle subscriptionHandle) (package private) voiduntrackSubscription(SubscriptionHandle subscriptionHandle) Trigger an immediate address book update to refresh the client's network with the latest node information.
-
Field Details
-
DEFAULT_MAX_ATTEMPTS
static final int DEFAULT_MAX_ATTEMPTS- See Also:
-
DEFAULT_MAX_BACKOFF
-
DEFAULT_MIN_BACKOFF
-
DEFAULT_MAX_NODE_BACKOFF
-
DEFAULT_MIN_NODE_BACKOFF
-
DEFAULT_CLOSE_TIMEOUT
-
DEFAULT_REQUEST_TIMEOUT
-
DEFAULT_GRPC_DEADLINE
-
DEFAULT_NETWORK_UPDATE_PERIOD
-
NETWORK_UPDATE_INITIAL_DELAY
-
executor
-
defaultMaxTransactionFee
-
defaultMaxQueryPayment
Hbar defaultMaxQueryPayment -
network
Network network -
mirrorNetwork
MirrorNetwork mirrorNetwork
-
-
Constructor Details
-
Client
Client(ExecutorService executor, Network network, MirrorNetwork mirrorNetwork, @Nullable Duration networkUpdateInitialDelay, boolean shouldShutdownExecutor, @Nullable Duration networkUpdatePeriod, long shard, long realm) Constructor.- Parameters:
executor- the executornetwork- the networkmirrorNetwork- the mirror networkshouldShutdownExecutor-
-
-
Method Details
-
createExecutor
Extract the executor.- Returns:
- the executor service
-
forNetwork
Construct a client given a set of nodes. It is the responsibility of the caller to ensure that all nodes in the map are part of the same Hedera network. Failure to do so will result in undefined behavior. The client will load balance all requests to Hedera using a simple round-robin scheme to chose nodes to send transactions to. For one transaction, at most 1/3 of the nodes will be tried.- Parameters:
networkMap- the map of node IDs to node addresses that make up the network.executor- runs the grpc requests asynchronously.- Returns:
Client
-
forNetwork
Construct a client given a set of nodes.It is the responsibility of the caller to ensure that all nodes in the map are part of the same Hedera network. Failure to do so will result in undefined behavior.
The client will load balance all requests to Hedera using a simple round-robin scheme to chose nodes to send transactions to. For one transaction, at most 1/3 of the nodes will be tried.
- Parameters:
networkMap- the map of node IDs to node addresses that make up the network.- Returns:
Client
-
forMirrorNetwork
public static Client forMirrorNetwork(List<String> mirrorNetworkList) throws InterruptedException, TimeoutException Set up the client from selected mirror network. Using default `0` values for realm and shard for retrieving addressBookFileId- Parameters:
mirrorNetworkList-- Returns:
- Throws:
InterruptedExceptionTimeoutException
-
forMirrorNetwork
public static Client forMirrorNetwork(List<String> mirrorNetworkList, long shard, long realm) throws InterruptedException, TimeoutException Set up the client from selected mirror network and given realm and shard- Parameters:
mirrorNetworkList-shard-realm-- Returns:
- Throws:
InterruptedExceptionTimeoutException
-
forName
Set up the client for the selected network.- Parameters:
name- the selected network- Returns:
- the configured client
-
forMainnet
Construct a Hedera client pre-configured for Mainnet access.- Parameters:
executor- runs the grpc requests asynchronously.- Returns:
Client
-
forTestnet
Construct a Hedera client pre-configured for Testnet access.- Parameters:
executor- runs the grpc requests asynchronously.- Returns:
Client
-
forPreviewnet
Construct a Hedera client pre-configured for Preview Testnet nodes.- Parameters:
executor- runs the grpc requests asynchronously.- Returns:
Client
-
forMainnet
Construct a Hedera client pre-configured for Mainnet access.- Returns:
Client
-
forTestnet
Construct a Hedera client pre-configured for Testnet access.- Returns:
Client
-
forPreviewnet
Construct a Hedera client pre-configured for Preview Testnet nodes.- Returns:
Client
-
fromConfig
Configure a client based off the given JSON string. -
fromConfig
Configure a client based off the given JSON reader. -
fromConfigFile
Configure a client based on a JSON file at the given path.- Parameters:
fileName- The string containing the file path- Returns:
Client- Throws:
IOException- if IO operations failException
-
fromConfigFile
Configure a client based on a JSON file.- Parameters:
file- The file containing the client configuration- Returns:
Client- Throws:
IOException- if IO operations failException
-
getMirrorNetwork
Extract the mirror network node list.- Returns:
- the list of mirror nodes
-
getMirrorRestBaseUrl
Build the REST base URL for the next healthy mirror node. Returns a string like `https://host[:port]/api/v1`. If the selected mirror node is a local host (localhost/127.0.0.1) returns `http://localhost:{5551|8545}/api/v1`. -
setMirrorNetwork
Set the mirror network nodes.- Parameters:
network- list of network nodes- Returns:
this- Throws:
InterruptedException- when a thread is interrupted while it's waiting, sleeping, or otherwise occupied
-
trackSubscription
-
untrackSubscription
-
setNetworkFromAddressBook
public Client setNetworkFromAddressBook(NodeAddressBook addressBook) throws InterruptedException, TimeoutException Replace all nodes in this Client with the nodes in the Address Book and update the address book if necessary.- Parameters:
addressBook- A list of nodes and their metadata- Returns:
this- Throws:
InterruptedExceptionTimeoutException
-
getNetwork
Extract the network.- Returns:
- the client's network
-
setNetwork
public Client setNetwork(Map<String, AccountId> network) throws InterruptedException, TimeoutExceptionReplace all nodes in this Client with a new set of nodes (e.g. for an Address Book update).- Parameters:
network- a map of node account ID to node URL.- Returns:
thisfor fluent API usage.- Throws:
TimeoutException- when shutting down nodesInterruptedException- when a thread is interrupted while it's waiting, sleeping, or otherwise occupied
-
setMirrorTransportSecurity
Deprecated.Mirror nodes can only be accessed using TLSSet if transport security should be used to connect to mirror nodes.
If transport security is enabled all connections to mirror nodes will use TLS.- Parameters:
transportSecurity- - enable or disable transport security for mirror nodes- Returns:
thisfor fluent API usage.
-
isTransportSecurity
public boolean isTransportSecurity()Is tls enabled for consensus nodes.- Returns:
- is tls enabled
-
setTransportSecurity
Set if transport security should be used to connect to consensus nodes.
If transport security is enabled all connections to consensus nodes will use TLS, and the server's certificate hash will be compared to the hash stored in theNodeAddressBookfor the given network.
*Note*: If transport security is enabled, butisVerifyCertificates()is disabled then server certificates will not be verified.- Parameters:
transportSecurity- enable or disable transport security for consensus nodes- Returns:
thisfor fluent API usage.- Throws:
InterruptedException- when a thread is interrupted while it's waiting, sleeping, or otherwise occupied
-
mirrorIsTransportSecurity
public boolean mirrorIsTransportSecurity()Is tls enabled for mirror nodes.- Returns:
- is tls enabled
-
isVerifyCertificates
public boolean isVerifyCertificates()Is certificate verification enabled.- Returns:
- is certificate verification enabled
-
setVerifyCertificates
Set if server certificates should be verified against an existing address book- Parameters:
verifyCertificates- - enable or disable certificate verification- Returns:
this
-
ping
Send a ping to the given node.- Parameters:
nodeAccountId- Account ID of the node to ping- Throws:
TimeoutException- when the transaction times outPrecheckStatusException- when the precheck fails
-
ping
public Void ping(AccountId nodeAccountId, Duration timeout) throws PrecheckStatusException, TimeoutException Send a ping to the given node.- Parameters:
nodeAccountId- Account ID of the node to pingtimeout- The timeout after which the execution attempt will be cancelled.- Throws:
TimeoutException- when the transaction times outPrecheckStatusException- when the precheck fails
-
pingAsync
Send a ping to the given node asynchronously.- Parameters:
nodeAccountId- Account ID of the node to ping- Returns:
- an empty future that throws exception if there was an error
-
pingAsync
Send a ping to the given node asynchronously.- Parameters:
nodeAccountId- Account ID of the node to pingtimeout- The timeout after which the execution attempt will be cancelled.- Returns:
- an empty future that throws exception if there was an error
-
pingAsync
Send a ping to the given node asynchronously.- Parameters:
nodeAccountId- Account ID of the node to pingcallback- a BiConsumer which handles the result or error.
-
pingAsync
public void pingAsync(AccountId nodeAccountId, Duration timeout, BiConsumer<Void, Throwable> callback) Send a ping to the given node asynchronously.- Parameters:
nodeAccountId- Account ID of the node to pingtimeout- The timeout after which the execution attempt will be cancelled.callback- a BiConsumer which handles the result or error.
-
pingAsync
public void pingAsync(AccountId nodeAccountId, Consumer<Void> onSuccess, Consumer<Throwable> onFailure) Send a ping to the given node asynchronously.- Parameters:
nodeAccountId- Account ID of the node to pingonSuccess- a Consumer which consumes the result on success.onFailure- a Consumer which consumes the error on failure.
-
pingAsync
public void pingAsync(AccountId nodeAccountId, Duration timeout, Consumer<Void> onSuccess, Consumer<Throwable> onFailure) Send a ping to the given node asynchronously.- Parameters:
nodeAccountId- Account ID of the node to pingtimeout- The timeout after which the execution attempt will be cancelled.onSuccess- a Consumer which consumes the result on success.onFailure- a Consumer which consumes the error on failure.
-
pingAll
Sends pings to all nodes in the client's network. Combines well with setMaxAttempts(1) to remove all dead nodes from the network.- Throws:
TimeoutException- when the transaction times outPrecheckStatusException- when the precheck fails
-
pingAll
Sends pings to all nodes in the client's network. Combines well with setMaxAttempts(1) to remove all dead nodes from the network.- Parameters:
timeoutPerPing- The timeout after which each execution attempt will be cancelled.- Throws:
TimeoutException- when the transaction times outPrecheckStatusException- when the precheck fails
-
pingAllAsync
Sends pings to all nodes in the client's network asynchronously. Combines well with setMaxAttempts(1) to remove all dead nodes from the network.- Returns:
- an empty future that throws exception if there was an error
-
pingAllAsync
Sends pings to all nodes in the client's network asynchronously. Combines well with setMaxAttempts(1) to remove all dead nodes from the network.- Parameters:
timeoutPerPing- The timeout after which each execution attempt will be cancelled.- Returns:
- an empty future that throws exception if there was an error
-
pingAllAsync
Sends pings to all nodes in the client's network asynchronously. Combines well with setMaxAttempts(1) to remove all dead nodes from the network.- Parameters:
callback- a BiConsumer which handles the result or error.
-
pingAllAsync
Sends pings to all nodes in the client's network asynchronously. Combines well with setMaxAttempts(1) to remove all dead nodes from the network.- Parameters:
timeoutPerPing- The timeout after which each execution attempt will be cancelled.callback- a BiConsumer which handles the result or error.
-
pingAllAsync
Sends pings to all nodes in the client's network asynchronously. Combines well with setMaxAttempts(1) to remove all dead nodes from the network.- Parameters:
onSuccess- a Consumer which consumes the result on success.onFailure- a Consumer which consumes the error on failure.
-
pingAllAsync
public void pingAllAsync(Duration timeoutPerPing, Consumer<Void> onSuccess, Consumer<Throwable> onFailure) Sends pings to all nodes in the client's network asynchronously. Combines well with setMaxAttempts(1) to remove all dead nodes from the network.- Parameters:
timeoutPerPing- The timeout after which each execution attempt will be cancelled.onSuccess- a Consumer which consumes the result on success.onFailure- a Consumer which consumes the error on failure.
-
setOperator
Set the account that will, by default, be paying for transactions and queries built with this client.The operator account ID is used to generate the default transaction ID for all transactions executed with this client.
The operator private key is used to sign all transactions executed by this client.
- Parameters:
accountId- The AccountId of the operatorprivateKey- The PrivateKey of the operator- Returns:
this
-
setOperatorWith
public Client setOperatorWith(AccountId accountId, PublicKey publicKey, UnaryOperator<byte[]> transactionSigner) Sets the account that will, by default, by paying for transactions and queries built with this client.The operator account ID is used to generate a default transaction ID for all transactions executed with this client.
The `transactionSigner` is invoked to sign all transactions executed by this client.
- Parameters:
accountId- The AccountId of the operatorpublicKey- The PrivateKey of the operatortransactionSigner- The signer for the operator- Returns:
this
-
getNetworkName
Deprecated.usegetLedgerId()insteadCurrent name of the network; corresponds to ledger ID in entity ID checksum calculations.- Returns:
- the network name
-
setNetworkName
Deprecated.usesetLedgerId(LedgerId)insteadSet the network name to a particular value. Useful when constructing a network which is a subset of an existing known network.- Parameters:
networkName- the desired network- Returns:
this
-
getLedgerId
Current LedgerId of the network; corresponds to ledger ID in entity ID checksum calculations.- Returns:
- the ledger id
-
setLedgerId
Set the LedgerId to a particular value. Useful when constructing a network which is a subset of an existing known network.- Parameters:
ledgerId- the desired ledger id- Returns:
this
-
getMaxAttempts
public int getMaxAttempts()Max number of attempts a request executed with this client will do.- Returns:
- the maximus attempts
-
setMaxAttempts
Set the max number of attempts a request executed with this client will do.- Parameters:
maxAttempts- the desired max attempts- Returns:
this
-
getMaxBackoff
The maximum amount of time to wait between retries- Returns:
- maxBackoff
-
setMaxBackoff
The maximum amount of time to wait between retries. Every retry attempt will increase the wait time exponentially until it reaches this time.- Parameters:
maxBackoff- The maximum amount of time to wait between retries- Returns:
this
-
getMinBackoff
The minimum amount of time to wait between retries- Returns:
- minBackoff
-
setMinBackoff
The minimum amount of time to wait between retries. When retrying, the delay will start at this time and increase exponentially until it reaches the maxBackoff.- Parameters:
minBackoff- The minimum amount of time to wait between retries- Returns:
this
-
getMaxNodeAttempts
public int getMaxNodeAttempts()Max number of times any node in the network can receive a bad gRPC status before being removed from the network.- Returns:
- the maximum node attempts
-
setMaxNodeAttempts
Set the max number of times any node in the network can receive a bad gRPC status before being removed from the network.- Parameters:
maxNodeAttempts- the desired minimum attempts- Returns:
this
-
getNodeWaitTime
Deprecated.- UsegetNodeMaxBackoff()insteadThe minimum backoff time for any node in the network.- Returns:
- the wait time
-
setNodeWaitTime
Deprecated.- UsesetNodeMinBackoff(Duration)()} insteadSet the minimum backoff time for any node in the network.- Parameters:
nodeWaitTime- the wait time- Returns:
- the updated client
-
getNodeMinBackoff
The minimum backoff time for any node in the network.- Returns:
- the minimum backoff time
-
setNodeMinBackoff
Set the minimum backoff time for any node in the network.- Parameters:
minBackoff- the desired minimum backoff time- Returns:
this
-
getNodeMaxBackoff
The maximum backoff time for any node in the network.- Returns:
- the maximum node backoff time
-
setNodeMaxBackoff
Set the maximum backoff time for any node in the network.- Parameters:
maxBackoff- the desired max backoff time- Returns:
this
-
getMinNodeReadmitTime
Extract the minimum node readmit time.- Returns:
- the minimum node readmit time
-
setMinNodeReadmitTime
Assign the minimum node readmit time.- Parameters:
minNodeReadmitTime- the requested duration- Returns:
this
-
getMaxNodeReadmitTime
Extract the node readmit time.- Returns:
- the maximum node readmit time
-
setMaxNodeReadmitTime
Assign the maximum node readmit time.- Parameters:
maxNodeReadmitTime- the maximum node readmit time- Returns:
this
-
setMaxNodesPerTransaction
Set the max amount of nodes that will be chosen per request. By default, the request will use 1/3rd the network nodes per request.- Parameters:
maxNodesPerTransaction- the desired number of nodes- Returns:
this
-
setAutoValidateChecksums
Enable or disable automatic entity ID checksum validation.- Parameters:
value- the desired value- Returns:
this
-
isAutoValidateChecksumsEnabled
public boolean isAutoValidateChecksumsEnabled()Is automatic entity ID checksum validation enabled.- Returns:
- is validation enabled
-
getOperatorAccountId
Get the ID of the operator. Useful when the client was constructed from file.- Returns:
- {AccountId}
-
getOperatorPublicKey
Get the key of the operator. Useful when the client was constructed from file.- Returns:
- {PublicKey}
-
getDefaultMaxTransactionFee
The default maximum fee used for transactions.- Returns:
- the max transaction fee
-
setDefaultMaxTransactionFee
Set the maximum fee to be paid for transactions executed by this client.Because transaction fees are always maximums, this will simply add a call to
Transaction.setMaxTransactionFee(Hbar)on every new transaction. The actual fee assessed for a given transaction may be less than this value, but never greater.- Parameters:
defaultMaxTransactionFee- The Hbar to be set- Returns:
this
-
setMaxTransactionFee
Deprecated.UsesetDefaultMaxTransactionFee(Hbar)instead.Set the maximum fee to be paid for transactions executed by this client.Because transaction fees are always maximums, this will simply add a call to
Transaction.setMaxTransactionFee(Hbar)on every new transaction. The actual fee assessed for a given transaction may be less than this value, but never greater.- Parameters:
maxTransactionFee- The Hbar to be set- Returns:
this
-
getDefaultMaxQueryPayment
Extract the maximum query payment.- Returns:
- the default maximum query payment
-
setDefaultMaxQueryPayment
Set the maximum default payment allowable for queries.When a query is executed without an explicit
Query.setQueryPayment(Hbar)call, the client will first request the cost of the given query from the node it will be submitted to and attach a payment for that amount from the operator account on the client.If the returned value is greater than this value, a
MaxQueryPaymentExceededExceptionwill be thrown fromExecutable.execute(Client)or returned in the second callback ofExecutable.executeAsync(Client, Consumer, Consumer).Set to 0 to disable automatic implicit payments.
- Parameters:
defaultMaxQueryPayment- The Hbar to be set- Returns:
this
-
setMaxQueryPayment
Deprecated.UsesetDefaultMaxQueryPayment(Hbar)instead.- Parameters:
maxQueryPayment- The Hbar to be set- Returns:
this
-
getDefaultRegenerateTransactionId
public boolean getDefaultRegenerateTransactionId()Should the transaction id be regenerated?- Returns:
- the default regenerate transaction id
-
isAllowReceiptNodeFailover
public boolean isAllowReceiptNodeFailover()Should node failover be enabled- Returns:
- the node failover mode
-
setDefaultRegenerateTransactionId
Assign the default regenerate transaction id.- Parameters:
regenerateTransactionId- should there be a regenerated transaction id- Returns:
this
-
setAllowReceiptNodeFailover
Enable or disable receipt query failover to other nodes when the submitting node is unresponsive. When enabled, receipt queries will start with the submitting node but can fail over to other nodes in the network if needed. Default is `false` to preserve existing behavior where receipt queries are pinned to the submitting node only.- Parameters:
allowReceiptNodeFailover- should node failover be enabled- Returns:
this
-
getRequestTimeout
Maximum amount of time a request can run- Returns:
- the timeout value
-
setRequestTimeout
Set the maximum amount of time a request can run. Used only in async variants of methods.- Parameters:
requestTimeout- the timeout value- Returns:
this
-
getCloseTimeout
Maximum amount of time closing a network can take.- Returns:
- the timeout value
-
setCloseTimeout
Set the maximum amount of time closing a network can take.- Parameters:
closeTimeout- the timeout value- Returns:
this
-
getGrpcDeadline
Maximum amount of time a gRPC request can run- Returns:
- the gRPC deadline value
-
setGrpcDeadline
Set the maximum amount of time a gRPC request can run.- Parameters:
grpcDeadline- the gRPC deadline value- Returns:
this
-
getOperator
Extract the operator.- Returns:
- the operator
-
getNetworkUpdatePeriod
Get the period for updating the Address Book- Returns:
- the networkUpdatePeriod
-
setNetworkUpdatePeriod
Set the period for updating the Address BookNote: This method requires API level 33 or higher. It will not work on devices running API versions below 31 because it uses features introduced in API level 31 (Android 12).
*- Parameters:
networkUpdatePeriod- the period for updating the Address Book- Returns:
this
-
updateNetworkFromAddressBook
Trigger an immediate address book update to refresh the client's network with the latest node information. This is useful when encountering INVALID_NODE_ACCOUNT_ID errors to ensure subsequent transactions use the correct node account IDs.- Returns:
this
-
getLogger
-
setLogger
-
getRealm
public long getRealm()Get the current default realm for new Client instances.- Returns:
- the default realm
-
getShard
public long getShard()Get the current default shard for new Client instances.- Returns:
- the default shard
-
close
Initiates an orderly shutdown of all channels (to the Hedera network) in which preexisting transactions or queries continue but more would be immediately cancelled.After this method returns, this client can be re-used. Channels will be re-established as needed.
- Specified by:
closein interfaceAutoCloseable- Throws:
TimeoutException- if the mirror network doesn't close in time
-
close
Initiates an orderly shutdown of all channels (to the Hedera network) in which preexisting transactions or queries continue but more would be immediately cancelled.After this method returns, this client can be re-used. Channels will be re-established as needed.
- Parameters:
timeout- The Duration to be set- Throws:
TimeoutException- if the mirror network doesn't close in time
-
getLedgerId()instead