Skip to content

Instantly share code, notes, and snippets.

@ashwinYardi
Created August 26, 2022 12:40
Show Gist options
  • Save ashwinYardi/8978fbd9a311ea9a57349f75be52f134 to your computer and use it in GitHub Desktop.
Save ashwinYardi/8978fbd9a311ea9a57349f75be52f134 to your computer and use it in GitHub Desktop.
Simple solidity contract to demo error throwing mechanisms in solidity
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.7;
contract DemoErrors {
function demoRequire(uint input) public pure {
require(input > 5, "input must be greater than 5");
}
function demoRevert(uint input) public pure {
if (input <= 10) {
revert("Input must be greater than 10");
}
}
function demoAssert(uint input) public pure {
assert(input >=10);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment