0
function withdraw() external onlyOwner {
    if(block.timestamp < end || totalCollected < goal) {
       revert CollectNotFinished();
    }
 }
1
  • the function does not change the state of the contract and therefore it cannot be declared as external. It should be view because it only read and compare data of contract but does not change it. you need to add the withdraw code that change the state of the contract and then it can be declared as external and called by a transaction
    – Majd TL
    Commented Mar 9 at 13:54

1 Answer 1

0

Simply do what the warning suggests by restricting the function state mutability to view, such as:

function withdraw() external view onlyOwner {
    if(block.timestamp < end || totalCollected < goal) {
       revert CollectNotFinished();
    }
 }

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.