@hashgraph/sdk
    Preparing search index...

    Class WebClient

    Represents a client for interacting with the Hedera network over the web. The WebClient class extends the base Client class and provides methods for configuring and managing connections to the Hedera network, including setting the network type (mainnet, testnet, previewnet) and handling transactions and queries.

    Hierarchy

    • default
      • WebClient
    Index

    Constructors

    Properties

    _isUpdatingNetwork: boolean
    _logger: null | Logger

    Logger

    _maxAttempts: null | number
    _realm: number
    _shard: number
    _timer: Timeout

    Accessors

    • get defaultRegenerateTransactionId(): boolean

      Returns boolean

    • 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 networkUpdatePeriod(): number

      Returns number

    • get nodeMaxReadmitPeriod(): number

      Returns number

    • get nodeMinReadmitPeriod(): number

      Returns number

    • get requestTimeout(): null | number

      Returns null | number

    Methods

    • Returns (address: string) => any

    • Returns (address: string) => WebChannel

    • Returns null | ClientOperator

    • Returns boolean

    • Returns boolean

    • Set the maximum payment allowable for queries.

      Parameters

      • defaultMaxQueryPayment: Hbar

      Returns Client<WebChannel, any>

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

      Parameters

      • defaultMaxTransactionFee: Hbar

      Returns WebClient

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

      Parameters

      • defaultRegenerateTransactionId: boolean

      Returns WebClient

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

      The client instance for method chaining

    • Parameters

      • maxQueryPayment: Hbar

      Returns Client<WebChannel, any>

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

    • Parameters

      • maxTransactionFee: Hbar

      Returns WebClient

      • Use setDefaultMaxTransactionFee() instead Set the maximum fee to be paid for transactions executed by this 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 WebClient

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

    • Parameters

      • signOnDemand: boolean

      Returns void

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

    • Construct a client configured to use mirror nodes. This will query the address book to get the network nodes.

      Parameters

      • mirrorNetwork: string | string[]

      Returns Promise<WebClient>

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

      Parameters

      • network: string

      Returns Promise<WebClient>

    • 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: string | { [key: string]: string | AccountId }

      Returns WebClient