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

How can we check whether a token supports permit? #10

Open
tab00 opened this issue Apr 13, 2022 · 1 comment
Open

How can we check whether a token supports permit? #10

tab00 opened this issue Apr 13, 2022 · 1 comment

Comments

@tab00
Copy link

tab00 commented Apr 13, 2022

I'm developing a dapp with a smart contract that can receive ERC20 tokens. What's the best way for a dapp (using ethers or web3) to check whether a token has the permit function, so that execution can fall back to using approve if not?

I had just tried signERC2612Permit with WETH on Rinkeby and it succeeded to create signature values, however when the smart contract tries to call permit the transaction is reverted without a reason. I then checked WETH and found that that WETH doesn't have permit.

Should signERC2612Permit check for permit before returning signature values, throwing an error if it doesn't exist?

@rkalis
Copy link

rkalis commented Apr 29, 2023

What I do now is call contract.functions.nonces(DUMMY_ADDRESS) and contract.functions.DOMAIN_SEPARATOR() and see if they don't throw + return expected values (zero for nonces and non-zero bytes for DOMAIN_SEPARATOR.

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