Skip to content

Commit

Permalink
Add Security documentation to ensure finality
Browse files Browse the repository at this point in the history
  • Loading branch information
aefhm committed Jan 23, 2024
1 parent 9b899bb commit 912b355
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions docs/security.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,36 @@ function transferFrom(address who, address to, uint amount)
}
```

## Speed Bump

If we would like to prevent off-chain calls from being chained together, we can
ensure that the block has been finalized.

```solidity
contract Secret {
uint256 private _height;
bytes private _secret;
address private _buyer;
constructor(bytes memory _text) {
_secret = _text;
}
function recordPayment() external payable {
require(msg.value == 1 ether);
// set and lock recipient
_height = block.number;
}
/// @notice Reveals the secret.
function revealSecret() view external returns (bytes memory) {
require(block.number >= _height, "not settled");
// check for recipient
return _secret;
}
}
```

## Gas Padding

To prevent leaking information about a particular transaction, Sapphire
Expand Down

0 comments on commit 912b355

Please sign in to comment.