Created
March 26, 2023 21:36
-
-
Save mushketyk/27ca745cf274d0232674ebcad9dfb9d5 to your computer and use it in GitHub Desktop.
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.18+commit.87f61d96.js&optimize=false&runs=200&gist=
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: MIT | |
pragma solidity ^0.8.13; | |
import "Ownable.sol"; | |
contract Auction { | |
address public beneficiary; | |
uint public deadline; | |
Ownable public ownable; | |
constructor(address ownableAddress) { | |
beneficiary = msg.sender; | |
ownable = Ownable(ownableAddress); | |
require(ownable.owner() == address(beneficiary), "Should be owned by the caller"); | |
} | |
function startAuction(uint duration) public { | |
require(ownable.isOwner(), "Auction should be the owner"); | |
deadline = block.timestamp + duration; | |
} | |
} |
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: MIT | |
pragma solidity ^0.8.13; | |
contract Ownable { | |
address public owner; | |
string public itemName; | |
constructor(string memory itemName_) { | |
owner = msg.sender; | |
itemName = itemName_; | |
} | |
function transferOwnership(address newOwner) public { | |
require(isOwner(), "Not an owner"); | |
require(newOwner != address(0x0), "Invalid owner address"); | |
owner = newOwner; | |
} | |
function isOwner() public view returns(bool) { | |
return owner == msg.sender; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment