Created
September 24, 2021 19:42
-
-
Save nathan-websculpt/b1ae472676b23e05f3d7a5804a256d02 to your computer and use it in GitHub Desktop.
Example usage of Escrow -- not production-ready -- for learning purposes only
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
// SPDX-License-Identifier: GPL-3.0 | |
pragma solidity >=0.7.0 <0.9.0; | |
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v4.3/contracts/security/ReentrancyGuard.sol"; | |
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v4.3/contracts/utils/escrow/Escrow.sol"; | |
contract EscrowExample is ReentrancyGuard { | |
Escrow private immutable _escrow; | |
constructor() { | |
_escrow = new Escrow(); | |
} | |
function deposit() public payable { | |
_escrow.deposit{ value: msg.value }(msg.sender); | |
} | |
function withdraw(address payable payee) public nonReentrant { | |
require(payee == msg.sender, "sender address did not match address in arguments"); | |
_escrow.withdraw(payee); | |
} | |
function query() external view returns (uint256) { | |
return _escrow.depositsOf(msg.sender); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Used as an example in this blog