Skip to main content

eth_signTypedData_v4

MetaMask

Presents a data message for the user to sign in a structured and readable format and returns the signed response. Introduced By EIP-712.

Params

(2)

1. Address (required)

The address of the requested signing account.

string
Match pattern:
^0x[0-9,a-f,A-F]{40}$

2. TypedData (required)

types
object
required
EIP712Domain
array
required

An array specifying one or more of the following domain separator values: 1) 'name' - The user-readable name of signing domain, i.e., the name of the dapp or the protocol. 2) 'version' - The current major version of the signing domain. 3) 'chainId' - The EIP-155 chain ID. 4) 'verifyingContract' - The address of the contract that will verify the signature. 5) 'salt' - A disambiguating salt for the protocol.

domain
object
required

Contains the domain separator values specified in the EIP712Domain type.

primaryType
string
required
message
object
required

Result

(Signature)
string
Match pattern:
^0x[0-9a-f]*$

Example

Request

await window.ethereum.request({
"method": "eth_signTypedData_v4",
"params": [
"0x0000000000000000000000000000000000000000",
{
"types": {
"EIP712Domain": [
{
"name": "name",
"type": "string"
},
{
"name": "version",
"type": "string"
},
{
"name": "chainId",
"type": "uint256"
},
{
"name": "verifyingContract",
"type": "address"
}
],
"Person": [
{
"name": "name",
"type": "string"
},
{
"name": "wallet",
"type": "address"
}
],
"Mail": [
{
"name": "from",
"type": "Person"
},
{
"name": "to",
"type": "Person"
},
{
"name": "contents",
"type": "string"
}
]
},
"primaryType": "Mail",
"domain": {
"name": "Ether Mail",
"version": "1",
"chainId": 1,
"verifyingContract": "0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC"
},
"message": {
"from": {
"name": "Cow",
"wallet": "0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826"
},
"to": {
"name": "Bob",
"wallet": "0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB"
},
"contents": "Hello, Bob!"
}
}
]
});

Result

"0x4355c47d63924e8a72e509b65029052eb6c299d53a04e167c5775fd466751c9d07299936d304c153f6443dfa05f40ff007d72911b6f72307f996231605b915621c"

Params

Address

TypedData

types*

Unsupported field schema for field root_types_EIP712Domain: Missing items definition.

{
  "type": "array"
}
domain*
message*

Request

await window.ethereum.request({
"method": "eth_signTypedData_v4",
"params": [
null,
null
]
});