EIP 712 Signatures #188
Answered
by
brunoalano
brunoalano
asked this question in
Q&A
-
Hello, It's possible to some way sign EIP 712 messages (structured messages)? Ethers.js has a |
Beta Was this translation helpful? Give feedback.
Answered by
brunoalano
Feb 22, 2022
Replies: 2 comments 2 replies
-
Would be interested to know how to use v4 using |
Beta Was this translation helpful? Give feedback.
0 replies
-
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.
2 replies
Answer selected by
brunoalano
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Got it working using the following: