Check for permit() in ERC20 token

I'm developing a dapp with smart contract that can accept ERC20 tokens from users. To have the smart contract get a user's tokens, I want to use the permit function by getting a signature from the user; but if permit() doesn't exist in the token, then I'll resort to having the user do an approve transaction.

What is the best way to use web3 or ethers to check that a token has permit()?

1 Like

I decided to use getFunction in ethers' Interface, which throws an error if the function isn't found. But it means the dapp needs the ABI of the token, which isn't always available. Is there any better way to handle the logic?

1 Like