Skip to content

Commit

Permalink
Add example contract validations
Browse files Browse the repository at this point in the history
  • Loading branch information
aefhm committed Jan 30, 2024
1 parent cb430cd commit 1418969
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions docs/security.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,16 @@ contract Secret {
function recordPayment() external payable {
require(msg.value == 1 ether);
// set and lock recipient
// set and lock buyer
_height = block.number;
_buyer = msg.sender;
}
/// @notice Reveals the secret.
function revealSecret() view external returns (bytes memory) {
require(block.number > _height, "not settled");
// check for recipient
require(_buyer != address(0), "no recorded buyer");
// TODO: optionally authenticate call from buyer
return _secret;
}
}
Expand Down

0 comments on commit 1418969

Please sign in to comment.