eth_signTypedData_v4
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
objectEIP712Domain
arrayAn 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
objectContains the domain separator values specified in the EIP712Domain type.
primaryType
stringmessage
objectResult
(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"