useWallet
API reference for the useWallet hook.
useWallet
The useWallet hook provides methods to interact with the wallet.
import { useWallet } from '@lazorkit/wallet';connect
Trigger the connection flow. If the user has previously connected, this will try to restore their session automatically without showing a pop-up.
Usage
const { connect } = useWallet();
await connect({ feeMode: 'paymaster' });Arguments
| Property | Type | Required | Description |
|---|---|---|---|
options | object | No | Connection options. |
options.feeMode | 'paymaster' | 'user' | No | Fee payment mode (default: 'paymaster'). |
Returns
Promise<WalletInfo> - The connected wallet info object.
disconnect
Signs the user out and wipes any cached session data from local storage.
Usage
const { disconnect } = useWallet();
await disconnect();Returns
Promise<void>
signMessage
Requests the user to sign a plain text message using their passkey. This is useful for verifying ownership without sending a transaction.
Usage
const { signMessage } = useWallet();
const message = 'Hello LazorKit';
const { signature } = await signMessage(message);Arguments
| Property | Type | Required | Description |
|---|---|---|---|
message | string | Yes | The message content to sign. |
Returns
Promise<{ signature: string, signedPayload: string }>
signAndSendTransaction
The core method for executing on-chain actions. It handles signing the transaction with the user's passkey and submitting it via the Paymaster (bundler).
Usage
const { signAndSendTransaction } = useWallet();
const signature = await signAndSendTransaction({
instructions: [/* ... */],
transactionOptions: {
feeToken: 'USDC',
computeUnitLimit: 500_000
}
});Arguments
| Property | Type | Required | Description |
|---|---|---|---|
payload | object | Yes | Transaction payload. |
payload.instructions | TransactionInstruction[] | Yes | Array of Solana instructions. |
payload.transactionOptions | object | No | Configuration options. |
transactionOptions.feeToken | string | No | Token address for gas fees (e.g. USDC). |
transactionOptions.computeUnitLimit | number | No | Max compute units for the transaction. |
transactionOptions.addressLookupTableAccounts | AddressLookupTableAccount[] | No | Lookup tables for versioned (v0) transactions. |
transactionOptions.clusterSimulation | 'devnet' | 'mainnet' | No | Network to use for simulation. |
Returns
Promise<string> - The transaction signature.