Last active
September 21, 2023 22:46
-
-
Save andreitr/f8c4d96edd0f53a2eb4d27086a645f63 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { signTypedData, data, error } = useSignTypedData(); | |
const handleSign = async () => { | |
try { | |
const domain = { | |
name: 'Sign referral', | |
version: '1', | |
chainId: 1, | |
verifyingContract: 'contract...' | |
}; | |
const types = { | |
Listing: [ | |
{ name: 'nftContractAddress', type: 'address' }, | |
{ name: 'nftId', type: 'uint256' }, | |
{ name: 'price', type: 'uint256' }, | |
{ name: 'referralFee', type: 'uint256' }, | |
{ name: 'expiration', type:’uint256’} | |
] | |
}; | |
const message = { | |
nftContractAddress: "0x00", | |
nftId, | |
price, | |
referralFee, | |
expiration, | |
}, | |
}; | |
const signature = await signTypedData(domain, types, message); | |
} catch (err) { | |
console.error('Error signing the message:', err); | |
} | |
}; |
` const domain = {
name: "referralAndLoyalty",
version: "0.0.1",
chainId: hardhat.id,
verifyingContract: "0x5FC8d32690cc91D4c39d9d3abcBD16989F875707",
} as const;
const types = {
Listing: [
{ name: "nftContractAddress", type: "address" },
{ name: "nftId", type: "uint256" },
{ name: "price", type: "uint256" },
{ name: "referralFee", type: "uint256" },
{ name: "expiration", type: "uint256" },
],
} as const;
const message = {
nftContractAddress: contractAddress,
nftId: tokenId,
price,
referralFee,
expiration,
} as const;
const signature = useSignTypedData({ domain, types, primaryType: "mail", message });`
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
const handleSign = async () => {
try {
const domain = {
name: "referralAndLoyalty",
version: "0.0.1",
chainId: hardhat.id,
verifyingContract: "0x5FC8d32690cc91D4c39d9d3abcBD16989F875707",
};
};