Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'Dai/invalid-permit' #4

Open
jrocco2 opened this issue Jun 30, 2021 · 1 comment
Open

'Dai/invalid-permit' #4

jrocco2 opened this issue Jun 30, 2021 · 1 comment

Comments

@jrocco2
Copy link

jrocco2 commented Jun 30, 2021

Im using this exact demo code while using Hardhat on a forked Ethereum mainnet node.

const result = await signDaiPermit(window.ethereum, tokenAddress, senderAddress, spender);
await token.methods.permit(senderAddress, spender, result.nonce, result.expiry, true, result.v, result.r, result.s)

I'm able to console log all the variables and I tripled checked everything matches. However no matter what I do I always get the error message 'Dai/invalid-permit'

This is for the DAI token

@jgostylo
Copy link

I know this was posted a long time ago but I wanted to provide a possible answer. If you are deploying a DAI contract on your test fork then you need to make sure to deploy as chainId "31337". If you are using the DAI contract that was deployed on mainnet it was deployed as chainId "1". The DAI contract uses the DOMAIN_SEPARATOR pattern to ensure safety of transaction replay. If you are making a permit call on the mainnet deployment you need to sign the permit data with chainId=1, if you are making the permit call to a fresh deployment of DAI then you can use the provided chainId=31337. I am currently running into the issue that I cannot use Metamask to sign a message that claims chainId=1 when the active chainId=31337 because it is set up to refuse to do this (safety). However, I also cannot get the dai-permit library to use ethers to sign based on a wallet set up using chainId=1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants