Address Contract Partially Verified
Address
0x1f52b87C3503e537853e160adBF7E330eA0Be7C4
Balance
7.5166 ETH
Nonce
1
Code Size
6665 bytes
Creator
0x5b325696...1073 at tx 0x72a51b9f...ae8a3c
Indexed Transactions
0
Contract Bytecode
6665 bytes
0x6060604052600436106100d0576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680631ae6b6ee146100dd5780633f4ba83a1461011f57806359d667a5146101345780635c975abb1461016b5780635fd8c710146101985780636c54df52146101ad578063762a66a21461020357806383b5ff8b146102a15780638456cb59146102ca578063859b97fe146102df5780638da5cb5b14610321578063961c9ae414610376578063e6effbe9146103d3578063f2fde38b1461044f575b34156100db57600080fd5b005b34156100e857600080fd5b61011d600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610488565b005b341561012a57600080fd5b610132610599565b005b610169600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610657565b005b341561017657600080fd5b61017e6106ee565b604051808215151515815260200191505060405180910390f35b34156101a357600080fd5b6101ab610701565b005b34156101b857600080fd5b6101ed600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506107b5565b6040518082815260200191505060405180910390f35b341561020e57600080fd5b610243600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610830565b604051808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018581526020018481526020018381526020018281526020019550505050505060405180910390f35b34156102ac57600080fd5b6102b4610991565b6040518082815260200191505060405180910390f35b34156102d557600080fd5b6102dd610997565b005b34156102ea57600080fd5b61031f600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610a57565b005b341561032c57600080fd5b610334610b32565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561038157600080fd5b6103d1600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091908035906020019091908035906020019091908035906020019091905050610b57565b005b34156103de57600080fd5b61044d600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803590602001909190803590602001909190803590602001909190803590602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610c70565b005b341561045a57600080fd5b610486600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610db6565b005b60008060149054906101000a900460ff1615156104a457600080fd5b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156104ff57600080fd5b600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000838152602001908152602001600020905061055a81610f0b565b151561056557600080fd5b61059483838360010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16610f39565b505050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156105f457600080fd5b600060149054906101000a900460ff16151561060f57600080fd5b60008060146101000a81548160ff0219169083151502179055507f7805862f689e2f13df9f062ff482ad3ad112aca9e0847911ed832e158c525b3360405160405180910390a1565b600080600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002060010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1691506106db848434610fbe565b90506106e8843385611188565b50505050565b600060149054906101000a900460ff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561075c57600080fd5b3373ffffffffffffffffffffffffffffffffffffffff166108fc3073ffffffffffffffffffffffffffffffffffffffff16319081150290604051600060405180830381858888f1935050505015156107b357600080fd5b565b600080600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000848152602001908152602001600020905061081381610f0b565b151561081e57600080fd5b61082781611251565b91505092915050565b600080600080600080600260008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000888152602001908152602001600020905061089481610f0b565b151561089f57600080fd5b8060010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff168160020160009054906101000a90046fffffffffffffffffffffffffffffffff168260020160109054906101000a90046fffffffffffffffffffffffffffffffff168360030160009054906101000a900467ffffffffffffffff168460030160089054906101000a900467ffffffffffffffff16836fffffffffffffffffffffffffffffffff169350826fffffffffffffffffffffffffffffffff1692508167ffffffffffffffff1691508067ffffffffffffffff16905095509550955095509550509295509295909350565b60015481565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156109f257600080fd5b600060149054906101000a900460ff16151515610a0e57600080fd5b6001600060146101000a81548160ff0219169083151502179055507f6985a02210a168e66602d3235cb6db0e70f92b3ba4d376a33c0f3d9434bff62560405160405180910390a1565b600080600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008481526020019081526020016000209150610ab582610f0b565b1515610ac057600080fd5b8160010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610b2157600080fd5b610b2c848483610f39565b50505050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000610b61611942565b846fffffffffffffffffffffffffffffffff81101515610b8057600080fd5b846fffffffffffffffffffffffffffffffff81101515610b9f57600080fd5b8467ffffffffffffffff8111151515610bb757600080fd5b339450610bc58a868b611344565b60c0604051908101604052808b73ffffffffffffffffffffffffffffffffffffffff1681526020018673ffffffffffffffffffffffffffffffffffffffff168152602001896fffffffffffffffffffffffffffffffff168152602001886fffffffffffffffffffffffffffffffff1681526020018767ffffffffffffffff1681526020014267ffffffffffffffff168152509350610c648a8a86611441565b50505050505050505050565b610c78611942565b600060149054906101000a900460ff16151515610c9457600080fd5b846fffffffffffffffffffffffffffffffff81101515610cb357600080fd5b846fffffffffffffffffffffffffffffffff81101515610cd257600080fd5b8467ffffffffffffffff8111151515610cea57600080fd5b610cf58a338b6116df565b1515610d0057600080fd5b610d0b8a338b611344565b60c0604051908101604052808b73ffffffffffffffffffffffffffffffffffffffff1681526020018673ffffffffffffffffffffffffffffffffffffffff168152602001896fffffffffffffffffffffffffffffffff168152602001886fffffffffffffffffffffffffffffffff1681526020018767ffffffffffffffff1681526020014267ffffffffffffffff168152509350610daa8a8a86611441565b50505050505050505050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610e1157600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614151515610e4d57600080fd5b8073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000808260030160089054906101000a900467ffffffffffffffff1667ffffffffffffffff16119050919050565b610f4383836117b7565b610f4e838284611188565b7f018b64b6242d32aa550e95d78985b938d71af5b3f10827b0683f55da163930488383604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a1505050565b600080600080600080600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000898152602001908152602001600020945061102285610f0b565b151561102d57600080fd5b61103685611251565b935083871015151561104757600080fd5b8460010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16925061107889896117b7565b60008411156110d25761108a846118d8565b915081840390508273ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f1935050505015156110d157600080fd5b5b7f6c00bb44a64da29b6a73920d50ff280237d277bda3e1f3cdf4e24392e6839efe89898633604051808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018381526020018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200194505050505060405180910390a183955050505050509392505050565b6000611193846118f3565b90508073ffffffffffffffffffffffffffffffffffffffff1663a9059cbb84846040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050600060405180830381600087803b151561123757600080fd5b6102c65a03f1151561124857600080fd5b50505050505050565b600080600090508260030160089054906101000a900467ffffffffffffffff1667ffffffffffffffff164211156112aa578260030160089054906101000a900467ffffffffffffffff1667ffffffffffffffff16420390505b61133c8360020160009054906101000a90046fffffffffffffffffffffffffffffffff166fffffffffffffffffffffffffffffffff168460020160109054906101000a90046fffffffffffffffffffffffffffffffff166fffffffffffffffffffffffffffffffff168560030160009054906101000a900467ffffffffffffffff1667ffffffffffffffff1684611902565b915050919050565b600061134f846118f3565b90508073ffffffffffffffffffffffffffffffffffffffff166323b872dd8430856040518463ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050600060405180830381600087803b151561142757600080fd5b6102c65a03f1151561143857600080fd5b50505050505050565b603c816080015167ffffffffffffffff161015151561145f57600080fd5b80600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002060008201518160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060208201518160010160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060408201518160020160006101000a8154816fffffffffffffffffffffffffffffffff02191690836fffffffffffffffffffffffffffffffff16021790555060608201518160020160106101000a8154816fffffffffffffffffffffffffffffffff02191690836fffffffffffffffffffffffffffffffff16021790555060808201518160030160006101000a81548167ffffffffffffffff021916908367ffffffffffffffff16021790555060a08201518160030160086101000a81548167ffffffffffffffff021916908367ffffffffffffffff1602179055509050507fb0c0552f858e630668cc4c58a1b7d1bd302efa77c15d8ec0f1fe725053c59801838383604001516fffffffffffffffffffffffffffffffff1684606001516fffffffffffffffffffffffffffffffff16856080015167ffffffffffffffff16604051808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018581526020018481526020018381526020018281526020019550505050505060405180910390a1505050565b6000806116eb856118f3565b90508373ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16636352211e856000604051602001526040518263ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180828152602001915050602060405180830381600087803b151561177b57600080fd5b6102c65a03f1151561178c57600080fd5b5050506040518051905073ffffffffffffffffffffffffffffffffffffffff16149150509392505050565b600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828152602001908152602001600020600080820160006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690556001820160006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690556002820160006101000a8154906fffffffffffffffffffffffffffffffff02191690556002820160106101000a8154906fffffffffffffffffffffffffffffffff02191690556003820160006101000a81549067ffffffffffffffff02191690556003820160086101000a81549067ffffffffffffffff021916905550505050565b600061271060015483028115156118eb57fe5b049050919050565b60008082905080915050919050565b600080600080858510151561191957869350611937565b87870392508585840281151561192b57fe5b05915081880190508093505b505050949350505050565b60c060405190810160405280600073ffffffffffffffffffffffffffffffffffffffff168152602001600073ffffffffffffffffffffffffffffffffffffffff16815260200160006fffffffffffffffffffffffffffffffff16815260200160006fffffffffffffffffffffffffffffffff168152602001600067ffffffffffffffff168152602001600067ffffffffffffffff16815250905600a165627a7a72305820719ab9a4079a83be862127911ddd53aee142d915e174548d1d94e3e48c4a5ddf0029
Verified Source Code Partial Match
Compiler: v0.4.20-nightly.2018.1.6+commit.2548228b
Optimization: No
SaleClockAuction.sol 565 lines
pragma solidity ^0.4.18;
/**
* Interface for required functionality in the ERC721 standard
* for non-fungible tokens.
*
* Author: Nadav Hollander (nadav at dharma.io)
*/
contract ERC721 {
// Function
function totalSupply() public view returns (uint256 _totalSupply);
function balanceOf(address _owner) public view returns (uint256 _balance);
function ownerOf(uint _tokenId) public view returns (address _owner);
function approve(address _to, uint _tokenId) public;
function transferFrom(address _from, address _to, uint _tokenId) public;
function transfer(address _to, uint _tokenId) public;
function implementsERC721() public view returns (bool _implementsERC721);
// Events
event Transfer(address indexed _from, address indexed _to, uint256 _tokenId);
event Approval(address indexed _owner, address indexed _approved, uint256 _tokenId);
}
/// @title Auction Core
/// @dev Contains models, variables, and internal methods for the auction.
contract ClockAuctionBase {
// Represents an auction on an NFT
struct Auction {
// Address of the NFT
address nftAddress;
// Current owner of NFT
address seller;
// Price (in wei) at beginning of auction
uint128 startingPrice;
// Price (in wei) at end of auction
uint128 endingPrice;
// Duration (in seconds) of auction
uint64 duration;
// Time when auction started
// NOTE: 0 if this auction has been concluded
uint64 startedAt;
}
// Cut owner takes on each auction, measured in basis points (1/100 of a percent).
// Values 0-10,000 map to 0%-100%
uint256 public ownerCut;
// Map from token ID to their corresponding auction.
mapping (address => mapping(uint256 => Auction)) nftToTokenIdToAuction;
event AuctionCreated(address nftAddress, uint256 tokenId, uint256 startingPrice, uint256 endingPrice, uint256 duration);
event AuctionSuccessful(address nftAddress, uint256 tokenId, uint256 totalPrice, address winner);
event AuctionCancelled(address nftAddress, uint256 tokenId);
/// @dev DON'T give me your money.
function() external {}
// Modifiers to check that inputs can be safely stored with a certain
// number of bits. We use constants and multiple modifiers to save gas.
modifier canBeStoredWith64Bits(uint256 _value) {
require(_value <= 18446744073709551615);
_;
}
modifier canBeStoredWith128Bits(uint256 _value) {
require(_value < 340282366920938463463374607431768211455);
_;
}
/// @dev Returns true if the claimant owns the token.
/// @param _nft - The address of the NFT.
/// @param _claimant - Address claiming to own the token.
/// @param _tokenId - ID of token whose ownership to verify.
function _owns(address _nft, address _claimant, uint256 _tokenId) internal view returns (bool) {
ERC721 nonFungibleContract = _getNft(_nft);
return (nonFungibleContract.ownerOf(_tokenId) == _claimant);
}
/// @dev Escrows the NFT, assigning ownership to this contract.
/// Throws if the escrow fails.
/// @param _nft - The address of the NFT.
/// @param _owner - Current owner address of token to escrow.
/// @param _tokenId - ID of token whose approval to verify.
function _escrow(address _nft, address _owner, uint256 _tokenId) internal {
ERC721 nonFungibleContract = _getNft(_nft);
// it will throw if transfer fails
nonFungibleContract.transferFrom(_owner, this, _tokenId);
}
/// @dev Transfers an NFT owned by this contract to another address.
/// Returns true if the transfer succeeds.
/// @param _nft - The address of the NFT.
/// @param _receiver - Address to transfer NFT to.
/// @param _tokenId - ID of token to transfer.
function _transfer(address _nft, address _receiver, uint256 _tokenId) internal {
ERC721 nonFungibleContract = _getNft(_nft);
// it will throw if transfer fails
nonFungibleContract.transfer(_receiver, _tokenId);
}
/// @dev Adds an auction to the list of open auctions. Also fires the
/// AuctionCreated event.
/// @param _tokenId The ID of the token to be put on auction.
/// @param _auction Auction to add.
function _addAuction(address _nft, uint256 _tokenId, Auction _auction) internal {
// Require that all auctions have a duration of
// at least one minute. (Keeps our math from getting hairy!)
require(_auction.duration >= 1 minutes);
nftToTokenIdToAuction[_nft][_tokenId] = _auction;
AuctionCreated(
address(_nft),
uint256(_tokenId),
uint256(_auction.startingPrice),
uint256(_auction.endingPrice),
uint256(_auction.duration)
);
}
/// @dev Cancels an auction unconditionally.
function _cancelAuction(address _nft, uint256 _tokenId, address _seller) internal {
_removeAuction(_nft, _tokenId);
_transfer(_nft, _seller, _tokenId);
AuctionCancelled(_nft, _tokenId);
}
/// @dev Computes the price and transfers winnings.
/// Does NOT transfer ownership of token.
function _bid(address _nft, uint256 _tokenId, uint256 _bidAmount)
internal
returns (uint256)
{
// Get a reference to the auction struct
Auction storage auction = nftToTokenIdToAuction[_nft][_tokenId];
// Explicitly check that this auction is currently live.
// (Because of how Ethereum mappings work, we can't just count
// on the lookup above failing. An invalid _tokenId will just
// return an auction object that is all zeros.)
require(_isOnAuction(auction));
// Check that the incoming bid is higher than the current
// price
uint256 price = _currentPrice(auction);
require(_bidAmount >= price);
// Grab a reference to the seller before the auction struct
// gets deleted.
address seller = auction.seller;
// The bid is good! Remove the auction before sending the fees
// to the sender so we can't have a reentrancy attack.
_removeAuction(_nft, _tokenId);
// Transfer proceeds to seller (if there are any!)
if (price > 0) {
// Calculate the auctioneer's cut.
// (NOTE: _computeCut() is guaranteed to return a
// value <= price, so this subtraction can't go negative.)
uint256 auctioneerCut = _computeCut(price);
uint256 sellerProceeds = price - auctioneerCut;
// NOTE: Doing a transfer() in the middle of a complex
// method like this is generally discouraged because of
// reentrancy attacks and DoS attacks if the seller is
// a contract with an invalid fallback function. We explicitly
// guard against reentrancy attacks by removing the auction
// before calling transfer(), and the only thing the seller
// can DoS is the sale of their own asset! (And if it's an
// accident, they can call cancelAuction(). )
seller.transfer(sellerProceeds);
}
// Tell the world!
AuctionSuccessful(_nft, _tokenId, price, msg.sender);
return price;
}
/// @dev Removes an auction from the list of open auctions.
/// @param _tokenId - ID of NFT on auction.
function _removeAuction(address _nft, uint256 _tokenId) internal {
delete nftToTokenIdToAuction[_nft][_tokenId];
}
/// @dev Returns true if the NFT is on auction.
/// @param _auction - Auction to check.
function _isOnAuction(Auction storage _auction) internal view returns (bool) {
return (_auction.startedAt > 0);
}
/// @dev Returns current price of an NFT on auction. Broken into two
/// functions (this one, that computes the duration from the auction
/// structure, and the other that does the price computation) so we
/// can easily test that the price computation works correctly.
function _currentPrice(Auction storage _auction)
internal
view
returns (uint256)
{
uint256 secondsPassed = 0;
// A bit of insurance against negative values (or wraparound).
// Probably not necessary (since Ethereum guarnatees that the
// now variable doesn't ever go backwards).
if (now > _auction.startedAt) {
secondsPassed = now - _auction.startedAt;
}
return _computeCurrentPrice(
_auction.startingPrice,
_auction.endingPrice,
_auction.duration,
secondsPassed
);
}
/// @dev Computes the current price of an auction. Factored out
/// from _currentPrice so we can run extensive unit tests.
/// When testing, make this function public and turn on
/// `Current price computation` test suite.
function _computeCurrentPrice(
uint256 _startingPrice,
uint256 _endingPrice,
uint256 _duration,
uint256 _secondsPassed
)
internal
pure
returns (uint256)
{
// NOTE: We don't use SafeMath (or similar) in this function because
// all of our public functions carefully cap the maximum values for
// time (at 64-bits) and currency (at 128-bits). _duration is
// also known to be non-zero (see the require() statement in
// _addAuction())
if (_secondsPassed >= _duration) {
// We've reached the end of the dynamic pricing portion
// of the auction, just return the end price.
return _endingPrice;
} else {
// Starting price can be higher than ending price (and often is!), so
// this delta can be negative.
int256 totalPriceChange = int256(_endingPrice) - int256(_startingPrice);
// This multiplication can't overflow, _secondsPassed will easily fit within
// 64-bits, and totalPriceChange will easily fit within 128-bits, their product
// will always fit within 256-bits.
int256 currentPriceChange = totalPriceChange * int256(_secondsPassed) / int256(_duration);
// currentPriceChange can be negative, but if so, will have a magnitude
// less that _startingPrice. Thus, this result will always end up positive.
int256 currentPrice = int256(_startingPrice) + currentPriceChange;
return uint256(currentPrice);
}
}
/// @dev Computes owner's cut of a sale.
/// @param _price - Sale price of NFT.
function _computeCut(uint256 _price) internal view returns (uint256) {
// NOTE: We don't use SafeMath (or similar) in this function because
// all of our entry functions carefully cap the maximum values for
// currency (at 128-bits), and ownerCut <= 10000 (see the require()
// statement in the ClockAuction constructor). The result of this
// function is always guaranteed to be <= _price.
return _price * ownerCut / 10000;
}
/// @dev Gets the NFT object from an address, validating that implementsERC721 is true.
/// @param _nft - Address of the NFT.
function _getNft(address _nft) internal view returns (ERC721) {
ERC721 candidateContract = ERC721(_nft);
//require(candidateContract.implementsERC721());
return candidateContract;
}
}
/**
* @title Ownable
* @dev The Ownable contract has an owner address, and provides basic authorization control
* functions, this simplifies the implementation of "user permissions".
*/
contract Ownable {
address public owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
function Ownable() public {
owner = msg.sender;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
/**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param newOwner The address to transfer ownership to.
*/
function transferOwnership(address newOwner) public onlyOwner {
require(newOwner != address(0));
OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
}
/**
* @title Pausable
* @dev Base contract which allows children to implement an emergency stop mechanism.
*/
contract Pausable is Ownable {
event Pause();
event Unpause();
bool public paused = false;
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*/
modifier whenNotPaused() {
require(!paused);
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*/
modifier whenPaused() {
require(paused);
_;
}
/**
* @dev called by the owner to pause, triggers stopped state
*/
function pause() onlyOwner whenNotPaused public {
paused = true;
Pause();
}
/**
* @dev called by the owner to unpause, returns to normal state
*/
function unpause() onlyOwner whenPaused public {
paused = false;
Unpause();
}
}
/// @title Clock auction for non-fungible tokens.
contract ClockAuction is Pausable, ClockAuctionBase {
/// @dev Constructor creates a reference to the NFT ownership contract
/// and verifies the owner cut is in the valid range.
/// @param _cut - percent cut the owner takes on each auction, must be
/// between 0-10,000.
function ClockAuction(uint256 _cut) public {
require(_cut <= 10000);
ownerCut = _cut;
}
/// @dev Remove all Ether from the contract, which is the owner's cuts
/// as well as any Ether sent directly to the contract address.
/// Always transfers to the NFT contract, but can be called either by
/// the owner or the NFT contract.
function withdrawBalance() external {
require(
msg.sender == owner
);
msg.sender.transfer(this.balance);
}
/// @dev Creates and begins a new auction.
/// @param _nftAddress - address of a deployed contract implementing
/// the Nonfungible Interface.
/// @param _tokenId - ID of token to auction, sender must be owner.
/// @param _startingPrice - Price of item (in wei) at beginning of auction.
/// @param _endingPrice - Price of item (in wei) at end of auction.
/// @param _duration - Length of time to move between starting
/// price and ending price (in seconds).
/// @param _seller - Seller, if not the message sender
function createAuction(
address _nftAddress,
uint256 _tokenId,
uint256 _startingPrice,
uint256 _endingPrice,
uint256 _duration,
address _seller
)
public
whenNotPaused
canBeStoredWith128Bits(_startingPrice)
canBeStoredWith128Bits(_endingPrice)
canBeStoredWith64Bits(_duration)
{
require(_owns(_nftAddress, msg.sender, _tokenId));
_escrow(_nftAddress, msg.sender, _tokenId);
Auction memory auction = Auction(
_nftAddress,
_seller,
uint128(_startingPrice),
uint128(_endingPrice),
uint64(_duration),
uint64(now)
);
_addAuction(_nftAddress, _tokenId, auction);
}
/// @dev Bids on an open auction, completing the auction and transferring
/// ownership of the NFT if enough Ether is supplied.
/// @param _nftAddress - address of a deployed contract implementing
/// the Nonfungible Interface.
/// @param _tokenId - ID of token to bid on.
function bid(address _nftAddress, uint256 _tokenId)
public
payable
whenNotPaused
{
// _bid will throw if the bid or funds transfer fails
_bid(_nftAddress, _tokenId, msg.value);
_transfer(_nftAddress, msg.sender, _tokenId);
}
/// @dev Cancels an auction that hasn't been won yet.
/// Returns the NFT to original owner.
/// @notice This is a state-modifying function that can
/// be called while the contract is paused.
/// @param _nftAddress - Address of the NFT.
/// @param _tokenId - ID of token on auction
function cancelAuction(address _nftAddress, uint256 _tokenId)
public
{
Auction storage auction = nftToTokenIdToAuction[_nftAddress][_tokenId];
require(_isOnAuction(auction));
address seller = auction.seller;
require(msg.sender == seller);
_cancelAuction(_nftAddress, _tokenId, seller);
}
/// @dev Cancels an auction when the contract is paused.
/// Only the owner may do this, and NFTs are returned to
/// the seller. This should only be used in emergencies.
/// @param _nftAddress - Address of the NFT.
/// @param _tokenId - ID of the NFT on auction to cancel.
function cancelAuctionWhenPaused(address _nftAddress, uint256 _tokenId)
whenPaused
onlyOwner
public
{
Auction storage auction = nftToTokenIdToAuction[_nftAddress][_tokenId];
require(_isOnAuction(auction));
_cancelAuction(_nftAddress, _tokenId, auction.seller);
}
/// @dev Returns auction info for an NFT on auction.
/// @param _nftAddress - Address of the NFT.
/// @param _tokenId - ID of NFT on auction.
function getAuction(address _nftAddress, uint256 _tokenId)
public
view
returns
(
address seller,
uint256 startingPrice,
uint256 endingPrice,
uint256 duration,
uint256 startedAt
) {
Auction storage auction = nftToTokenIdToAuction[_nftAddress][_tokenId];
require(_isOnAuction(auction));
return (
auction.seller,
auction.startingPrice,
auction.endingPrice,
auction.duration,
auction.startedAt
);
}
/// @dev Returns the current price of an auction.
/// @param _nftAddress - Address of the NFT.
/// @param _tokenId - ID of the token price we are checking.
function getCurrentPrice(address _nftAddress, uint256 _tokenId)
public
view
returns (uint256)
{
Auction storage auction = nftToTokenIdToAuction[_nftAddress][_tokenId];
require(_isOnAuction(auction));
return _currentPrice(auction);
}
}
/// @title Clock auction modified for sale of kitties
contract SaleClockAuction is ClockAuction {
// Delegate constructor
function SaleClockAuction(uint256 _cut) public
ClockAuction(_cut) {}
/// @dev Creates and begins a new auction.
/// @param _nftAddress - The address of the NFT.
/// @param _tokenId - ID of token to auction, sender must be owner.
/// @param _startingPrice - Price of item (in wei) at beginning of auction.
/// @param _endingPrice - Price of item (in wei) at end of auction.
/// @param _duration - Length of auction (in seconds).
function createAuction(
address _nftAddress,
uint256 _tokenId,
uint256 _startingPrice,
uint256 _endingPrice,
uint256 _duration
)
public
canBeStoredWith128Bits(_startingPrice)
canBeStoredWith128Bits(_endingPrice)
canBeStoredWith64Bits(_duration)
{
address seller = msg.sender;
_escrow(_nftAddress, seller, _tokenId);
Auction memory auction = Auction(
_nftAddress,
seller,
uint128(_startingPrice),
uint128(_endingPrice),
uint64(_duration),
uint64(now)
);
_addAuction(_nftAddress, _tokenId, auction);
}
/// @dev Updates lastSalePrice if seller is the nft contract
/// Otherwise, works the same as default bid method.
function bid(address _nftAddress, uint256 _tokenId)
public
payable
{
// _bid verifies token ID size
address seller = nftToTokenIdToAuction[_nftAddress][_tokenId].seller;
uint256 price = _bid(_nftAddress, _tokenId, msg.value);
_transfer(_nftAddress, msg.sender, _tokenId);
}
}
Read Contract
getAuction 0x762a66a2 → address, uint256, uint256, uint256, uint256
getCurrentPrice 0x6c54df52 → uint256
owner 0x8da5cb5b → address
ownerCut 0x83b5ff8b → uint256
paused 0x5c975abb → bool
Write Contract 9 functions
These functions modify contract state and require a wallet transaction to execute.
bid 0x59d667a5
address _nftAddress
uint256 _tokenId
cancelAuction 0x859b97fe
address _nftAddress
uint256 _tokenId
cancelAuctionWhenPaused 0x1ae6b6ee
address _nftAddress
uint256 _tokenId
createAuction 0x961c9ae4
address _nftAddress
uint256 _tokenId
uint256 _startingPrice
uint256 _endingPrice
uint256 _duration
createAuction 0xe6effbe9
address _nftAddress
uint256 _tokenId
uint256 _startingPrice
uint256 _endingPrice
uint256 _duration
address _seller
pause 0x8456cb59
No parameters
transferOwnership 0xf2fde38b
address newOwner
unpause 0x3f4ba83a
No parameters
withdrawBalance 0x5fd8c710
No parameters
Token Balances (1)
View Transfers →Recent Transactions
No transactions found for this address