3

ERC20 token standard uses approve() and transferFrom() to do the indirect transfer.

function approve(address spender, uint256 value) public returns (bool success) {
    allowance[msg.sender][spender] = value;
    Approval(msg.sender, spender, value);
    return true;
}

As shown above, the approve() method uses the variable - allowance to add the mapping, so the owner can allow multiple spenders at the same time.

But I am just thinking if the approve() is the method to add the allowance why the ERC20 standard doesn't have any method to remove spender when the token owner doesn't want to give allowance. If allowance[msg.sender][spender] =0, why the standard doesn't just delete the allowance[msg.sender][spender.

And given the structure allowance[msg.sender][spender] = uint256, what is the maximum memory this structure will take for the contract?

1 Answer 1

5

The ERC20 standard does not enforce any implementation. If you really want to implement a token when calling approve() with 0 value you can delete the spender. From a utility point of view, both methods should work and both are compatible with ERC20.

Your Answer

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

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