@hiero-ledger/sdk
    Preparing search index...

    Class Client

    Hierarchy

    • default
      • Client
    Index

    Constructors

    Properties

    Accessors

    Methods

    Constructors

    Properties

    _isUpdatingNetwork: boolean
    _logger: null | Logger

    Logger

    _maxAttempts: number
    _realm: number
    _shard: number
    _timer: Timeout

    Accessors

    • get allowReceiptNodeFailover(): boolean

      Returns boolean

    • get defaultRegenerateTransactionId(): boolean

      Returns boolean

    • get grpcDeadline(): number

      Get the global gRPC deadline for all requests.

      Returns number

      Maximum time in milliseconds for a single gRPC request

    • get maxNodesPerTransaction(): number

      Gets the maximum number of nodes that a transaction or query will attempt to execute against.

      Returns number

      The current maximum nodes per transaction setting. Returns -1 if no limit is set (uses network defaults).

    • get maxTransactionFee(): null | Hbar

      Returns null | Hbar

      • Use defaultMaxTransactionFee instead
    • get mirrorRestApiBaseUrl(): string

      Returns string

      When no mirror network is configured or available

    • get networkName(): null | string

      Returns null | string

    • get nodeMaxReadmitPeriod(): number

      Returns number

    • get nodeMinReadmitPeriod(): number

      Returns number

    • get requestTimeout(): number

      Get the total request timeout for complete operations.

      Returns number

      Maximum time in milliseconds for complete Transaction/Query operations

    Methods

    • Returns (address: string) => NodeMirrorChannel

    • Returns (address: string, cert?: string) => NodeChannel

    • Close the client: the consensus and mirror gRPC channels, the scheduled network update, and the mirror HTTP transport this client built for itself, which is given a 5 s grace period for reads in flight before being torn down. A transport the application injected is never closed. Mirror REST calls still running start no new attempt.

      Returns void

    • The mirror node HTTP configuration as supplied, never as resolved: transport stays null even after the SDK has built its own, so inspecting a client never constructs one and setMirrorNodeHttpConfig(getMirrorNodeHttpConfig()) is a no-op.

      Returns MirrorNodeHttpConfig

    • Returns null | ClientOperator

    • Returns boolean

    • Returns boolean

    • Probe the liveness of the node with the given account ID by sending a CryptoService/getAccountInfo query for account <shard>.<realm>.2 with ResponseType = COST_ANSWER — the node answers with the query fee without executing the query, so no HBAR is charged and no operator is required. A cost response means success; a gRPC failure propagates.

      Parameters

      Returns Promise<void>

    • 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.

      Tradeoff: Enabling this improves availability for high-throughput/relay use cases, but in rare cases only the submitting node may have the final failure information.

      Parameters

      • allowReceiptNodeFailover: boolean

      Returns Client

    • Set the maximum payment allowable for queries.

      Parameters

      • defaultMaxQueryPayment: Hbar

      Returns Client<NodeChannel, NodeMirrorChannel>

    • Set the defaultimum fee to be paid for transactions executed by this client.

      Parameters

      • defaultMaxTransactionFee: Hbar

      Returns Client

    • Set if a new transaction ID should be generated when a TRANSACTION_EXPIRED status is returned.

      Parameters

      • defaultRegenerateTransactionId: boolean

      Returns Client

    • Set the global gRPC deadline for all requests.

      Parameters

      • grpcDeadline: number

        Maximum time in milliseconds for a single gRPC request

      Returns Client

    • Available only for NodeClient Legacy method maintained for backward compatibility. This method now calls setGrpcDeadline internally to ensure proper validation.

      Parameters

      • maxExecutionTime: number

      Returns Client

      Use setGrpcDeadline instead.

    • Sets the maximum number of nodes that a transaction or query will execute against.

      • Before freezing: Limits automatic node selection when no explicit nodes are set
      • After freezing: Trims frozen transactions to the first N nodes while preserving signatures
      • Special values: 0 disables limiting, values > available nodes cause no trimming

      Parameters

      • maxNodesPerTransaction: number

        Maximum nodes per transaction. Set to 0 to disable.

      Returns Client

      The client instance for method chaining

    • Parameters

      • maxQueryPayment: Hbar

      Returns Client<NodeChannel, NodeMirrorChannel>

      in a favor of setDefaultMaxQueryPayment() Set the maximum payment allowable for queries.

    • Parameters

      • maxTransactionFee: Hbar

      Returns Client

      • Use setDefaultMaxTransactionFee() instead Set the maximum fee to be paid for transactions executed by this client.
    • Replace the mirror node HTTP configuration: the transport the mirror REST queries use (or null to let the SDK build one), how the SDK builds it, the retry policy, and the caller headers.

      The whole value is replaced, not merged, so derive from the current one to change a single field:

      const cfg = client.getMirrorNodeHttpConfig();
      client.setMirrorNodeHttpConfig({
      ...cfg,
      retryPolicy: { ...cfg.retryPolicy, maxAttempts: 3 },
      });

      A transport set here is owned by the application and never closed by the SDK; it is used from the next mirror REST call on. The transportConfiguration applies only to a transport the SDK builds, which happens once, on the first mirror REST call.

      Parameters

      • config:
            | undefined
            | MirrorNodeHttpConfig
            | {
                requestHeaders?: Record<string, string>;
                retryPolicy?:
                    | MirrorNodeHttpRetryPolicy
                    | {
                        initialBackoff?: number;
                        maxAttempts?: number;
                        maxBackoff?: number;
                        perAttemptTimeout?: number;
                        retryableStatusCodes?: readonly number[];
                        totalDeadline?: number;
                    };
                transport?: null
                | HttpTransport;
                transportConfiguration?:
                    | HttpTransportConfiguration
                    | {
                        connectTimeout?: number;
                        defaultHeaders?: Record<string, string>;
                        maxRedirects?: number;
                        maxResponseBytes?: number;
                    };
            }

      Returns Client

    • Parameters

      • networkUpdatePeriod: number

      Returns Client

    • Parameters

      • nodeMaxReadmitPeriod: number

      Returns Client

    • Parameters

      • nodeMinReadmitPeriod: number

      Returns Client

    • Set the account that will, by default, pay for transactions and queries built with this client. NOTE: When using string for private key, the string needs to contain DER headers

      Parameters

      Returns Client

    • Sets the account that will, by default, pay for transactions and queries built with this client.

      Parameters

      • accountId: string | AccountId
      • publicKey: string | PublicKey
      • transactionSigner: (message: Uint8Array) => Promise<Uint8Array<ArrayBufferLike>>

      Returns Client

    • Set the total request timeout for complete operations.

      Parameters

      • requestTimeout: number

        Maximum time in milliseconds for complete Transaction/Query operations

      Returns Client

    • Parameters

      • signOnDemand: boolean

      Returns void

    • Parameters

      • transportSecurity: boolean

      Returns Client

    • Extracts shard and realm values from a network configuration. Note: This method assumes the network is consistent (all nodes in same shard/realm). Use validateNetworkConsistency() first to ensure this.

      Parameters

      • network: { [key: string]: string | AccountId }

      Returns { realm: number; shard: number }

    • Validates that all nodes in a network are in the same shard and realm.

      Parameters

      • network: { [key: string]: string | AccountId }

      Returns void

    • Construct a Hedera client pre-configured for local-node access.

      Parameters

      • Optionalprops: { scheduleNetworkUpdate?: boolean } = ...

      Returns Client

    • Construct a Hedera client pre-configured for Mainnet access.

      Parameters

      • Optionalprops: { scheduleNetworkUpdate?: boolean } = {}

      Returns Client

    • Construct a Hedera client pre-configured for Mainnet access with network update.

      Parameters

      • Optionalprops: { scheduleNetworkUpdate?: boolean } = {}

      Returns Promise<Client>

    • Parameters

      • mirrorNetwork: string | string[]
      • Optionalshard: number
      • Optionalrealm: number

      Returns Promise<Client>

    • Parameters

      • network: string
      • Optionalprops: { scheduleNetworkUpdate?: boolean } = {}

      Returns Client

    • Construct a client for a specific network with optional network update. Updates network only if the network is not "local-node".

      Parameters

      • network: string
      • Optionalprops: { scheduleNetworkUpdate?: boolean } = {}

      Returns Promise<Client>

    • Construct a client for a specific network.

      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

      • network: { [key: string]: string | AccountId }
      • Optionalprops: ClientConfiguration

      Returns Client

    • Construct a Hedera client pre-configured for Previewnet access.

      Parameters

      • Optionalprops: { scheduleNetworkUpdate?: boolean } = {}

      Returns Client

    • Construct a Hedera client pre-configured for Previewnet access with network update.

      Parameters

      • Optionalprops: { scheduleNetworkUpdate?: boolean } = {}

      Returns Promise<Client>

    • Construct a Hedera client pre-configured for Testnet access.

      Parameters

      • Optionalprops: { scheduleNetworkUpdate?: boolean } = {}

      Returns Client

    • Construct a Hedera client pre-configured for Testnet access with network update.

      Parameters

      • Optionalprops: { scheduleNetworkUpdate?: boolean } = {}

      Returns Promise<Client>