ETH Price: $1,977.07 (+0.75%)

Transaction Decoder

Block:
4437690 at Oct-27-2017 06:27:31 AM +UTC
Transaction Fee:
0.00477695 ETH $9.44
Gas Used:
95,539 Gas / 50 Gwei

Emitted Events:

0 SecondPriceAuction.Ticked( era=3412, received=484818940802509116202000, accounted=544376965625310733632450 )
1 SecondPriceAuction.Buyin( who=[Sender] 0x65b761631b6f2fcc2c085a544b6602d1317dd94c, accounted=10000000000000000000, received=10000000000000000000, price=109179656825948 )
2 Wallet.Deposit( _from=[Receiver] SecondPriceAuction, value=10000000000000000000 )

Account State Difference:

  Address   Before After State Difference Code
0x3BfC20f0...F16540258
(Polkadot: MultiSig)
305,763.782251399926202 Eth305,773.782251399926202 Eth10
0x54a2d42a...0f0Eff078
0x65B76163...1317dD94C
10.163625058499556376 Eth
Nonce: 14
0.158848108499556376 Eth
Nonce: 15
10.00477695
(F2Pool Old)
10,304.447048356598945923 Eth10,304.451825306598945923 Eth0.00477695

Execution Trace

ETH 10 SecondPriceAuction.buyin( v=28, r=48B98934A8CF5DFCEBD98BCA8355119BCC70EA9A4C15A29C608D7DE79119033C, s=0870A8653F3A3F0287C9040282C238C24CD2C0F0D989429CFAA0887F3F70569E )
  • Null: 0x000...001.2cedb9c5( )
  • MultiCertifier.certified( _who=0x65B761631B6F2FcC2c085a544b6602d1317dD94C ) => ( True )
  • ETH 10 Wallet.CALL( )
    File 1 of 3: SecondPriceAuction
    //! Copyright Parity Technologies, 2017.
    //! Released under the Apache Licence 2.
    
    pragma solidity ^0.4.17;
    
    /// Stripped down ERC20 standard token interface.
    contract Token {
    	function transfer(address _to, uint256 _value) public returns (bool success);
    }
    
    // From Certifier.sol
    contract Certifier {
    	event Confirmed(address indexed who);
    	event Revoked(address indexed who);
    	function certified(address) public constant returns (bool);
    	function get(address, string) public constant returns (bytes32);
    	function getAddress(address, string) public constant returns (address);
    	function getUint(address, string) public constant returns (uint);
    }
    
    /// Simple modified second price auction contract. Price starts high and monotonically decreases
    /// until all tokens are sold at the current price with currently received funds.
    /// The price curve has been chosen to resemble a logarithmic curve
    /// and produce a reasonable auction timeline.
    contract SecondPriceAuction {
    	// Events:
    
    	/// Someone bought in at a particular max-price.
    	event Buyin(address indexed who, uint accounted, uint received, uint price);
    
    	/// Admin injected a purchase.
    	event Injected(address indexed who, uint accounted, uint received);
    
    	/// Admin uninjected a purchase.
    	event Uninjected(address indexed who);
    
    	/// At least 5 minutes has passed since last Ticked event.
    	event Ticked(uint era, uint received, uint accounted);
    
    	/// The sale just ended with the current price.
    	event Ended(uint price);
    
    	/// Finalised the purchase for `who`, who has been given `tokens` tokens.
    	event Finalised(address indexed who, uint tokens);
    
    	/// Auction is over. All accounts finalised.
    	event Retired();
    
    	// Constructor:
    
    	/// Simple constructor.
    	/// Token cap should take be in whole tokens, not smallest divisible units.
    	function SecondPriceAuction(
    		address _certifierContract,
    		address _tokenContract,
    		address _treasury,
    		address _admin,
    		uint _beginTime,
    		uint _tokenCap
    	)
    		public
    	{
    		certifier = Certifier(_certifierContract);
    		tokenContract = Token(_tokenContract);
    		treasury = _treasury;
    		admin = _admin;
    		beginTime = _beginTime;
    		tokenCap = _tokenCap;
    		endTime = beginTime + 28 days;
    	}
    
    	// No default function, entry-level users
    	function() public { assert(false); }
    
    	// Public interaction:
    
    	/// Buyin function. Throws if the sale is not active and when refund would be needed.
    	function buyin(uint8 v, bytes32 r, bytes32 s)
    		public
    		payable
    		when_not_halted
    		when_active
    		only_eligible(msg.sender, v, r, s)
    	{
    		flushEra();
    
    		// Flush bonus period:
    		if (currentBonus > 0) {
    			// Bonus is currently active...
    			if (now >= beginTime + BONUS_MIN_DURATION				// ...but outside the automatic bonus period
    				&& lastNewInterest + BONUS_LATCH <= block.number	// ...and had no new interest for some blocks
    			) {
    				currentBonus--;
    			}
    			if (now >= beginTime + BONUS_MAX_DURATION) {
    				currentBonus = 0;
    			}
    			if (buyins[msg.sender].received == 0) {	// We have new interest
    				lastNewInterest = uint32(block.number);
    			}
    		}
    
    		uint accounted;
    		bool refund;
    		uint price;
    		(accounted, refund, price) = theDeal(msg.value);
    
    		/// No refunds allowed.
    		require (!refund);
    
    		// record the acceptance.
    		buyins[msg.sender].accounted += uint128(accounted);
    		buyins[msg.sender].received += uint128(msg.value);
    		totalAccounted += accounted;
    		totalReceived += msg.value;
    		endTime = calculateEndTime();
    		Buyin(msg.sender, accounted, msg.value, price);
    
    		// send to treasury
    		treasury.transfer(msg.value);
    	}
    
    	/// Like buyin except no payment required and bonus automatically given.
    	function inject(address _who, uint128 _received)
    		public
    		only_admin
    		only_basic(_who)
    		before_beginning
    	{
    		uint128 bonus = _received * uint128(currentBonus) / 100;
    		uint128 accounted = _received + bonus;
    
    		buyins[_who].accounted += accounted;
    		buyins[_who].received += _received;
    		totalAccounted += accounted;
    		totalReceived += _received;
    		endTime = calculateEndTime();
    		Injected(_who, accounted, _received);
    	}
    
    	/// Reverses a previous `inject` command.
    	function uninject(address _who)
    		public
    		only_admin
    		before_beginning
    	{
    		totalAccounted -= buyins[_who].accounted;
    		totalReceived -= buyins[_who].received;
    		delete buyins[_who];
    		endTime = calculateEndTime();
    		Uninjected(_who);
    	}
    
    	/// Mint tokens for a particular participant.
    	function finalise(address _who)
    		public
    		when_not_halted
    		when_ended
    		only_buyins(_who)
    	{
    		// end the auction if we're the first one to finalise.
    		if (endPrice == 0) {
    			endPrice = totalAccounted / tokenCap;
    			Ended(endPrice);
    		}
    
    		// enact the purchase.
    		uint total = buyins[_who].accounted;
    		uint tokens = total / endPrice;
    		totalFinalised += total;
    		delete buyins[_who];
    		require (tokenContract.transfer(_who, tokens));
    
    		Finalised(_who, tokens);
    
    		if (totalFinalised == totalAccounted) {
    			Retired();
    		}
    	}
    
    	// Prviate utilities:
    
    	/// Ensure the era tracker is prepared in case the current changed.
    	function flushEra() private {
    		uint currentEra = (now - beginTime) / ERA_PERIOD;
    		if (currentEra > eraIndex) {
    			Ticked(eraIndex, totalReceived, totalAccounted);
    		}
    		eraIndex = currentEra;
    	}
    
    	// Admin interaction:
    
    	/// Emergency function to pause buy-in and finalisation.
    	function setHalted(bool _halted) public only_admin { halted = _halted; }
    
    	/// Emergency function to drain the contract of any funds.
    	function drain() public only_admin { treasury.transfer(this.balance); }
    
    	// Inspection:
    
    	/**
    	 * The formula for the price over time.
    	 *
    	 * This is a hand-crafted formula (no named to the constants) in order to
    	 * provide the following requirements:
    	 *
    	 * - Simple reciprocal curve (of the form y = a + b / (x + c));
    	 * - Would be completely unreasonable to end in the first 48 hours;
    	 * - Would reach $65m effective cap in 4 weeks.
    	 *
    	 * The curve begins with an effective cap (EC) of over $30b, more ether
    	 * than is in existance. After 48 hours, the EC reduces to approx. $1b.
    	 * At just over 10 days, the EC has reduced to $200m, and half way through
    	 * the 19th day it has reduced to $100m.
    	 *
    	 * Here's the curve: https://www.desmos.com/calculator/k6iprxzcrg?embed
    	 */
    
    	/// The current end time of the sale assuming that nobody else buys in.
    	function calculateEndTime() public constant returns (uint) {
    		var factor = tokenCap / DIVISOR * USDWEI;
    		return beginTime + 40000000 * factor / (totalAccounted + 5 * factor) - 5760;
    	}
    
    	/// The current price for a single indivisible part of a token. If a buyin happens now, this is
    	/// the highest price per indivisible token part that the buyer will pay. This doesn't
    	/// include the discount which may be available.
    	function currentPrice() public constant when_active returns (uint weiPerIndivisibleTokenPart) {
    		return (USDWEI * 40000000 / (now - beginTime + 5760) - USDWEI * 5) / DIVISOR;
    	}
    
    	/// Returns the total indivisible token parts available for purchase right now.
    	function tokensAvailable() public constant when_active returns (uint tokens) {
    		uint _currentCap = totalAccounted / currentPrice();
    		if (_currentCap >= tokenCap) {
    			return 0;
    		}
    		return tokenCap - _currentCap;
    	}
    
    	/// The largest purchase than can be made at present, not including any
    	/// discount.
    	function maxPurchase() public constant when_active returns (uint spend) {
    		return tokenCap * currentPrice() - totalAccounted;
    	}
    
    	/// Get the number of `tokens` that would be given if the sender were to
    	/// spend `_value` now. Also tell you what `refund` would be given, if any.
    	function theDeal(uint _value)
    		public
    		constant
    		when_active
    		returns (uint accounted, bool refund, uint price)
    	{
    		uint _bonus = bonus(_value);
    
    		price = currentPrice();
    		accounted = _value + _bonus;
    
    		uint available = tokensAvailable();
    		uint tokens = accounted / price;
    		refund = (tokens > available);
    	}
    
    	/// Any applicable bonus to `_value`.
    	function bonus(uint _value)
    		public
    		constant
    		when_active
    		returns (uint extra)
    	{
    		return _value * uint(currentBonus) / 100;
    	}
    
    	/// True if the sale is ongoing.
    	function isActive() public constant returns (bool) { return now >= beginTime && now < endTime; }
    
    	/// True if all buyins have finalised.
    	function allFinalised() public constant returns (bool) { return now >= endTime && totalAccounted == totalFinalised; }
    
    	/// Returns true if the sender of this transaction is a basic account.
    	function isBasicAccount(address _who) internal constant returns (bool) {
    		uint senderCodeSize;
    		assembly {
    			senderCodeSize := extcodesize(_who)
    		}
    	    return senderCodeSize == 0;
    	}
    
    	// Modifiers:
    
    	/// Ensure the sale is ongoing.
    	modifier when_active { require (isActive()); _; }
    
    	/// Ensure the sale has not begun.
    	modifier before_beginning { require (now < beginTime); _; }
    
    	/// Ensure the sale is ended.
    	modifier when_ended { require (now >= endTime); _; }
    
    	/// Ensure we're not halted.
    	modifier when_not_halted { require (!halted); _; }
    
    	/// Ensure `_who` is a participant.
    	modifier only_buyins(address _who) { require (buyins[_who].accounted != 0); _; }
    
    	/// Ensure sender is admin.
    	modifier only_admin { require (msg.sender == admin); _; }
    
    	/// Ensure that the signature is valid, `who` is a certified, basic account,
    	/// the gas price is sufficiently low and the value is sufficiently high.
    	modifier only_eligible(address who, uint8 v, bytes32 r, bytes32 s) {
    		require (
    			ecrecover(STATEMENT_HASH, v, r, s) == who &&
    			certifier.certified(who) &&
    			isBasicAccount(who) &&
    			msg.value >= DUST_LIMIT
    		);
    		_;
    	}
    
    	/// Ensure sender is not a contract.
    	modifier only_basic(address who) { require (isBasicAccount(who)); _; }
    
    	// State:
    
    	struct Account {
    		uint128 accounted;	// including bonus & hit
    		uint128 received;	// just the amount received, without bonus & hit
    	}
    
    	/// Those who have bought in to the auction.
    	mapping (address => Account) public buyins;
    
    	/// Total amount of ether received, excluding phantom "bonus" ether.
    	uint public totalReceived = 0;
    
    	/// Total amount of ether accounted for, including phantom "bonus" ether.
    	uint public totalAccounted = 0;
    
    	/// Total amount of ether which has been finalised.
    	uint public totalFinalised = 0;
    
    	/// The current end time. Gets updated when new funds are received.
    	uint public endTime;
    
    	/// The price per token; only valid once the sale has ended and at least one
    	/// participant has finalised.
    	uint public endPrice;
    
    	/// Must be false for any public function to be called.
    	bool public halted;
    
    	/// The current percentage of bonus that purchasers get.
    	uint8 public currentBonus = 15;
    
    	/// The last block that had a new participant.
    	uint32 public lastNewInterest;
    
    	// Constants after constructor:
    
    	/// The tokens contract.
    	Token public tokenContract;
    
    	/// The certifier.
    	Certifier public certifier;
    
    	/// The treasury address; where all the Ether goes.
    	address public treasury;
    
    	/// The admin address; auction can be paused or halted at any time by this.
    	address public admin;
    
    	/// The time at which the sale begins.
    	uint public beginTime;
    
    	/// Maximum amount of tokens to mint. Once totalAccounted / currentPrice is
    	/// greater than this, the sale ends.
    	uint public tokenCap;
    
    	// Era stuff (isolated)
    	/// The era for which the current consolidated data represents.
    	uint public eraIndex;
    
    	/// The size of the era in seconds.
    	uint constant public ERA_PERIOD = 5 minutes;
    
    	// Static constants:
    
    	/// Anything less than this is considered dust and cannot be used to buy in.
    	uint constant public DUST_LIMIT = 5 finney;
    
    	/// The hash of the statement which must be signed in order to buyin.
    	/// The meaning of this hash is:
    	///
    	/// parity.api.util.sha3(parity.api.util.asciiToHex("\x19Ethereum Signed Message:\n" + tscs.length + tscs))
    	/// where `toUTF8 = x => unescape(encodeURIComponent(x))`
    	/// and `tscs` is the toUTF8 called on the contents of https://gist.githubusercontent.com/gavofyork/5a530cad3b19c1cafe9148f608d729d2/raw/a116b507fd6d96036037f3affd393994b307c09a/gistfile1.txt
    	bytes32 constant public STATEMENT_HASH = 0x2cedb9c5443254bae6c4f44a31abcb33ec27a0bd03eb58e22e38cdb8b366876d;
    
    	/// Minimum duration after sale begins that bonus is active.
    	uint constant public BONUS_MIN_DURATION = 1 hours;
    
    	/// Minimum duration after sale begins that bonus is active.
    	uint constant public BONUS_MAX_DURATION = 24 hours;
    
    	/// Number of consecutive blocks where there must be no new interest before bonus ends.
    	uint constant public BONUS_LATCH = 2;
    
    	/// Number of Wei in one USD, constant.
    	uint constant public USDWEI = 3226 szabo;
    
    	/// Divisor of the token.
    	uint constant public DIVISOR = 1000;
    }

    File 2 of 3: Wallet
    //sol Wallet
    // Multi-sig, daily-limited account proxy/wallet.
    // @authors:
    // Gav Wood <g@ethdev.com>
    // inheritable "property" contract that enables methods to be protected by requiring the acquiescence of either a
    // single, or, crucially, each of a number of, designated owners.
    // usage:
    // use modifiers onlyowner (just own owned) or onlymanyowners(hash), whereby the same hash must be provided by
    // some number (specified in constructor) of the set of owners (specified in the constructor, modifiable) before the
    // interior is executed.
    
    pragma solidity ^0.4.9;
    
    contract WalletEvents {
      // EVENTS
    
      // this contract only has six types of events: it can accept a confirmation, in which case
      // we record owner and operation (hash) alongside it.
      event Confirmation(address owner, bytes32 operation);
      event Revoke(address owner, bytes32 operation);
    
      // some others are in the case of an owner changing.
      event OwnerChanged(address oldOwner, address newOwner);
      event OwnerAdded(address newOwner);
      event OwnerRemoved(address oldOwner);
    
      // the last one is emitted if the required signatures change
      event RequirementChanged(uint newRequirement);
    
      // Funds has arrived into the wallet (record how much).
      event Deposit(address _from, uint value);
      // Single transaction going out of the wallet (record who signed for it, how much, and to whom it's going).
      event SingleTransact(address owner, uint value, address to, bytes data, address created);
      // Multi-sig transaction going out of the wallet (record who signed for it last, the operation hash, how much, and to whom it's going).
      event MultiTransact(address owner, bytes32 operation, uint value, address to, bytes data, address created);
      // Confirmation still needed for a transaction.
      event ConfirmationNeeded(bytes32 operation, address initiator, uint value, address to, bytes data);
    }
    
    contract WalletAbi {
      // Revokes a prior confirmation of the given operation
      function revoke(bytes32 _operation) external;
    
      // Replaces an owner `_from` with another `_to`.
      function changeOwner(address _from, address _to) external;
    
      function addOwner(address _owner) external;
    
      function removeOwner(address _owner) external;
    
      function changeRequirement(uint _newRequired) external;
    
      function isOwner(address _addr) constant returns (bool);
    
      function hasConfirmed(bytes32 _operation, address _owner) external constant returns (bool);
    
      // (re)sets the daily limit. needs many of the owners to confirm. doesn't alter the amount already spent today.
      function setDailyLimit(uint _newLimit) external;
    
      function execute(address _to, uint _value, bytes _data) external returns (bytes32 o_hash);
      function confirm(bytes32 _h) returns (bool o_success);
    }
    
    contract WalletLibrary is WalletEvents {
      // TYPES
    
      // struct for the status of a pending operation.
      struct PendingState {
        uint yetNeeded;
        uint ownersDone;
        uint index;
      }
    
      // Transaction structure to remember details of transaction lest it need be saved for a later call.
      struct Transaction {
        address to;
        uint value;
        bytes data;
      }
    
      // MODIFIERS
    
      // simple single-sig function modifier.
      modifier onlyowner {
        if (isOwner(msg.sender))
          _;
      }
      // multi-sig function modifier: the operation must have an intrinsic hash in order
      // that later attempts can be realised as the same underlying operation and
      // thus count as confirmations.
      modifier onlymanyowners(bytes32 _operation) {
        if (confirmAndCheck(_operation))
          _;
      }
    
      // METHODS
    
      // gets called when no other function matches
      function() payable {
        // just being sent some cash?
        if (msg.value > 0)
          Deposit(msg.sender, msg.value);
      }
    
      // constructor is given number of sigs required to do protected "onlymanyowners" transactions
      // as well as the selection of addresses capable of confirming them.
      function initMultiowned(address[] _owners, uint _required) only_uninitialized {
        m_numOwners = _owners.length + 1;
        m_owners[1] = uint(msg.sender);
        m_ownerIndex[uint(msg.sender)] = 1;
        for (uint i = 0; i < _owners.length; ++i)
        {
          m_owners[2 + i] = uint(_owners[i]);
          m_ownerIndex[uint(_owners[i])] = 2 + i;
        }
        m_required = _required;
      }
    
      // Revokes a prior confirmation of the given operation
      function revoke(bytes32 _operation) external {
        uint ownerIndex = m_ownerIndex[uint(msg.sender)];
        // make sure they're an owner
        if (ownerIndex == 0) return;
        uint ownerIndexBit = 2**ownerIndex;
        var pending = m_pending[_operation];
        if (pending.ownersDone & ownerIndexBit > 0) {
          pending.yetNeeded++;
          pending.ownersDone -= ownerIndexBit;
          Revoke(msg.sender, _operation);
        }
      }
    
      // Replaces an owner `_from` with another `_to`.
      function changeOwner(address _from, address _to) onlymanyowners(sha3(msg.data)) external {
        if (isOwner(_to)) return;
        uint ownerIndex = m_ownerIndex[uint(_from)];
        if (ownerIndex == 0) return;
    
        clearPending();
        m_owners[ownerIndex] = uint(_to);
        m_ownerIndex[uint(_from)] = 0;
        m_ownerIndex[uint(_to)] = ownerIndex;
        OwnerChanged(_from, _to);
      }
    
      function addOwner(address _owner) onlymanyowners(sha3(msg.data)) external {
        if (isOwner(_owner)) return;
    
        clearPending();
        if (m_numOwners >= c_maxOwners)
          reorganizeOwners();
        if (m_numOwners >= c_maxOwners)
          return;
        m_numOwners++;
        m_owners[m_numOwners] = uint(_owner);
        m_ownerIndex[uint(_owner)] = m_numOwners;
        OwnerAdded(_owner);
      }
    
      function removeOwner(address _owner) onlymanyowners(sha3(msg.data)) external {
        uint ownerIndex = m_ownerIndex[uint(_owner)];
        if (ownerIndex == 0) return;
        if (m_required > m_numOwners - 1) return;
    
        m_owners[ownerIndex] = 0;
        m_ownerIndex[uint(_owner)] = 0;
        clearPending();
        reorganizeOwners(); //make sure m_numOwner is equal to the number of owners and always points to the optimal free slot
        OwnerRemoved(_owner);
      }
    
      function changeRequirement(uint _newRequired) onlymanyowners(sha3(msg.data)) external {
        if (_newRequired > m_numOwners) return;
        m_required = _newRequired;
        clearPending();
        RequirementChanged(_newRequired);
      }
    
      // Gets an owner by 0-indexed position (using numOwners as the count)
      function getOwner(uint ownerIndex) external constant returns (address) {
        return address(m_owners[ownerIndex + 1]);
      }
    
      function isOwner(address _addr) constant returns (bool) {
        return m_ownerIndex[uint(_addr)] > 0;
      }
    
      function hasConfirmed(bytes32 _operation, address _owner) external constant returns (bool) {
        var pending = m_pending[_operation];
        uint ownerIndex = m_ownerIndex[uint(_owner)];
    
        // make sure they're an owner
        if (ownerIndex == 0) return false;
    
        // determine the bit to set for this owner.
        uint ownerIndexBit = 2**ownerIndex;
        return !(pending.ownersDone & ownerIndexBit == 0);
      }
    
      // constructor - stores initial daily limit and records the present day's index.
      function initDaylimit(uint _limit) only_uninitialized {
        m_dailyLimit = _limit;
        m_lastDay = today();
      }
      // (re)sets the daily limit. needs many of the owners to confirm. doesn't alter the amount already spent today.
      function setDailyLimit(uint _newLimit) onlymanyowners(sha3(msg.data)) external {
        m_dailyLimit = _newLimit;
      }
      // resets the amount already spent today. needs many of the owners to confirm.
      function resetSpentToday() onlymanyowners(sha3(msg.data)) external {
        m_spentToday = 0;
      }
    
      // throw unless the contract is not yet initialized.
      modifier only_uninitialized { if (m_numOwners > 0) throw; _; }
    
      // constructor - just pass on the owner array to the multiowned and
      // the limit to daylimit
      function initWallet(address[] _owners, uint _required, uint _daylimit) only_uninitialized {
        initDaylimit(_daylimit);
        initMultiowned(_owners, _required);
      }
    
      // kills the contract sending everything to `_to`.
      function kill(address _to) onlymanyowners(sha3(msg.data)) external {
        suicide(_to);
      }
    
      // Outside-visible transact entry point. Executes transaction immediately if below daily spend limit.
      // If not, goes into multisig process. We provide a hash on return to allow the sender to provide
      // shortcuts for the other confirmations (allowing them to avoid replicating the _to, _value
      // and _data arguments). They still get the option of using them if they want, anyways.
      function execute(address _to, uint _value, bytes _data) external onlyowner returns (bytes32 o_hash) {
        // first, take the opportunity to check that we're under the daily limit.
        if ((_data.length == 0 && underLimit(_value)) || m_required == 1) {
          // yes - just execute the call.
          address created;
          if (_to == 0) {
            created = create(_value, _data);
          } else {
            if (!_to.call.value(_value)(_data))
              throw;
          }
          SingleTransact(msg.sender, _value, _to, _data, created);
        } else {
          // determine our operation hash.
          o_hash = sha3(msg.data, block.number);
          // store if it's new
          if (m_txs[o_hash].to == 0 && m_txs[o_hash].value == 0 && m_txs[o_hash].data.length == 0) {
            m_txs[o_hash].to = _to;
            m_txs[o_hash].value = _value;
            m_txs[o_hash].data = _data;
          }
          if (!confirm(o_hash)) {
            ConfirmationNeeded(o_hash, msg.sender, _value, _to, _data);
          }
        }
      }
    
      function create(uint _value, bytes _code) internal returns (address o_addr) {
        assembly {
          o_addr := create(_value, add(_code, 0x20), mload(_code))
          jumpi(invalidJumpLabel, iszero(extcodesize(o_addr)))
        }
      }
    
      // confirm a transaction through just the hash. we use the previous transactions map, m_txs, in order
      // to determine the body of the transaction from the hash provided.
      function confirm(bytes32 _h) onlymanyowners(_h) returns (bool o_success) {
        if (m_txs[_h].to != 0 || m_txs[_h].value != 0 || m_txs[_h].data.length != 0) {
          address created;
          if (m_txs[_h].to == 0) {
            created = create(m_txs[_h].value, m_txs[_h].data);
          } else {
            if (!m_txs[_h].to.call.value(m_txs[_h].value)(m_txs[_h].data))
              throw;
          }
    
          MultiTransact(msg.sender, _h, m_txs[_h].value, m_txs[_h].to, m_txs[_h].data, created);
          delete m_txs[_h];
          return true;
        }
      }
    
      // INTERNAL METHODS
    
      function confirmAndCheck(bytes32 _operation) internal returns (bool) {
        // determine what index the present sender is:
        uint ownerIndex = m_ownerIndex[uint(msg.sender)];
        // make sure they're an owner
        if (ownerIndex == 0) return;
    
        var pending = m_pending[_operation];
        // if we're not yet working on this operation, switch over and reset the confirmation status.
        if (pending.yetNeeded == 0) {
          // reset count of confirmations needed.
          pending.yetNeeded = m_required;
          // reset which owners have confirmed (none) - set our bitmap to 0.
          pending.ownersDone = 0;
          pending.index = m_pendingIndex.length++;
          m_pendingIndex[pending.index] = _operation;
        }
        // determine the bit to set for this owner.
        uint ownerIndexBit = 2**ownerIndex;
        // make sure we (the message sender) haven't confirmed this operation previously.
        if (pending.ownersDone & ownerIndexBit == 0) {
          Confirmation(msg.sender, _operation);
          // ok - check if count is enough to go ahead.
          if (pending.yetNeeded <= 1) {
            // enough confirmations: reset and run interior.
            delete m_pendingIndex[m_pending[_operation].index];
            delete m_pending[_operation];
            return true;
          }
          else
          {
            // not enough: record that this owner in particular confirmed.
            pending.yetNeeded--;
            pending.ownersDone |= ownerIndexBit;
          }
        }
      }
    
      function reorganizeOwners() private {
        uint free = 1;
        while (free < m_numOwners)
        {
          while (free < m_numOwners && m_owners[free] != 0) free++;
          while (m_numOwners > 1 && m_owners[m_numOwners] == 0) m_numOwners--;
          if (free < m_numOwners && m_owners[m_numOwners] != 0 && m_owners[free] == 0)
          {
            m_owners[free] = m_owners[m_numOwners];
            m_ownerIndex[m_owners[free]] = free;
            m_owners[m_numOwners] = 0;
          }
        }
      }
    
      // checks to see if there is at least `_value` left from the daily limit today. if there is, subtracts it and
      // returns true. otherwise just returns false.
      function underLimit(uint _value) internal onlyowner returns (bool) {
        // reset the spend limit if we're on a different day to last time.
        if (today() > m_lastDay) {
          m_spentToday = 0;
          m_lastDay = today();
        }
        // check to see if there's enough left - if so, subtract and return true.
        // overflow protection                    // dailyLimit check
        if (m_spentToday + _value >= m_spentToday && m_spentToday + _value <= m_dailyLimit) {
          m_spentToday += _value;
          return true;
        }
        return false;
      }
    
      // determines today's index.
      function today() private constant returns (uint) { return now / 1 days; }
    
      function clearPending() internal {
        uint length = m_pendingIndex.length;
    
        for (uint i = 0; i < length; ++i) {
          delete m_txs[m_pendingIndex[i]];
    
          if (m_pendingIndex[i] != 0)
            delete m_pending[m_pendingIndex[i]];
        }
    
        delete m_pendingIndex;
      }
    
      // FIELDS
      address constant _walletLibrary = 0xcafecafecafecafecafecafecafecafecafecafe;
    
      // the number of owners that must confirm the same operation before it is run.
      uint public m_required;
      // pointer used to find a free slot in m_owners
      uint public m_numOwners;
    
      uint public m_dailyLimit;
      uint public m_spentToday;
      uint public m_lastDay;
    
      // list of owners
      uint[256] m_owners;
    
      uint constant c_maxOwners = 250;
      // index on the list of owners to allow reverse lookup
      mapping(uint => uint) m_ownerIndex;
      // the ongoing operations.
      mapping(bytes32 => PendingState) m_pending;
      bytes32[] m_pendingIndex;
    
      // pending transactions we have at present.
      mapping (bytes32 => Transaction) m_txs;
    }
    
    contract Wallet is WalletEvents {
    
      // WALLET CONSTRUCTOR
      //   calls the `initWallet` method of the Library in this context
      function Wallet(address[] _owners, uint _required, uint _daylimit) {
        // Signature of the Wallet Library's init function
        bytes4 sig = bytes4(sha3("initWallet(address[],uint256,uint256)"));
        address target = _walletLibrary;
    
        // Compute the size of the call data : arrays has 2
        // 32bytes for offset and length, plus 32bytes per element ;
        // plus 2 32bytes for each uint
        uint argarraysize = (2 + _owners.length);
        uint argsize = (2 + argarraysize) * 32;
    
        assembly {
          // Add the signature first to memory
          mstore(0x0, sig)
          // Add the call data, which is at the end of the
          // code
          codecopy(0x4,  sub(codesize, argsize), argsize)
          // Delegate call to the library
          delegatecall(sub(gas, 10000), target, 0x0, add(argsize, 0x4), 0x0, 0x0)
        }
      }
    
      // METHODS
    
      // gets called when no other function matches
      function() payable {
        // just being sent some cash?
        if (msg.value > 0)
          Deposit(msg.sender, msg.value);
        else if (msg.data.length > 0)
          _walletLibrary.delegatecall(msg.data);
      }
    
      // Gets an owner by 0-indexed position (using numOwners as the count)
      function getOwner(uint ownerIndex) constant returns (address) {
        return address(m_owners[ownerIndex + 1]);
      }
    
      // As return statement unavailable in fallback, explicit the method here
    
      function hasConfirmed(bytes32 _operation, address _owner) external constant returns (bool) {
        return _walletLibrary.delegatecall(msg.data);
      }
    
      function isOwner(address _addr) constant returns (bool) {
        return _walletLibrary.delegatecall(msg.data);
      }
    
      // FIELDS
      address constant _walletLibrary = 0x863df6bfa4469f3ead0be8f9f2aae51c91a907b4;
    
      // the number of owners that must confirm the same operation before it is run.
      uint public m_required;
      // pointer used to find a free slot in m_owners
      uint public m_numOwners;
    
      uint public m_dailyLimit;
      uint public m_spentToday;
      uint public m_lastDay;
    
      // list of owners
      uint[256] m_owners;
    }

    File 3 of 3: MultiCertifier
    //! MultiCertifier contract.
    //! By Parity Technologies, 2017.
    //! Released under the Apache Licence 2.
    
    pragma solidity ^0.4.16;
    
    // From Owned.sol
    contract Owned {
    	modifier only_owner { if (msg.sender != owner) return; _; }
    
    	event NewOwner(address indexed old, address indexed current);
    
    	function setOwner(address _new) public only_owner { NewOwner(owner, _new); owner = _new; }
    
    	address public owner = msg.sender;
    }
    
    // From Certifier.sol
    contract Certifier {
    	event Confirmed(address indexed who);
    	event Revoked(address indexed who);
    	function certified(address) public constant returns (bool);
    	function get(address, string) public constant returns (bytes32);
    	function getAddress(address, string) public constant returns (address);
    	function getUint(address, string) public constant returns (uint);
    }
    
    /**
     * Contract to allow multiple parties to collaborate over a certification contract.
     * Each certified account is associated with the delegate who certified it.
     * Delegates can be added and removed only by the contract owner.
     */
    contract MultiCertifier is Owned, Certifier {
    	modifier only_delegate { require (msg.sender == owner || delegates[msg.sender]); _; }
    	modifier only_certifier_of(address who) { require (msg.sender == owner || msg.sender == certs[who].certifier); _; }
    	modifier only_certified(address who) { require (certs[who].active); _; }
    	modifier only_uncertified(address who) { require (!certs[who].active); _; }
    
    	event Confirmed(address indexed who, address indexed by);
    	event Revoked(address indexed who, address indexed by);
    
    	struct Certification {
    		address certifier;
    		bool active;
    	}
    
    	function certify(address _who)
    		public
    		only_delegate
    		only_uncertified(_who)
    	{
    		certs[_who].active = true;
    		certs[_who].certifier = msg.sender;
    		Confirmed(_who, msg.sender);
    	}
    
    	function revoke(address _who)
    		public
    		only_certifier_of(_who)
    		only_certified(_who)
    	{
    		certs[_who].active = false;
    		Revoked(_who, msg.sender);
    	}
    
    	function certified(address _who) public constant returns (bool) { return certs[_who].active; }
    	function getCertifier(address _who) public constant returns (address) { return certs[_who].certifier; }
    	function addDelegate(address _new) public only_owner { delegates[_new] = true; }
    	function removeDelegate(address _old) public only_owner { delete delegates[_old]; }
    
    	mapping (address => Certification) certs;
    	mapping (address => bool) delegates;
    
    	/// Unused interface methods.
    	function get(address, string) public constant returns (bytes32) {}
    	function getAddress(address, string) public constant returns (address) {}
    	function getUint(address, string) public constant returns (uint) {}
    }