eth_signTypedData_v4
Signs structured data according to EIP-712. Unlike personal_sign, this method understands the structure of your data and displays it in a human-readable format. Use this for permit signatures, order signing, and any protocol that requires typed structured data signatures.
Try it
Parameters
| Position | Type | Description |
|---|---|---|
| 0 | string | The account address |
| 1 | string | object | The typed data object (or JSON string) |
Typed Data Structure
interface TypedData {
domain: {
name?: string;
version?: string;
chainId?: number;
verifyingContract?: string;
};
types: {
[typeName: string]: Array<{ name: string; type: string }>;
};
primaryType: string;
message: Record<string, unknown>;
}Returns
string - The signature as a hex string.
Example
const typedData = {
domain: {
name: 'My App',
version: '1',
chainId: 1,
verifyingContract: '0x...',
},
types: {
Person: [
{ name: 'name', type: 'string' },
{ name: 'wallet', type: 'address' },
],
},
primaryType: 'Person',
message: {
name: 'Alice',
wallet: '0x...',
},
};
const signature = await provider.request({
method: 'eth_signTypedData_v4',
params: [accounts[0], typedData],
});Notes
- Shows a human-readable preview of the structured data
- Also available as
eth_signTypedData(alias) - The typed data is validated before signing