EIP 712 Signatures #188
-
|
Hello, It's possible to some way sign EIP 712 messages (structured messages)? Ethers.js has a |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
|
Would be interested to know how to use v4 using |
Beta Was this translation helpful? Give feedback.
-
|
Got it working using the following: import type { VoidSigner } from "@ethersproject/abstract-signer";
import { useNetwork, useSigner } from "wagmi";
const [{ data: signer }] = useSigner();
const domain = {
name: "Ether Mail",
version: "1",
chainId: networkData.chain.id,
verifyingContract: "0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC",
};
// The named list of all type definitions
const types = {
Person: [
{ name: "name", type: "string" },
{ name: "wallet", type: "address" },
],
Mail: [
{ name: "from", type: "Person" },
{ name: "to", type: "Person" },
{ name: "contents", type: "string" },
],
};
// The data to sign
const value = {
from: {
name: "Cow",
wallet: "0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826",
},
to: {
name: "Bob",
wallet: "0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB",
},
contents: "Hello, Bob!",
};
const signature = await (signer as VoidSigner)._signTypedData(domain, types, value); |
Beta Was this translation helpful? Give feedback.
Got it working using the following: