Skip to content

Instantly share code, notes, and snippets.

@TehilaFavourite
Created July 18, 2023 10:20
Show Gist options
  • Save TehilaFavourite/84bc9f7f75ea2c7254752ddb330d8a79 to your computer and use it in GitHub Desktop.
Save TehilaFavourite/84bc9f7f75ea2c7254752ddb330d8a79 to your computer and use it in GitHub Desktop.
// 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