[ Download CSV Export  ] 
 Internal Transactions as a result of Contract Execution
View All
ParentTxHash Block Age From To Value
Contract Source Code Verified (Exact Match)
Contract Name: Vyper_contract
Compiler Version: vyper:0.1.0b8
Optimization Enabled: N/A
Runs (Optimiser):  N/A



  Contract Source Code   Find Similiar Contracts

# Blind Auction # Adapted to Vyper from [Solidity by Example](https://github.com/ethereum/solidity/blob/develop/docs/solidity-by-example.rst#blind-auction-1)

struct Bid:
  blindedBid: bytes32
  deposit: wei_value

# Note: because Vyper does not allow for dynamic arrays, we have limited the
# number of bids that can be placed by one address to 128 in this example
MAX_BIDS: constant(int128) = 128

# Event for logging that auction has ended
AuctionEnded: event({_highestBidder: address, _highestBid: wei_value})

# Auction parameters
beneficiary: public(address)
biddingEnd: public(timestamp)
revealEnd: public(timestamp)

# Set to true at the end of auction, disallowing any new bids
ended: public(bool)

# Final auction state
highestBid: public(wei_value)
highestBidder: public(address)

# State of the bids
bids: map(address, Bid[128])
bidCounts: map(address, int128)

# Allowed withdrawals of previous bids
pendingReturns: map(address, wei_value)


# Create a blinded auction with `_biddingTime` seconds bidding time and
# `_revealTime` seconds reveal time on behalf of the beneficiary address
# `_beneficiary`.
@public
def __init__(_beneficiary: address, _biddingTime: timedelta, _revealTime: timedelta):
    self.beneficiary = _beneficiary
    self.biddingEnd = block.timestamp + _biddingTime
    self.revealEnd = self.biddingEnd + _revealTime


# Place a blinded bid with:
#
# _blindedBid = sha3(concat(
#       convert(value, bytes32),
#       convert(fake, bytes32),
#       secret)
# )
#
# The sent ether is only refunded if the bid is correctly revealed in the
# revealing phase. The bid is valid if the ether sent together with the bid is
# at least "value" and "fake" is not true. Setting "fake" to true and sending
# not the exact amount are ways to hide the real bid but still make the
# required deposit. The same address can place multiple bids.
@public
@payable
def bid(_blindedBid: bytes32):
    # Check if bidding period is still open
    assert block.timestamp < self.biddingEnd

    # Check that payer hasn't already placed maximum number of bids
    numBids: int128 = self.bidCounts[msg.sender]
    assert numBids < MAX_BIDS

    # Add bid to mapping of all bids
    self.bids[msg.sender][numBids] = Bid({
        blindedBid: _blindedBid,
        deposit: msg.value
        })
    self.bidCounts[msg.sender] += 1


# Returns a boolean value, `True` if bid placed successfully, `False` otherwise.
@private
def placeBid(bidder: address, value: wei_value) -> bool:
    # If bid is less than highest bid, bid fails
    if (value <= self.highestBid):
        return False

    # Refund the previously highest bidder
    if (self.highestBidder != ZERO_ADDRESS):
        self.pendingReturns[self.highestBidder] += self.highestBid

    # Place bid successfully and update auction state
    self.highestBid = value
    self.highestBidder = bidder

    return True


# Reveal your blinded bids. You will get a refund for all correctly blinded
# invalid bids and for all bids except for the totally highest.
@public
def reveal(_numBids: int128, _values: wei_value[128], _fakes: bool[128], _secrets: bytes32[128]):
    # Check that bidding period is over
    assert block.timestamp > self.biddingEnd

    # Check that reveal end has not passed
    assert block.timestamp < self.revealEnd

    # Check that number of bids being revealed matches log for sender
    assert _numBids == self.bidCounts[msg.sender]

    # Calculate refund for sender
    refund: wei_value
    for i in range(MAX_BIDS):
        # Note that loop may break sooner than 128 iterations if i >= _numBids
        if (i >= _numBids):
            break

        # Get bid to check
        bidToCheck: Bid = (self.bids[msg.sender])[i]

        # Check against encoded packet
        value: wei_value = _values[i]
        fake: bool = _fakes[i]
        secret: bytes32 = _secrets[i]
        blindedBid: bytes32 = sha3(concat(
            convert(value, bytes32),
            convert(fake, bytes32),
            secret
        ))

        # Bid was not actually revealed
        # Do not refund deposit
        if (blindedBid != bidToCheck.blindedBid):
            assert 1 == 0
            continue

        # Add deposit to refund if bid was indeed revealed
        refund += bidToCheck.deposit
        if (not fake and bidToCheck.deposit >= value):
            if (self.placeBid(msg.sender, value)):
                refund -= value

        # Make it impossible for the sender to re-claim the same deposit
        zeroBytes32: bytes32
        bidToCheck.blindedBid = zeroBytes32

    # Send refund if non-zero
    if (refund != 0):
        send(msg.sender, refund)


# Withdraw a bid that was overbid.
@public
def withdraw():
    # Check that there is an allowed pending return.
    pendingAmount: wei_value = self.pendingReturns[msg.sender]
    if (pendingAmount > 0):
        # If so, set pending returns to zero to prevent recipient from calling
        # this function again as part of the receiving call before `transfer`
        # returns (see the remark above about conditions -> effects ->
        # interaction).
        self.pendingReturns[msg.sender] = 0

        # Then send return
        send(msg.sender, pendingAmount)


# End the auction and send the highest bid to the beneficiary.
@public
def auctionEnd():
    # Check that reveal end has passed
    assert block.timestamp > self.revealEnd

    # Check that auction has not already been marked as ended
    assert not self.ended

    # Log auction ending and set flag
    log.AuctionEnded(self.highestBidder, self.highestBid)
    self.ended = True

    # Transfer funds to beneficiary
    send(self.beneficiary, self.highestBid)

    Contract ABI  
[{"name":"AuctionEnded","inputs":[{"type":"address","name":"_highestBidder","indexed":false},{"type":"uint256","name":"_highestBid","indexed":false,"unit":"wei"}],"anonymous":false,"type":"event"},{"name":"__init__","outputs":[],"inputs":[{"type":"address","name":"_beneficiary"},{"type":"uint256","name":"_biddingTime","unit":"sec"},{"type":"uint256","name":"_revealTime","unit":"sec"}],"constant":false,"payable":false,"type":"constructor"},{"name":"bid","outputs":[],"inputs":[{"type":"bytes32","name":"_blindedBid"}],"constant":false,"payable":true,"type":"function","gas":106716},{"name":"reveal","outputs":[],"inputs":[{"type":"int128","name":"_numBids"},{"type":"uint256[128]","name":"_values"},{"type":"bool[128]","name":"_fakes"},{"type":"bytes32[128]","name":"_secrets"}],"constant":false,"payable":false,"type":"function","gas":14708472},{"name":"withdraw","outputs":[],"inputs":[],"constant":false,"payable":false,"type":"function","gas":55667},{"name":"auctionEnd","outputs":[],"inputs":[],"constant":false,"payable":false,"type":"function","gas":73519},{"name":"beneficiary","outputs":[{"type":"address","name":"out"}],"inputs":[],"constant":true,"payable":false,"type":"function","gas":633},{"name":"biddingEnd","outputs":[{"type":"uint256","name":"out","unit":"sec"}],"inputs":[],"constant":true,"payable":false,"type":"function","gas":663},{"name":"revealEnd","outputs":[{"type":"uint256","name":"out","unit":"sec"}],"inputs":[],"constant":true,"payable":false,"type":"function","gas":693},{"name":"ended","outputs":[{"type":"bool","name":"out"}],"inputs":[],"constant":true,"payable":false,"type":"function","gas":723},{"name":"highestBid","outputs":[{"type":"uint256","name":"out","unit":"wei"}],"inputs":[],"constant":true,"payable":false,"type":"function","gas":753},{"name":"highestBidder","outputs":[{"type":"address","name":"out"}],"inputs":[],"constant":true,"payable":false,"type":"function","gas":783}]

  Contract Creation Code Switch To Opcodes View
600035601c52740100000000000000000000000000000000000000006020526f7fffffffffffffffffffffffffffffff6040527fffffffffffffffffffffffffffffffff8000000000000000000000000000000060605274012a05f1fffffffffffffffffffffffffdabf41c006080527ffffffffffffffffffffffffed5fa0e000000000000000000000000000000000060a0526060611cc36101403934156100a757600080fd5b6020611cc360c03960c05160205181106100c057600080fd5b50610140516000554261016051420110156100da57600080fd5b610160514201600155600154610180516001540110156100f957600080fd5b6101805160015401600255611cab56600035601c52740100000000000000000000000000000000000000006020526f7fffffffffffffffffffffffffffffff6040527fffffffffffffffffffffffffffffffff8000000000000000000000000000000060605274012a05f1fffffffffffffffffffffffffdabf41c006080527ffffffffffffffffffffffffed5fa0e000000000000000000000000000000000060a05263957bb1e0600051141561015057602060046101403760015442106100b757600080fd5b60073360e05260c052604060c0205461016052608061016051126100da57600080fd5b61016051608081106100eb57600080fd5b60063360e05260c052604060c02060c052602060c0200160c052602060c0206101405181553460018201555060073360e05260c052604060c02060605160018254018060405190131561013d57600080fd5b809190121561014b57600080fd5b815550005b6000156101d7575b6101805261014052610160526004546101605111151561018057600060005260005161018051565b60006005541415156101b957600860055460e05260c052604060c020805460045482540110156101af57600080fd5b6004548154018155505b61016051600455610140516005556001600052600051610180515650005b6359dc4cbb60005114156119c95761302060046101403734156101f957600080fd5b6060516004358060405190131561020f57600080fd5b809190121561021d57600080fd5b50611024356002811061022f57600080fd5b50611044356002811061024157600080fd5b50611064356002811061025357600080fd5b50611084356002811061026557600080fd5b506110a4356002811061027757600080fd5b506110c4356002811061028957600080fd5b506110e4356002811061029b57600080fd5b5061110435600281106102ad57600080fd5b5061112435600281106102bf57600080fd5b5061114435600281106102d157600080fd5b5061116435600281106102e357600080fd5b5061118435600281106102f557600080fd5b506111a4356002811061030757600080fd5b506111c4356002811061031957600080fd5b506111e4356002811061032b57600080fd5b50611204356002811061033d57600080fd5b50611224356002811061034f57600080fd5b50611244356002811061036157600080fd5b50611264356002811061037357600080fd5b50611284356002811061038557600080fd5b506112a4356002811061039757600080fd5b506112c435600281106103a957600080fd5b506112e435600281106103bb57600080fd5b5061130435600281106103cd57600080fd5b5061132435600281106103df57600080fd5b5061134435600281106103f157600080fd5b50611364356002811061040357600080fd5b50611384356002811061041557600080fd5b506113a4356002811061042757600080fd5b506113c4356002811061043957600080fd5b506113e4356002811061044b57600080fd5b50611404356002811061045d57600080fd5b50611424356002811061046f57600080fd5b50611444356002811061048157600080fd5b50611464356002811061049357600080fd5b5061148435600281106104a557600080fd5b506114a435600281106104b757600080fd5b506114c435600281106104c957600080fd5b506114e435600281106104db57600080fd5b5061150435600281106104ed57600080fd5b5061152435600281106104ff57600080fd5b50611544356002811061051157600080fd5b50611564356002811061052357600080fd5b50611584356002811061053557600080fd5b506115a4356002811061054757600080fd5b506115c4356002811061055957600080fd5b506115e4356002811061056b57600080fd5b50611604356002811061057d57600080fd5b50611624356002811061058f57600080fd5b5061164435600281106105a157600080fd5b5061166435600281106105b357600080fd5b5061168435600281106105c557600080fd5b506116a435600281106105d757600080fd5b506116c435600281106105e957600080fd5b506116e435600281106105fb57600080fd5b50611704356002811061060d57600080fd5b50611724356002811061061f57600080fd5b50611744356002811061063157600080fd5b50611764356002811061064357600080fd5b50611784356002811061065557600080fd5b506117a4356002811061066757600080fd5b506117c4356002811061067957600080fd5b506117e4356002811061068b57600080fd5b50611804356002811061069d57600080fd5b5061182435600281106106af57600080fd5b5061184435600281106106c157600080fd5b5061186435600281106106d357600080fd5b5061188435600281106106e557600080fd5b506118a435600281106106f757600080fd5b506118c4356002811061070957600080fd5b506118e4356002811061071b57600080fd5b50611904356002811061072d57600080fd5b50611924356002811061073f57600080fd5b50611944356002811061075157600080fd5b50611964356002811061076357600080fd5b50611984356002811061077557600080fd5b506119a4356002811061078757600080fd5b506119c4356002811061079957600080fd5b506119e435600281106107ab57600080fd5b50611a0435600281106107bd57600080fd5b50611a2435600281106107cf57600080fd5b50611a4435600281106107e157600080fd5b50611a6435600281106107f357600080fd5b50611a84356002811061080557600080fd5b50611aa4356002811061081757600080fd5b50611ac4356002811061082957600080fd5b50611ae4356002811061083b57600080fd5b50611b04356002811061084d57600080fd5b50611b24356002811061085f57600080fd5b50611b44356002811061087157600080fd5b50611b64356002811061088357600080fd5b50611b84356002811061089557600080fd5b50611ba435600281106108a757600080fd5b50611bc435600281106108b957600080fd5b50611be435600281106108cb57600080fd5b50611c0435600281106108dd57600080fd5b50611c2435600281106108ef57600080fd5b50611c44356002811061090157600080fd5b50611c64356002811061091357600080fd5b50611c84356002811061092557600080fd5b50611ca4356002811061093757600080fd5b50611cc4356002811061094957600080fd5b50611ce4356002811061095b57600080fd5b50611d04356002811061096d57600080fd5b50611d24356002811061097f57600080fd5b50611d44356002811061099157600080fd5b50611d6435600281106109a357600080fd5b50611d8435600281106109b557600080fd5b50611da435600281106109c757600080fd5b50611dc435600281106109d957600080fd5b50611de435600281106109eb57600080fd5b50611e0435600281106109fd57600080fd5b50611e243560028110610a0f57600080fd5b50611e443560028110610a2157600080fd5b50611e643560028110610a3357600080fd5b50611e843560028110610a4557600080fd5b50611ea43560028110610a5757600080fd5b50611ec43560028110610a6957600080fd5b50611ee43560028110610a7b57600080fd5b50611f043560028110610a8d57600080fd5b50611f243560028110610a9f57600080fd5b50611f443560028110610ab157600080fd5b50611f643560028110610ac357600080fd5b50611f843560028110610ad557600080fd5b50611fa43560028110610ae757600080fd5b50611fc43560028110610af957600080fd5b50611fe43560028110610b0b57600080fd5b506120043560028110610b1d57600080fd5b506001544211610b2c57600080fd5b6002544210610b3a57600080fd5b60073360e05260c052604060c020546101405114610b5757600080fd5b61318060006080818352015b6101405161318051121515610b775761199e565b6131a06131805160808110610b8b57600080fd5b60063360e05260c052604060c02060c052602060c020018060c052602060c02054825260018160c052602060c0200154826020015250506101606131805160808110610bd657600080fd5b60200201516131e0526111606131805160808110610bf357600080fd5b6020020151613200526121606131805160808110610c1057600080fd5b60200201516132205260006131e051602082613260010152602081019050613200516020826132600101526020810190506132205160208261326001015260208101905080613260526132609050805160208201209050613240526131a05161324051141515610c8b57600115610c8657600080fd5b61198e565b61316080516131c0518251011015610ca257600080fd5b6131c0518151018152506131e0516131c051101561320051151615611985576101405161016051610180516101a0516101c0516101e05161020051610220516102405161026051610280516102a0516102c0516102e05161030051610320516103405161036051610380516103a0516103c0516103e05161040051610420516104405161046051610480516104a0516104c0516104e05161050051610520516105405161056051610580516105a0516105c0516105e05161060051610620516106405161066051610680516106a0516106c0516106e05161070051610720516107405161076051610780516107a0516107c0516107e05161080051610820516108405161086051610880516108a0516108c0516108e05161090051610920516109405161096051610980516109a0516109c0516109e051610a0051610a2051610a4051610a6051610a8051610aa051610ac051610ae051610b0051610b2051610b4051610b6051610b8051610ba051610bc051610be051610c0051610c2051610c4051610c6051610c8051610ca051610cc051610ce051610d0051610d2051610d4051610d6051610d8051610da051610dc051610de051610e0051610e2051610e4051610e6051610e8051610ea051610ec051610ee051610f0051610f2051610f4051610f6051610f8051610fa051610fc051610fe05161100051611020516110405161106051611080516110a0516110c0516110e05161110051611120516111405161116051611180516111a0516111c0516111e05161120051611220516112405161126051611280516112a0516112c0516112e05161130051611320516113405161136051611380516113a0516113c0516113e05161140051611420516114405161146051611480516114a0516114c0516114e05161150051611520516115405161156051611580516115a0516115c0516115e05161160051611620516116405161166051611680516116a0516116c0516116e05161170051611720516117405161176051611780516117a0516117c0516117e05161180051611820516118405161186051611880516118a0516118c0516118e05161190051611920516119405161196051611980516119a0516119c0516119e051611a0051611a2051611a4051611a6051611a8051611aa051611ac051611ae051611b0051611b2051611b4051611b6051611b8051611ba051611bc051611be051611c0051611c2051611c4051611c6051611c8051611ca051611cc051611ce051611d0051611d2051611d4051611d6051611d8051611da051611dc051611de051611e0051611e2051611e4051611e6051611e8051611ea051611ec051611ee051611f0051611f2051611f4051611f6051611f8051611fa051611fc051611fe05161200051612020516120405161206051612080516120a0516120c0516120e05161210051612120516121405161216051612180516121a0516121c0516121e05161220051612220516122405161226051612280516122a0516122c0516122e05161230051612320516123405161236051612380516123a0516123c0516123e05161240051612420516124405161246051612480516124a0516124c0516124e05161250051612520516125405161256051612580516125a0516125c0516125e05161260051612620516126405161266051612680516126a0516126c0516126e05161270051612720516127405161276051612780516127a0516127c0516127e05161280051612820516128405161286051612880516128a0516128c0516128e05161290051612920516129405161296051612980516129a0516129c0516129e051612a0051612a2051612a4051612a6051612a8051612aa051612ac051612ae051612b0051612b2051612b4051612b6051612b8051612ba051612bc051612be051612c0051612c2051612c4051612c6051612c8051612ca051612cc051612ce051612d0051612d2051612d4051612d6051612d8051612da051612dc051612de051612e0051612e2051612e4051612e6051612e8051612ea051612ec051612ee051612f0051612f2051612f4051612f6051612f8051612fa051612fc051612fe05161300051613020516130405161306051613080516130a0516130c0516130e05161310051613120516131405161316051613180516131a0516131c0516131e05161320051613220516132405161326051613280516132a0516132c0516132e05163d98b9bb56133005233613320526131e05161334052613340516133205160065801610158565b6133a0526132e0526132c0526132a05261328052613260526132405261322052613200526131e0526131c0526131a05261318052613160526131405261312052613100526130e0526130c0526130a0526130805261306052613040526130205261300052612fe052612fc052612fa052612f8052612f6052612f4052612f2052612f0052612ee052612ec052612ea052612e8052612e6052612e4052612e2052612e0052612de052612dc052612da052612d8052612d6052612d4052612d2052612d0052612ce052612cc052612ca052612c8052612c6052612c4052612c2052612c0052612be052612bc052612ba052612b8052612b6052612b4052612b2052612b0052612ae052612ac052612aa052612a8052612a6052612a4052612a2052612a00526129e0526129c0526129a05261298052612960526129405261292052612900526128e0526128c0526128a05261288052612860526128405261282052612800526127e0526127c0526127a05261278052612760526127405261272052612700526126e0526126c0526126a05261268052612660526126405261262052612600526125e0526125c0526125a05261258052612560526125405261252052612500526124e0526124c0526124a05261248052612460526124405261242052612400526123e0526123c0526123a05261238052612360526123405261232052612300526122e0526122c0526122a05261228052612260526122405261222052612200526121e0526121c0526121a05261218052612160526121405261212052612100526120e0526120c0526120a0526120805261206052612040526120205261200052611fe052611fc052611fa052611f8052611f6052611f4052611f2052611f0052611ee052611ec052611ea052611e8052611e6052611e4052611e2052611e0052611de052611dc052611da052611d8052611d6052611d4052611d2052611d0052611ce052611cc052611ca052611c8052611c6052611c4052611c2052611c0052611be052611bc052611ba052611b8052611b6052611b4052611b2052611b0052611ae052611ac052611aa052611a8052611a6052611a4052611a2052611a00526119e0526119c0526119a05261198052611960526119405261192052611900526118e0526118c0526118a05261188052611860526118405261182052611800526117e0526117c0526117a05261178052611760526117405261172052611700526116e0526116c0526116a05261168052611660526116405261162052611600526115e0526115c0526115a05261158052611560526115405261152052611500526114e0526114c0526114a05261148052611460526114405261142052611400526113e0526113c0526113a05261138052611360526113405261132052611300526112e0526112c0526112a05261128052611260526112405261122052611200526111e0526111c0526111a05261118052611160526111405261112052611100526110e0526110c0526110a0526110805261106052611040526110205261100052610fe052610fc052610fa052610f8052610f6052610f4052610f2052610f0052610ee052610ec052610ea052610e8052610e6052610e4052610e2052610e0052610de052610dc052610da052610d8052610d6052610d4052610d2052610d0052610ce052610cc052610ca052610c8052610c6052610c4052610c2052610c0052610be052610bc052610ba052610b8052610b6052610b4052610b2052610b0052610ae052610ac052610aa052610a8052610a6052610a4052610a2052610a00526109e0526109c0526109a05261098052610960526109405261092052610900526108e0526108c0526108a05261088052610860526108405261082052610800526107e0526107c0526107a05261078052610760526107405261072052610700526106e0526106c0526106a05261068052610660526106405261062052610600526105e0526105c0526105a05261058052610560526105405261052052610500526104e0526104c0526104a05261048052610460526104405261042052610400526103e0526103c0526103a05261038052610360526103405261032052610300526102e0526102c0526102a05261028052610260526102405261022052610200526101e0526101c0526101a0526101805261016052610140526133a05115611984576131606131e0518151101561197957600080fd5b6131e0518151038152505b5b6133c0516131a0525b8151600101808352811415610b63575b50506000613160511415156119c757600060006000600061316051336000f16119c657600080fd5b5b005b633ccfd60b6000511415611a2e5734156119e257600080fd5b60083360e05260c052604060c02054610140526000610140511115611a2c57600060083360e05260c052604060c02055600060006000600061014051336000f1611a2b57600080fd5b5b005b632a24f46c6000511415611ab8573415611a4757600080fd5b6002544211611a5557600080fd5b60035415611a6257600080fd5b60055461014052600454610160527fdaec4582d5d9595688c8c98545fdd1c696d41c6aeaeb636737e84ed2f5c00eda6040610140a1600160035560006000600060006004546000546000f1611ab657600080fd5b005b6338af3eed6000511415611ade573415611ad157600080fd5b60005460005260206000f3005b63423b217f6000511415611b04573415611af757600080fd5b60015460005260206000f3005b63a6e664776000511415611b2a573415611b1d57600080fd5b60025460005260206000f3005b6312fa6feb6000511415611b50573415611b4357600080fd5b60035460005260206000f3005b63d57bde796000511415611b76573415611b6957600080fd5b60045460005260206000f3005b6391f901576000511415611b9c573415611b8f57600080fd5b60055460005260206000f3005b60006000fd5b610109611cab03610109600039610109611cab036000f3000000000000000000000000ad850d65eb5202f828f5f7883bc0b46ac87e64d4000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000064

    Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000ad850d65eb5202f828f5f7883bc0b46ac87e64d4000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000064

-----Encoded View---------------
3 Constructor Arguments found :
Arg [0] : 000000000000000000000000ad850d65eb5202f828f5f7883bc0b46ac87e64d4
Arg [1] : 000000000000000000000000000000000000000000000000000000000000000a
Arg [2] : 0000000000000000000000000000000000000000000000000000000000000064


 

View All
Block Age transaction Difficulty GasUsed Reward
View All
Block Age UncleNumber Difficulty GasUsed Reward