I've granted allowance to a smart contract to spend some tokens on my behalf, but it seems i gave it unlimited access.

I want to revoke this access as i now know that this could be a potential opening for an attack on my address(wallet).

I noticed that block explorers like etherscan or wallets like coinbase have a tool that makes revoking approvals possible.

I'm interested in knowing how this would work, and how i can build something similar. I dont think this is a feature that ERC20 OR ERC721 tokens currently support natively.


1 Answer 1


You just need to call the contract's function setApproval(ERC721) or setApprovalForAll(ERC1155 & ERC721) and pass false as the bool value

EDIT - added ERC20 standard

//for ERC1155 & ERC721
function setApprovalForAll(address operator, bool approved)

//only for ERC721
function approve(address to, uint256 tokenId)

//for ERC20 according to the EIP-20
function approve(address _spender, uint256 _value) public returns (bool success)
  • It seems not all tokens support this though. This USDC token for example: etherscan.io/token/…
    – KelvinIOT
    Commented Dec 9, 2022 at 4:05
  • It does but the function name is different; this one is an ERC20 :D I suggest you take a look at eips.ethereum.org/EIPS/eip-20, that is the Standard functions that must be implemented; maybe you can also search for the documentation of the smart contracts you want to interact with
    – Casareafer
    Commented Dec 9, 2022 at 4:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.