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:string
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.string
Bech32-formatted Initia wallet address of the connected account. Returns an
empty string when not connected.
string
Hex-encoded Ethereum-compatible address of the connected account. Returns an
empty string when not connected.
string | null | undefined
Optional username linked to the account. Returns
null if no username is
associated, or undefined before the query has produced a value.OfflineAminoSigner
Offline signer for Cosmos transactions.
boolean
Whether a wallet is currently connected.
boolean
Whether the InterwovenKit drawer/modal is currently open.
UI Controls
The hook provides methods for controlling wallet-related UI components:() => void
Opens a drawer for connecting an external wallet.
() => void
Opens the main wallet drawer showing balances for the connected account.
(defaultValues?: Partial<FormValues>) => void
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.
() => void
Disconnects the current wallet connection.
Bridge Form Values
TheopenBridge method accepts optional FormValues to pre-populate the bridge
form:
string
Source chain ID for the bridge transaction.
string
Source token denomination to bridge from.
string
Destination chain ID for the bridge transaction.
string
Destination token denomination to bridge to.
string
Initial bridge amount (use human-readable values, e.g., “1” for 1 INIT).
string
Sender address.
string
Recipient address.
string
Slippage tolerance percentage.
string
Optional Cosmos wallet name.
Deposit and Withdraw Example
Transaction Methods
The hook provides utilities for estimating, simulating, signing, and sending transactions on the blockchain:(tx: Pick<TxRequest, 'messages' | 'memo' | 'chainId'>) => Promise<number>
Estimates the gas required for a transaction before execution.
(tx: Pick<TxRequest, 'messages' | 'memo' | 'chainId'>) => Promise<unknown>
Simulates a transaction without broadcasting, returning the transaction
result.
(tx: TxRequest) => Promise<string>
Signs and broadcasts a transaction, returning the transaction hash immediately
without waiting for block inclusion. Shows transaction approval UI before
signing.
(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).(tx: TxParams) => Promise<string>
Signs and broadcasts a transaction with pre-calculated fee, returning the
transaction hash immediately without waiting for block inclusion. Does not
show UI.
(tx: TxParams, timeoutMs?: number, intervalMs?: number) => Promise<DeliverTxResponse>
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).(options: WaitForTxOptions) => Promise<IndexedTx>
Polls for transaction confirmation on-chain using a transaction hash.
Transaction Request Interface
TheTxRequest interface defines parameters for transaction operations that
include gas estimation:
EncodeObject[]
required
Array of encoded transaction messages to include in the transaction.
string
Optional memo to attach to the transaction.
string
Target chain ID for the transaction. Defaults to the provider’s
defaultChainId.number
default:"1.4"
Multiplier applied to the estimated gas amount for safety margin.
number
Explicit gas limit for the transaction. If provided, skips gas estimation.
Coin[] | null
Explicit gas prices. If provided, skips the fee denomination selection UI.
Coin[]
Coins to spend for the transaction fee.
Transaction Params Interface
TheTxParams interface defines parameters for transactions with pre-calculated
fees:
EncodeObject[]
required
Array of encoded transaction messages to include in the transaction.
string
Optional memo to attach to the transaction.
string
Target chain ID for the transaction. Defaults to the provider’s
defaultChainId.StdFee
required
Pre-calculated fee for the transaction.
Transaction Confirmation Options
TheWaitForTxOptions interface defines parameters for tracking transaction
confirmation:
string
required
Hash of the transaction to track for confirmation.
string
Chain ID where the transaction was broadcast.
number
default:"30000"
Maximum time in milliseconds to wait for transaction confirmation before
failing. Defaults to 30000 (30 seconds).
number
default:"500"
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:Record<string, Date | null | undefined>
Expiration dates for AutoSign permissions by chain ID.
Record<string, boolean>
Whether AutoSign is enabled for each chain.
boolean
Whether AutoSign status is being loaded.
(chainId?: string) => Promise<void>
Opens UI to enable AutoSign for a chain. Optionally specify a chain ID, or
defaults to the provider’s
defaultChainId if omitted.(chainId?: string) => Promise<void>
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.