Created
July 18, 2023 10:20
-
-
Save TehilaFavourite/84bc9f7f75ea2c7254752ddb330d8a79 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: MIT | |
pragma solidity ^0.8.0; | |
contract AssertExample { | |
uint256 public balance = 1000; | |
function withdraw(uint256 amount) public { | |
// Ensure the contract has sufficient balance before withdrawing | |
assert(balance >= amount); | |
// Deduct the withdrawn amount from the balance | |
balance -= amount; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment