0

my withdraw function asks for payable amount in Etherscan before invoking it, not sure what's the reason?

function withdraw() public payable onlyOwner {
      
        (bool os, ) = payable(owner()).call{value: address(this).balance}("");
        require(os);

    }

enter image description here

1
  • 2
    The function is marked as payable and etherscan is asking how much ether you want to send. If you don't want to send anything enter 0 (zero).
    – Ismael
    Feb 17, 2022 at 5:49

1 Answer 1

0

If you want to send ether (or bnb) to an address, the address must be of type address payable. That is why you are casting owner() as payable. What is payable is not the amount, but the address.

You can find more info here -> What's the difference between 'address' and 'address payable'?

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.