I want to show a button with 2 states (APRROVE USDC) and (CONFIRM SWAP). But, I do not how to get from the ERC20.sol contract a variable o methods that returns if the token was already approved or not.
1 Answer
You can use the allowance method to check if the spender is approved to transfer tokens on behalf of the owner. the method will return you the approved amount to spend
https://docs.openzeppelin.com/contracts/2.x/api/token/erc20#IERC20-allowance-address-address-
allowance(address owner, address spender) → uint256 external Returns the remaining number of tokens that spender will be allowed to spend on behalf of owner through transferFrom. This is zero by default.
This value changes when approve or transferFrom are called.
-
-
1@FalconStakepool ERC721 standard has the method isApprovedForAll(address owner, address operator) → bool / and getApproved(uint256 tokenId) → address operator– Majd TLMar 14 at 7:37
-
1check this docs.openzeppelin.com/contracts/4.x/api/token/… AND THIS ethereum.org/de/developers/docs/standards/tokens/erc-721– Majd TLMar 14 at 7:38
-