Created
February 1, 2024 17:00
-
-
Save dhruvinparikh/fa4b67b1761060a1e37ba5e42fa301c5 to your computer and use it in GitHub Desktop.
DAI Permit from inspect window via metamask
This file contains hidden or 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
| from : "" // holder address | |
| message = { | |
| holder: from, | |
| spender: "0x3d573f130125E1a510b65f2aD258ec4f88Ca7023", | |
| nonce: 0, // update nonce | |
| expiry: 1706806653, // update expiry | |
| allowed: true, | |
| }; | |
| msgParams = JSON.stringify({ | |
| types: { | |
| EIP712Domain: [ | |
| { | |
| name: "name", | |
| type: "string", | |
| }, | |
| { | |
| name: "version", | |
| type: "string", | |
| }, | |
| { | |
| name: "chainId", | |
| type: "uint256", | |
| }, | |
| { | |
| name: "verifyingContract", | |
| type: "address", | |
| }, | |
| ], | |
| Permit: [ | |
| { | |
| name: "holder", | |
| type: "address", | |
| }, | |
| { | |
| name: "spender", | |
| type: "address", | |
| }, | |
| { | |
| name: "nonce", | |
| type: "uint256", | |
| }, | |
| { | |
| name: "expiry", | |
| type: "uint256", | |
| }, | |
| { | |
| name: "allowed", | |
| type: "bool", | |
| }, | |
| ], | |
| }, | |
| primaryType: "Permit", | |
| domain: { | |
| name: "Dai Stablecoin", | |
| version: "1", | |
| chainId: 1, | |
| verifyingContract: "0x6B175474E89094C44Da98b954EedeAC495271d0F", | |
| }, | |
| message: message, | |
| }); | |
| sign = await ethereum.request({ | |
| method: 'eth_signTypedData_v4', | |
| params: [from, msgParams], | |
| }) | |
| r = sign.slice(0, 66); | |
| s = "0x" + sign.slice(66, 130); | |
| v = Number("0x" + sign.slice(130, 132)); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment