function withdraw() external onlyOwner {
if(block.timestamp < end || totalCollected < goal) {
revert CollectNotFinished();
}
}
-
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 TLCommented Mar 9 at 13:54
Add a comment
|
1 Answer
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();
}
}