Created
February 8, 2022 18:52
-
-
Save MCarlomagno/3a6f4653baf53fe36261b8f7f2a69b70 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
pragma solidity >=0.7.0 <0.9.0; | |
import "github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v3.3/contracts/cryptography/ECDSA.sol"; | |
import "github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v3.3/contracts/utils/ReentrancyGuard.sol"; | |
contract UniDirectionalPaymentChannel is ReentrancyGuard { | |
// ... | |
function send(uint _amount, bytes memory _sig) external nonReentrant { | |
// verifing signature and sender != receiver | |
require(msg.sender == receiver, "sender must be different than receiver"); | |
require(_verify(_amount, _sig), "invalid signature"); | |
(bool sent, ) = receiver.call{value: _amount}(""); | |
require(sent, "Failed to send Ether"); | |
selfdestruct(sender); | |
} | |
// ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment