Last active
January 18, 2023 06:34
-
-
Save developeruche/1660097d81747e029e9ee01907dc679c 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
async function getPermitSignature(signer: any, token: any, spender: any, value: any, deadline: any) { | |
const [nonce, name, version, chainId] = await Promise.all([ | |
token.nonces(signer.address), | |
token.name(), | |
"1", | |
80001, | |
]) | |
console.log(nonce, name, version, chainId) | |
return ethers.utils.splitSignature( | |
await signer._signTypedData( | |
{ | |
name, | |
version, | |
chainId, | |
verifyingContract: token.address, | |
}, | |
{ | |
Permit: [ | |
{ | |
name: "owner", | |
type: "address", | |
}, | |
{ | |
name: "spender", | |
type: "address", | |
}, | |
{ | |
name: "value", | |
type: "uint256", | |
}, | |
{ | |
name: "nonce", | |
type: "uint256", | |
}, | |
{ | |
name: "deadline", | |
type: "uint256", | |
}, | |
], | |
}, | |
{ | |
owner: signer.address, | |
spender, | |
value, | |
nonce, | |
deadline, | |
} | |
) | |
) | |
} |
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 deadline = Math.floor(Date.now() + 600); | |
const { v, r, s } = await getPermitSignature( | |
contractOwner, | |
Token, | |
DIAMOND_ADDRESS, | |
NUM_IN, | |
deadline | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment