> ## Documentation Index
> Fetch the complete documentation index at: https://docs.startale.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Sign messages

> Sign plain strings with personal_sign or structured data with EIP-712.

Two signing methods are supported.

| Method                 | Use for                                                         |
| ---------------------- | --------------------------------------------------------------- |
| `personal_sign`        | Plain-string messages, login challenges, terms acknowledgements |
| `eth_signTypedData_v4` | Structured EIP-712 data, orders, permits, domain-bound consent  |

Signatures are produced by the user's smart account. They are ERC-1271 compatible and verifiable off-chain with viem's `verifyMessage` or `verifyTypedData`.

## Sign a string

```tsx theme={null}
import { useAccount, useSignMessage } from 'wagmi'

const { signMessageAsync } = useSignMessage()
const signature = await signMessageAsync({
  message: 'I acknowledge the airdrop terms.',
})
```

With the raw provider:

```ts theme={null}
const signature = await provider.request({
  method: 'personal_sign',
  params: [stringToHex('I acknowledge the airdrop terms.'), address],
})
```

## Sign typed data

```tsx theme={null}
import { useSignTypedData } from 'wagmi'

const { signTypedDataAsync } = useSignTypedData()
const signature = await signTypedDataAsync({
  domain: {
    name: 'My App',
    version: '1',
    chainId: 1868,
    verifyingContract: '0x...',
  },
  types: {
    Order: [
      { name: 'item', type: 'string' },
      { name: 'amount', type: 'uint256' },
    ],
  },
  primaryType: 'Order',
  message: { item: 'Pass', amount: 1n },
})
```

## Verify a signature offchain

Use viem. Smart-account signatures are resolved automatically, no special handling required.

```ts theme={null}
import { publicClient } from './viem'

const isValid = await publicClient.verifyMessage({
  address,
  message: 'I acknowledge the airdrop terms.',
  signature,
})
```

For typed data, use `verifyTypedData`.

## Counterfactual signatures

Before a smart account is deployed on a given chain, signatures are wrapped per [ERC-6492](https://eips.ethereum.org/EIPS/eip-6492). The wrapping is transparent: verifiers that support 6492, including viem, accept both wrapped and unwrapped signatures.

If you write your own verifier, look up "ERC-6492 magic byte". The suffix `0x6492649264926492…` indicates an undeployed account; unwrap the signature before validation.
