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.UI Controls
The hook provides methods for controlling wallet-related UI components:Opens the bridge drawer to onboard assets with optional pre-populated values.
(params: { denoms: string[]; chainId?: string; srcOptions?: AssetOption[]; recipientAddress?: string }) => void
Opens a modal to deposit assets from another chain to the current chain.
(params: { denoms: string[]; chainId?: string; dstOptions?: AssetOption[]; recipientAddress?: string }) => void
Opens a modal to withdraw assets from the current chain to another chain.
Bridge Form Values
TheopenBridge method accepts optional FormValues to pre-populate the bridge
form:
Deposit and Withdraw Example
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.
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:
Transaction Params Interface
TheTxParams interface defines parameters for transactions with pre-calculated
fees:
Transaction Confirmation Options
TheWaitForTxOptions interface defines parameters for tracking transaction
confirmation:
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: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.