Signs typed data per EIP-712. Use for orders, permits, and any signed payload that needs domain separation.
Request
const signature = await provider.request<`0x${string}`>({
method: 'eth_signTypedData_v4',
params: [
address,
JSON.stringify({
domain: {
name: 'My App',
version: '1',
chainId: 1868,
verifyingContract: '0x...',
},
types: {
EIP712Domain: [
{ name: 'name', type: 'string' },
{ name: 'version', type: 'string' },
{ name: 'chainId', type: 'uint256' },
{ name: 'verifyingContract', type: 'address' },
],
Order: [
{ name: 'item', type: 'string' },
{ name: 'amount', type: 'uint256' },
],
},
primaryType: 'Order',
message: { item: 'Pass', amount: '1' },
}),
],
})
Parameters
EIP-712 typed data. Accepts a JSON-stringified string or the object directly; the SDK forwards the value verbatim.
Returns
0x${string}, the signature.
Errors
| Code | Cause |
|---|
4001 | User rejected |
4100 | Wallet not connected |
-32602 | Malformed typed data |
Verification
import { publicClient } from './viem'
const isValid = await publicClient.verifyTypedData({
address,
domain,
types,
primaryType: 'Order',
message,
signature,
})