Overview
TheuseInterwovenKit hook provides access to wallet connection state, account
information, UI controls, transaction utilities, and AutoSign functionality for
interacting with the Initia blockchain.
This hook must be used within a component wrapped by
InterwovenKitProvider
to access wallet functionality. For simple reads, prefer smaller hooks
(useAddress, useUsernameQuery) to avoid overhead.Prerequisites
- Must be rendered within
InterwovenKitProvider. - Must be used within a React Query
QueryClientProvider. - Must be used within a wagmi
WagmiProvider. - Client-only (no SSR): Put this in a
use clientprovider tree, or use a dynamic import in Next.js.
Quickstart
This example assumes providers are already set up. For complete setup
configurations, see Provider Setup.
Account Information
The hook provides multiple address formats and account details for the currently connected wallet:Current address in either Bech32 or hex format, depending on the configured
chain type (hex for
minievm, bech32 for others). Returns an empty string
when not connected.Bech32-formatted Initia wallet address of the connected account. Returns an
empty string when not connected.
Hex-encoded Ethereum-compatible address of the connected account. Returns an
empty string when not connected.
Optional username linked to the account. Returns
null if no username is
associated, or undefined before the query has produced a value.Offline signer for Cosmos transactions.
Whether a wallet is currently connected.
Whether the InterwovenKit drawer/modal is currently open.
UI Controls
The hook provides methods for controlling wallet-related UI components:Opens a drawer for connecting an external wallet.
Opens the main wallet drawer showing balances for the connected account.
Opens the bridge drawer to onboard assets with optional pre-populated values.
Disconnects the current wallet connection.
Bridge Form Values
TheopenBridge method accepts optional FormValues to pre-populate the bridge
form:
Source chain ID for the bridge transaction.
Source token denomination to bridge from.
Destination chain ID for the bridge transaction.
Destination token denomination to bridge to.
Initial bridge amount (use human-readable values, e.g., “1” for 1 INIT).
Sender address.
Recipient address.
Slippage tolerance percentage.
Optional Cosmos wallet name.
Transaction Methods
The hook provides utilities for estimating, simulating, signing, and sending transactions on the blockchain:Estimates the gas required for a transaction before execution.
Simulates a transaction without broadcasting, returning the transaction
result.
Signs and broadcasts a transaction, returning the transaction hash immediately
without waiting for block inclusion. Shows transaction approval UI before
signing.
requestTxBlock
(tx: TxRequest, timeoutMs?: number, intervalMs?: number) => Promise<DeliverTxResponse>
Signs, broadcasts, and waits for block inclusion, returning the complete
transaction response. Shows transaction approval UI before signing. Defaults
to
timeoutMs: 30000 (30 seconds) and intervalMs: 500 (0.5 seconds).Signs and broadcasts a transaction with pre-calculated fee, returning the
transaction hash immediately without waiting for block inclusion. Does not
show UI.
Signs, broadcasts, and waits for block inclusion with pre-calculated fee,
returning the complete transaction response. Does not show UI. Defaults to
timeoutMs: 30000 (30 seconds) and intervalMs: 500 (0.5 seconds).Polls for transaction confirmation on-chain using a transaction hash.
Transaction Request Interface
TheTxRequest interface defines parameters for transaction operations that
include gas estimation:
Array of encoded transaction messages to include in the transaction.
Optional memo to attach to the transaction.
Target chain ID for the transaction. Defaults to the provider’s
defaultChainId.Multiplier applied to the estimated gas amount for safety margin.
Explicit gas limit for the transaction. If provided, skips gas estimation.
Explicit gas prices. If provided, skips the fee denomination selection UI.
Coins to spend for the transaction fee.
Transaction Params Interface
TheTxParams interface defines parameters for transactions with pre-calculated
fees:
Array of encoded transaction messages to include in the transaction.
Optional memo to attach to the transaction.
Target chain ID for the transaction. Defaults to the provider’s
defaultChainId.Pre-calculated fee for the transaction.
Transaction Confirmation Options
TheWaitForTxOptions interface defines parameters for tracking transaction
confirmation:
Hash of the transaction to track for confirmation.
Chain ID where the transaction was broadcast.
Maximum time in milliseconds to wait for transaction confirmation before
failing. Defaults to 30000 (30 seconds).
Polling interval in milliseconds for checking transaction status. Defaults to
500 (0.5 seconds).
Transaction Examples
AutoSign
The hook provides AutoSign state and control methods for automatic transaction signing:Expiration dates for AutoSign permissions by chain ID.
Whether AutoSign is enabled for each chain.
Whether AutoSign status is being loaded.
Opens UI to enable AutoSign for a chain. Optionally specify a chain ID, or
defaults to the provider’s
defaultChainId if omitted.Disables AutoSign for a chain. Optionally specify a chain ID, or defaults to
the provider’s
defaultChainId if omitted.Notes
- Transaction helpers throw
MoveErroron Move VM errors (see MoveError). requestTx*methods show a transaction approval UI before signing.submitTx*methods sign and broadcast directly without UI.waitForTxConfirmationpolls until confirmed or timeout.
Type reference (advanced)
OfflineAminoSigner, EncodeObject, Coin, StdFee,
DeliverTxResponse, and IndexedTx are from external packages. See
@cosmjs/amino, @cosmjs/proto-signing, cosmjs-types, @cosmjs/stargate for
details.