Skip to content

Instantly share code, notes, and snippets.

@casweeney
Created August 1, 2022 17:52
Show Gist options
  • Save casweeney/cb9b3019eacc4d3c377afe2a0a219fee to your computer and use it in GitHub Desktop.
Save casweeney/cb9b3019eacc4d3c377afe2a0a219fee to your computer and use it in GitHub Desktop.
Using custom errors with NATSPEC
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.4;
/// ogbeni
error Unauthorized();
/// @custom:experimental This is an experimental contract.
contract VendingMachine {
address payable owner = payable(msg.sender);
function withdraw() public {
if (msg.sender != owner)
revert Unauthorized();
owner.transfer(address(this).balance);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment