Last active
July 6, 2022 00:25
-
-
Save blutarche/c9f295eea2d54bea154f3b4dc8a5a0c4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
contract LoveLetter { | |
... | |
function open(uint256 id) external returns (string memory message) { | |
require(receivers[id] == msg.sender, "Not receiver"); | |
require(!letters[id].opened, "Already opened"); | |
message = letters[id].message; | |
letters[id].opened = true; | |
uint256 amount = letters[id].etherAmount; | |
console.log("[open]", id, amount); | |
if (amount > 0) { | |
payable(msg.sender).transfer(amount); | |
} | |
emit Opened(senders[id], msg.sender, id, amount); | |
} | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment