Last active
December 13, 2021 00:20
-
-
Save JhonatanHern/381e7734242e66cbcc668f826a8ce11c to your computer and use it in GitHub Desktop.
Fast escrow
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 "github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC721/IERC721.sol"; | |
import "github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC721/IERC721Receiver.sol"; | |
contract EscrowUWU is IERC721Receiver{ | |
address private auctioncontract; | |
function setAuctionContract(address _auctioncontract) external{ | |
require(auctioncontract == address(0)); | |
auctioncontract = _auctioncontract; | |
} | |
modifier onlyAuctionContract(){ | |
require(msg.sender == auctioncontract, "Only authorized contract"); | |
_; | |
} | |
function transferNFT(uint id, address nftContract, address to) external onlyAuctionContract { | |
IERC721(nftContract).safeTransferFrom(address(this), to, id); | |
} | |
function transferNativeCurrency(uint amount, address payable to) external onlyAuctionContract { | |
to.transfer(amount); | |
} | |
function onERC721Received( | |
address operator, | |
address from, | |
uint256 tokenId, | |
bytes calldata data | |
) external pure override returns (bytes4){ | |
operator; | |
from; | |
tokenId; | |
data; | |
return this.onERC721Received.selector; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment