# JAW Wagmi Integration
> Wagmi connector and React hooks for integrating JAW smart accounts into React/Next.js applications.
**This file is self-contained.** You have everything needed to help with this topic. Do NOT fetch other llms-*.txt files unless the user explicitly asks about a different topic.
## Key Info
- **Package:** `@jaw.id/wagmi`
- **Install:** `npm install @jaw.id/wagmi wagmi @tanstack/react-query`
- **Dashboard:** https://dashboard.jaw.id
- **Docs:** https://docs.jaw.id
## Quick Example
```typescript
import { jaw } from '@jaw.id/wagmi';
import { createConfig, http } from 'wagmi';
import { base } from 'wagmi/chains';
const config = createConfig({
chains: [base],
connectors: [
jaw({
apiKey: 'YOUR_API_KEY',
appName: 'My App',
}),
],
transports: { [base.id]: http() },
});
```
---
## Wagmi Integration
Source: https://docs.jaw.id/wagmi/index
## Wagmi Integration
The `@jaw.id/wagmi` package provides a Wagmi-compatible connector and React hooks for integrating JAW smart accounts into your dApp.
### Installation
:::code-group
```bash [npm]
npm install @jaw.id/wagmi wagmi @tanstack/react-query
```
```bash [pnpm]
pnpm add @jaw.id/wagmi wagmi @tanstack/react-query
```
```bash [yarn]
yarn add @jaw.id/wagmi wagmi @tanstack/react-query
```
```bash [bun]
bun add @jaw.id/wagmi wagmi @tanstack/react-query
```
:::
### Quick Start
#### 1. Configure the Connector
```typescript
import { createConfig, http } from 'wagmi';
import { mainnet, base, baseSepolia } from 'wagmi/chains';
import { jaw } from '@jaw.id/wagmi';
export const config = createConfig({
chains: [mainnet, base, baseSepolia],
connectors: [
jaw({
apiKey: 'YOUR_API_KEY',
appName: 'My App',
appLogoUrl: 'https://example.com/logo.png',
}),
],
transports: {
[mainnet.id]: http(),
[base.id]: http(),
[baseSepolia.id]: http(),
},
});
```
#### 2. Set Up Providers
```tsx
import { WagmiProvider } from 'wagmi';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
const queryClient = new QueryClient();
function App({ children }) {
return (
{children}
);
}
```
#### 3. Use the Hooks
```tsx
import { useAccount, useSendTransaction } from 'wagmi';
import { useConnect, useDisconnect } from '@jaw.id/wagmi';
function WalletButton() {
const { address, isConnected } = useAccount();
const { mutate: connect, isPending } = useConnect();
const { mutate: disconnect } = useDisconnect();
if (isConnected) {
return (
Connected: {address}
);
}
return (
);
}
```
### Standard Wagmi Hooks
All standard wagmi hooks work with the JAW connector. Use them directly from `wagmi`:
```typescript
import {
useAccount,
useSendTransaction,
useSignMessage,
useSignTypedData,
useSwitchChain,
useSendCalls,
useWriteContract,
useBalance,
} from 'wagmi';
```
\| Hook | Description |
\| -------------------- | ----------------------------------------- |
\| `useAccount` | Get connected account address and status |
\| `useSendTransaction` | Send a single transaction |
\| `useSignMessage` | Sign a personal message (EIP-191) |
\| `useSignTypedData` | Sign typed data (EIP-712) |
\| `useSwitchChain` | Switch to a different chain |
\| `useSendCalls` | Send atomic batch transactions (EIP-5792) |
\| `useWriteContract` | Call a contract write function |
\| `useBalance` | Get ETH or token balance |
:::info
When a paymaster is configured, transactions sent via `useSendTransaction`, `useSendCalls`, and `useWriteContract` are automatically sponsored (gasless).
:::
### JAW Hooks
For JAW-specific features, import hooks directly from `@jaw.id/wagmi`:
```typescript
// Direct import (recommended)
import { useConnect, useDisconnect, useGrantPermissions } from '@jaw.id/wagmi';
// Alternative: namespace import
import { Hooks } from '@jaw.id/wagmi';
const { mutate } = Hooks.useConnect();
```
\| Hook | Description |
\| --------------------------------------------------- | ---------------------------------------------------------- |
\| [useConnect](/wagmi/useConnect) | Connect with optional capabilities (SIWE, subnames) |
\| [useDisconnect](/wagmi/useDisconnect) | Disconnect and clean up session |
\| [useSign](/wagmi/useSign) | Unified signing (personal + typed data) with chain support |
\| [useGrantPermissions](/wagmi/useGrantPermissions) | Grant permissions to a spender |
\| [usePermissions](/wagmi/usePermissions) | Query current permissions |
\| [useRevokePermissions](/wagmi/useRevokePermissions) | Revoke a permission |
\| [useGetAssets](/wagmi/useGetAssets) | Query token balances across chains |
\| [useCapabilities](/wagmi/useCapabilities) | Query wallet capabilities per chain |
\| [useAddFunds](/wagmi/useAddFunds) | Show the receive screen (chains, QR, address) |
### Connector
\| Function | Description |
\| ------------------- | -------------------------------- |
\| [jaw()](/wagmi/jaw) | Create a JAW connector for Wagmi |
### Why Use JAW Hooks?
#### useConnect vs wagmi's useConnect
\| Feature | `wagmi.useConnect` | `@jaw.id/wagmi.useConnect` |
\| ------------------------- | ------------------ | -------------------------- |
\| Basic connection | Yes | Yes |
\| Request SIWE signature | No | Yes |
\| Request subname issuance | No | Yes |
\| Uses `wallet_connect` RPC | No | When capabilities provided |
Use `@jaw.id/wagmi`'s `useConnect` when you need capabilities like Sign-In with Ethereum or ENS subnames during connection.
#### useDisconnect vs wagmi's useDisconnect
Both work the same way. `@jaw.id/wagmi`'s version is provided for consistency.
### Actions (Non-React)
For vanilla JavaScript or other frameworks, use actions directly:
```typescript
import { connect, disconnect, grantPermissions } from '@jaw.id/wagmi';
// Use with your wagmi config
await connect(config, { connector: jawConnector });
```
### Related
* [Configuration](/configuration) - Full configuration options
* [Provider API](/api-reference) - Direct provider methods
* [Account API](/account) - Low-level Account class
## Connector
Source: https://docs.jaw.id/wagmi/jaw
## Connector
Create a JAW connector for your [Wagmi Config](https://wagmi.sh/core/api/createConfig).
```typescript
import { createConfig, http } from 'wagmi';
import { mainnet } from 'wagmi/chains';
import { jaw } from '@jaw.id/wagmi';
const config = createConfig({
chains: [mainnet],
connectors: [jaw({ apiKey: 'YOUR_API_KEY' })],
transports: {
[mainnet.id]: http(),
},
});
```
### Signature
```typescript
function jaw(parameters: JawParameters): Connector;
```
### Parameters
#### apiKey
Type: `string` (required)
Your JAW API key. Get one at [JAW Dashboard](https://dashboard.jaw.id/).
#### appName
Type: `string`
Display name for your application. Shown in the authentication UI.
#### appLogoUrl
Type: `string | null`
URL to your application's logo. Used in authentication UI.
#### defaultChainId
Type: `number`
Default chain ID to use on first connection.
#### ens
Type: `string`
ENS domain for issuing subnames (e.g., `'myapp.eth'`). When configured, users can receive a subname during account creation.
#### preference
Type: `JawProviderPreference`
Configuration for authentication behavior.
```typescript
interface JawProviderPreference {
/** Authentication mode (default: Mode.CrossPlatform) */
mode?: Mode.CrossPlatform | Mode.AppSpecific;
/** Whether to show testnet chains (default: false) */
showTestnets?: boolean;
/** UI handler for app-specific mode */
uiHandler?: UIHandler;
}
```
#### paymasters
Type: `Record }>`
Custom paymaster configuration by chain ID for gas sponsorship. See [paymasters](/configuration/paymasters) for details.
### Returns
`Connector` - A Wagmi-compatible connector instance.
### Connector Properties
The returned connector has these Wagmi-standard properties:
\| Property | Value |
\| -------- | --------------- |
\| `id` | `'jaw'` |
\| `name` | `'JAW'` |
\| `type` | `'jaw'` |
\| `rdns` | `'keys.jaw.id'` |
### Example
```typescript
import { createConfig, http } from 'wagmi';
import { mainnet, base, baseSepolia } from 'wagmi/chains';
import { jaw } from '@jaw.id/wagmi';
const config = createConfig({
chains: [mainnet, base, baseSepolia],
connectors: [
jaw({
apiKey: 'YOUR_API_KEY',
appName: 'My DApp',
appLogoUrl: 'https://example.com/logo.png',
defaultChainId: 8453, // Base
ens: 'myapp.eth',
preference: {
showTestnets: true,
},
paymasters: {
8453: { url: 'https://my-paymaster.com/base' },
84532: { url: 'https://my-paymaster.com/base-sepolia' },
},
}),
],
transports: {
[mainnet.id]: http(),
[base.id]: http(),
[baseSepolia.id]: http(),
},
});
```
### Related
* [Configuration](/configuration) - Full configuration reference
* [useConnect](/wagmi/useConnect) - Connect with capabilities
* [mode](/configuration/mode) - Authentication mode and UI handler options
## useAddFunds
Source: https://docs.jaw.id/wagmi/useAddFunds
## useAddFunds
Hook to open the receive screen: the chains the account accepts deposits on, a QR code, and the address itself.
**Type:** `hook`
### Import
```typescript
import { useAddFunds } from '@jaw.id/wagmi';
```
### Signature
```typescript
function useAddFunds(parameters?: { config?: Config; mutation?: UseMutationParameters }): UseMutationResult;
```
### Parameters
#### config
Type: `Config` (optional)
Wagmi config. If not provided, uses the config from `WagmiProvider`.
#### mutation
Type: `UseMutationParameters` (optional)
TanStack React Query mutation options.
### Returns
Returns a TanStack React Query mutation result:
\| Property | Type | Description |
\| ------------- | ---------- | ------------------------------------------ |
\| `mutate` | `function` | Function to open the receive screen |
\| `mutateAsync` | `function` | Async version of mutate |
\| `data` | `null` | Always null — see below |
\| `isPending` | `boolean` | Whether the screen is open |
\| `isSuccess` | `boolean` | Whether the screen was shown and dismissed |
\| `isError` | `boolean` | Whether the request failed |
\| `error` | `Error` | Error if the request failed |
#### data
Always `null`. Deposits land off-app, so the wallet has no outcome to report: a resolved mutation means the screen was shown and closed, not that funds arrived.
### Mutation Variables
When calling `mutate()`, you can optionally pass an object with the following properties:
#### chainId (optional)
Type: `number`
Chain the QR code pins via EIP-681, and on its own the only chain offered — `chainId: base.id` shows Base and nothing else. Defaults to the first entry of `chains`, then the connected chain. Nothing is sent, so the connector does not need to be on this chain.
#### chains (optional)
Type: `number[]`
Chains your app accepts deposits on. The chain row on the screen shows exactly these instead of every chain the address works on.
Worth sending whenever your app only credits deposits on certain networks: the default is true of a smart account, but it invites a deposit your app will not see. Order it with your primary chain first — that is the one the QR code pins when no `chainId` comes with it. An empty array is rejected rather than read as "no preference".
If you pass `chainId` as well, it must be one of `chains` — a QR code pinned to a chain your own list excludes is rejected rather than resolved silently.
#### address (optional)
Type: `Address`
Which connected account to act as, as in the other actions. This is **not** a destination: the address funds are received at is always the connected account, resolved by the wallet from the session.
#### connector (optional)
Type: `Connector`
Specific connector to use. If omitted, uses the active connector.
### Examples
#### Basic Usage
```tsx
import { useAccount } from 'wagmi';
import { useAddFunds } from '@jaw.id/wagmi';
function AddFundsButton() {
const { isConnected } = useAccount();
const { mutate: addFunds, isPending } = useAddFunds();
if (!isConnected) return null;
return (
);
}
```
#### Pin the QR Code to a Chain
```tsx
import { useAddFunds } from '@jaw.id/wagmi';
import { base } from 'viem/chains';
function FundOnBase() {
const { mutate: addFunds } = useAddFunds();
return ;
}
```
#### Narrow the Chains You Accept
```tsx
import { useAddFunds } from '@jaw.id/wagmi';
import { base, optimism } from 'viem/chains';
function FundOnBaseOnly() {
const { mutate: addFunds } = useAddFunds();
// One chain: the row shows Base alone, and the QR code pins it.
return ;
}
function FundOnEither() {
const { mutate: addFunds } = useAddFunds();
// Several: the row shows exactly these two, Base first and pinned.
return ;
}
```
#### With Callbacks
```tsx
import { useAccount } from 'wagmi';
import { useAddFunds, useGetAssets } from '@jaw.id/wagmi';
function FundAndRefresh() {
const { address } = useAccount();
const { refetch } = useGetAssets({ account: address });
const { mutate: addFunds } = useAddFunds({
mutation: {
// Fires when the screen closes, which is not the same as funds landing.
onSuccess: () => refetch(),
},
});
return ;
}
```
### Behavior
* Opens the receive screen: the address, its ENS name and avatar when they resolve, and the chains it accepts deposits on — the ones in `chains`, or every mainnet the address works on when you send none
* The QR code encodes an [EIP-681](https://eips.ethereum.org/EIPS/eip-681) payment request, `ethereum:@`, so a scanner selects the network itself
* Resolves when the user closes the screen. Closing is a normal finish, not a rejection
* Reads no balances and polls for nothing
### Important Notes
:::info
**No arrival signal**: receiving has no completion event. The money usually arrives after the user has closed the screen and gone to an exchange, and an inbound transfer cannot be attributed to a particular request. Refetch balances with [useGetAssets](/wagmi/useGetAssets) rather than treating `onSuccess` as an arrival.
:::
:::warning
**The destination cannot be passed in**: funds are always received at the connected account, resolved by the wallet. The `address` variable selects which connected account to act as, and is never a destination the caller can name.
:::
### Related
* [useGetAssets](/wagmi/useGetAssets) - Read token balances after funding
* [useCapabilities](/wagmi/useCapabilities) - Chains and their metadata
* [wallet\_addFunds](/api-reference/wallet_addFunds) - RPC method reference
## useCapabilities
Source: https://docs.jaw.id/wagmi/useCapabilities
## useCapabilities
Hook to get wallet capabilities for supported chains. Implements EIP-5792 for capability discovery.
**Type:** `hook`
### Import
```typescript
import { useCapabilities } from '@jaw.id/wagmi';
```
### Signature
```typescript
function useCapabilities(parameters?: {
address?: Address;
chainId?: number;
connector?: Connector;
chainFilter?: Hex[];
config?: Config;
query?: UseQueryParameters;
}): UseQueryResult;
```
### Parameters
#### address
Type: `Address` (optional)
Specific account address to get capabilities for. When provided, allows querying capabilities without a connected wallet.
#### chainId
Type: `number` (optional)
Specific chain ID. Defaults to current chain.
#### connector
Type: `Connector` (optional)
Specific connector to use. Defaults to active connector.
#### chainFilter
Type: `Hex[]` (optional)
Array of chain IDs (hex format) to filter capabilities. If not provided, returns capabilities for all supported chains.
#### config
Type: `Config` (optional)
Wagmi config. If not provided, uses the config from `WagmiProvider`.
#### query
Type: `UseQueryParameters` (optional)
TanStack React Query options (excluding `gcTime` and `staleTime` which are managed internally).
### Returns
Returns a TanStack React Query result:
\| Property | Type | Description |
\| ------------ | -------------------------------------- | ------------------------------------ |
\| `data` | `Record>` | Capabilities keyed by chain ID (hex) |
\| `isLoading` | `boolean` | Whether initial load is in progress |
\| `isFetching` | `boolean` | Whether any fetch is in progress |
\| `isSuccess` | `boolean` | Whether query succeeded |
\| `isError` | `boolean` | Whether query failed |
\| `error` | `Error` | Error if query failed |
\| `refetch` | `function` | Manually refetch capabilities |
#### data
When successful, `data` is an object of capabilities keyed by chain ID (hex):
```typescript
type WalletGetCapabilitiesResponse = Record>;
// Example structure:
{
"0x1": {
"atomicBatch": { "supported": true },
"atomic": { "status": "supported" },
"paymasterService": { "supported": true },
"permissions": { "supported": true },
"feeToken": {
"supported": true,
"tokens": [...]
}
},
"0x2105": {
// Base chain capabilities
}
}
```
### Behavior
1. **Works without connection** when `address` parameter is provided
2. **Auto-enables** when wallet is connected or address is provided
3. **Caches results** for optimal performance
4. **Returns all chains** by default, use `chainFilter` to limit
### Examples
#### Basic Usage
```tsx
import { useAccount } from 'wagmi';
import { useCapabilities } from '@jaw.id/wagmi';
function CapabilitiesDisplay() {
const { isConnected } = useAccount();
const { data: capabilities, isLoading } = useCapabilities();
if (!isConnected) return
);
}
```
### Related
* [wallet\_getAssets](/api-reference/wallet_getAssets) - RPC method reference
* [usePermissions](/wagmi/usePermissions) - Query permissions
## useGetCallsHistory
Source: https://docs.jaw.id/wagmi/useGetCallsHistory
## useGetCallsHistory
Hook to get the call history for an account. Can be called with or without a connected wallet.
**Type:** `hook`
### Import
```typescript
import { useGetCallsHistory } from '@jaw.id/wagmi';
```
### Signature
```typescript
function useGetCallsHistory(parameters?: {
address?: Address;
chainId?: number;
connector?: Connector;
index?: number;
limit?: number;
sort?: 'asc' | 'desc';
config?: Config;
query?: UseQueryParameters;
}): UseQueryResult;
```
### Parameters
#### address
Type: `Address` (optional)
Specific account address to get history for. If not provided when connected, uses the connected account's address. **Required when not connected.**
#### chainId
Type: `number` (optional)
Chain ID to filter results by. When provided, only returns history items for that chain.
#### connector
Type: `Connector` (optional)
Specific connector to use. Defaults to active connector or JAW connector if available.
#### index
Type: `number` (optional)
Index cursor for pagination. Use the `index` from the last item in the previous response to fetch the next page.
#### limit
Type: `number` (optional)
Maximum number of bundles to return. Defaults to 20.
#### sort
Type: `'asc' | 'desc'` (optional)
Sort direction based on index. Defaults to `'desc'` (newest first).
#### config
Type: `Config` (optional)
Wagmi config. If not provided, uses the config from `WagmiProvider`.
#### query
Type: `UseQueryParameters` (optional)
TanStack React Query options (excluding `gcTime` and `staleTime` which are managed internally).
### Returns
Returns a TanStack React Query result:
\| Property | Type | Description |
\| ------------ | -------------------- | ----------------------------------- |
\| `data` | `CallsHistoryItem[]` | Array of call history items |
\| `isLoading` | `boolean` | Whether initial load is in progress |
\| `isFetching` | `boolean` | Whether any fetch is in progress |
\| `isSuccess` | `boolean` | Whether query succeeded |
\| `isError` | `boolean` | Whether query failed |
\| `error` | `Error` | Error if query failed |
\| `refetch` | `function` | Manually refetch history |
#### data
When successful, `data` is an array of call history items:
```typescript
interface CallsHistoryItem {
/** userOpHash */
id: `0x${string}`;
/** Auto-incrementing index per address (for cursor pagination) */
index: number;
/** Wallet address */
address: `0x${string}`;
/** 100=Pending, 200=Completed, 500=Onchain Revert */
status: number;
/** Unix timestamp in seconds */
timestamp: number;
/** Chain ID */
chainId: number;
/** Transaction hash (null when pending) */
transactionHash: `0x${string}` | null;
}
```
### Behavior
1. **Works without connection** when `address` is provided
2. **Uses connected address** automatically when wallet is connected
3. **Caches for 30 seconds** before becoming stale
4. **Supports pagination** via `index` cursor
### Examples
#### Basic Usage (Connected)
```tsx
import { useAccount } from 'wagmi';
import { useGetCallsHistory } from '@jaw.id/wagmi';
function TransactionHistory() {
const { isConnected } = useAccount();
const { data: history, isLoading } = useGetCallsHistory();
if (!isConnected) return
);
}
```
### Related
* [useGrantPermissions](/wagmi/useGrantPermissions) - Grant new permissions
* [useRevokePermissions](/wagmi/useRevokePermissions) - Revoke a permission
* [wallet\_getPermissions](/api-reference/wallet_getPermissions) - RPC method reference
## useRevokePermissions
Source: https://docs.jaw.id/wagmi/useRevokePermissions
## useRevokePermissions
Hook to revoke an active permission by its ID. This permanently disables the permission, preventing the spender from executing any further calls.
**Type:** `hook`
### Import
```typescript
import { useRevokePermissions } from '@jaw.id/wagmi';
```
### Signature
```typescript
function useRevokePermissions(parameters?: { config?: Config; mutation?: UseMutationParameters }): UseMutationResult;
```
### Parameters
#### config
Type: `Config` (optional)
Wagmi config. If not provided, uses the config from `WagmiProvider`.
#### mutation
Type: `UseMutationParameters` (optional)
TanStack React Query mutation options.
### Returns
Returns a TanStack React Query mutation result:
\| Property | Type | Description |
\| ------------- | ----------------------------- | --------------------------------- |
\| `mutate` | `function` | Function to revoke permission |
\| `mutateAsync` | `function` | Async version of mutate |
\| `data` | `RevokePermissionApiResponse` | Revocation result |
\| `isPending` | `boolean` | Whether revocation is in progress |
\| `isSuccess` | `boolean` | Whether revocation succeeded |
\| `isError` | `boolean` | Whether revocation failed |
\| `error` | `Error` | Error if revocation failed |
#### data
When successful, `data` contains:
```typescript
interface RevokePermissionApiResponse {
/** Indicates if the permission was revoked successfully */
success: boolean;
/** True when the relay does not see the on-chain revoke yet; it removes the permission once it does */
pending?: boolean;
}
```
### Mutation Variables
When calling `mutate()`, pass an object with the following properties:
#### id (required)
Type: `Hex` (e.g., `` `0x${string}` ``)
The permission ID (hash) to revoke. You can obtain this from:
* The `permissionId` field returned when granting a permission
* The `permissionId` field from permissions returned by `usePermissions()`
```typescript
// From grant response
const { data } = useGrantPermissions();
const permissionId = data.permissionId; // '0x1234...'
// From permissions list
const { data: permissions } = usePermissions();
const permissionId = permissions[0].permissionId; // '0x1234...'
```
#### address (optional)
Type: `Address`
Specific account address to revoke the permission for. Defaults to the connected account.
```typescript
revoke({
id: '0x1234...',
address: '0xSpecificAccount...', // Optional: specify which account
});
```
#### chainId (optional)
Type: `number`
Target chain ID where the permission exists. Defaults to the connected chain.
:::warning
**Chain-Specific**: Permissions are chain-specific. Make sure you're revoking on the correct chain where the permission was granted.
:::
```typescript
revoke({
id: '0x1234...',
chainId: 8453, // Revoke on Base
});
```
#### connector (optional)
Type: `Connector`
Specific connector to use. Defaults to the active connector.
#### capabilities (optional)
Type: `RequestCapabilities`
Optional capabilities for the revocation transaction, such as paymaster service for sponsored (gasless) revocation.
```typescript
interface RequestCapabilities {
/** Paymaster service for sponsored transactions */
paymasterService?: {
/** URL of the paymaster service (ERC-7677 compliant) */
url: string;
/** Optional context for the paymaster */
context?: Record;
};
}
```
```typescript
// Sponsored revocation (gasless)
revoke({
id: '0x1234...',
capabilities: {
paymasterService: {
url: 'https://paymaster.example.com',
},
},
});
```
### Examples
#### Basic Usage
```tsx
import { useRevokePermissions } from '@jaw.id/wagmi';
function RevokeButton({ permissionId }: { permissionId: `0x${string}` }) {
const { mutate: revoke, isPending } = useRevokePermissions();
return (
);
}
```
#### With Confirmation Dialog
```tsx
import { useState } from 'react';
import { useRevokePermissions } from '@jaw.id/wagmi';
function RevokeWithConfirmation({ permission }) {
const { mutate: revoke, isPending } = useRevokePermissions();
const [showConfirm, setShowConfirm] = useState(false);
const handleRevoke = () => {
revoke(
{ id: permission.permissionId },
{
onSuccess: () => {
setShowConfirm(false);
// Permission list will auto-update via usePermissions
},
}
);
};
if (showConfirm) {
return (
);
}
```
#### Revoke on Specific Chain
```tsx
import { useRevokePermissions } from '@jaw.id/wagmi';
import { base } from 'wagmi/chains';
function RevokeOnBase({ permissionId }) {
const { mutate: revoke, isPending } = useRevokePermissions();
const handleRevoke = () => {
revoke({
id: permissionId,
chainId: base.id, // Revoke on Base chain
});
};
return (
);
}
```
#### Sponsored Revocation (Gasless)
```tsx
import { useRevokePermissions } from '@jaw.id/wagmi';
function SponsoredRevoke({ permissionId }) {
const { mutate: revoke, isPending } = useRevokePermissions();
const handleRevoke = () => {
revoke({
id: permissionId,
capabilities: {
paymasterService: {
url: 'https://your-paymaster.com/api',
},
},
});
};
return (
);
}
```
### Important Notes
:::warning
**Revocation is Permanent**: Once a permission is revoked, it cannot be restored. The spender will immediately lose the ability to execute calls using that permission. To re-enable access, you must grant a new permission.
:::
:::info
**Transaction Required**: Revoking a permission requires an on-chain transaction. The user will need to pay gas for the transaction (unless using a paymaster for gasless revocation).
:::
### Related
* [usePermissions](/wagmi/usePermissions) - Get current permissions
* [useGrantPermissions](/wagmi/useGrantPermissions) - Grant new permissions
* [wallet\_revokePermissions](/api-reference/wallet_revokePermissions) - RPC method reference
## useSign
Source: https://docs.jaw.id/wagmi/useSign
## useSign
Hook to sign messages using the unified `wallet_sign` method (ERC-7871). This combines the functionality of `useSignMessage` and `useSignTypedData` into a single hook, with support for specifying a target chain.
**Type:** `hook`
### Import
```typescript
import { useSign } from '@jaw.id/wagmi';
```
### Signature
```typescript
function useSign(parameters?: { config?: Config; mutation?: UseMutationParameters }): UseMutationResult;
```
### Parameters
#### config
Type: `Config` (optional)
Wagmi config. If not provided, uses the config from `WagmiProvider`.
#### mutation
Type: `UseMutationParameters` (optional)
TanStack React Query mutation options.
### Returns
Returns a TanStack React Query mutation result:
\| Property | Type | Description |
\| ------------- | ---------- | ------------------------------ |
\| `mutate` | `function` | Function to sign a message |
\| `mutateAsync` | `function` | Async version of mutate |
\| `data` | `Hex` | The signature |
\| `isPending` | `boolean` | Whether signing is in progress |
\| `isSuccess` | `boolean` | Whether signing succeeded |
\| `isError` | `boolean` | Whether signing failed |
\| `error` | `Error` | Error if signing failed |
### Mutation Variables
When calling `mutate()`, pass:
#### request
Type: `PersonalSignRequestData | TypedDataRequestData` (required)
The signing request, which can be one of two types:
##### Personal Sign (EIP-191)
```typescript
{
type: '0x45',
data: {
message: string;
}
}
```
##### Typed Data (EIP-712)
```typescript
{
type: '0x01',
data: {
types: Record;
primaryType: string;
domain: TypedDataDomain;
message: Record;
}
}
```
#### Optional Parameters
\| Parameter | Type | Description |
\| ----------- | ----------- | --------------------------- |
\| `address` | `Address` | Specific account address |
\| `chainId` | `number` | Target chain ID for signing |
\| `connector` | `Connector` | Specific connector |
### Why Use useSign?
#### Unified API
Instead of choosing between `useSignMessage` and `useSignTypedData`, use a single hook that handles both:
\| Signature Type | Type Code | Standard |
\| -------------- | --------- | -------- |
\| Personal Sign | `0x45` | EIP-191 |
\| Typed Data | `0x01` | EIP-712 |
#### Chain-Specific Signing
Smart accounts can produce different signatures depending on which chain they're deployed on. The `chainId` parameter lets you sign for a specific chain without calling `wallet_switchEthereumChain` first:
```typescript
// Sign for Base without switching chains
signMessage({
chainId: 8453,
request: {
type: '0x45',
data: { message: 'Hello from Base' },
},
});
```
:::info
The `chainId` parameter specifies which chain's smart account to use for signing. This is separate from any chain ID that might be included in the message content itself (like in EIP-712's domain).
:::
### Examples
#### Personal Sign
```tsx
import { useSign } from '@jaw.id/wagmi';
function SignMessageButton() {
const { mutate: signMessage, data: signature, isPending } = useSign();
const handleSign = () => {
signMessage({
request: {
type: '0x45',
data: { message: 'Hello, World!' },
},
});
};
return (