Transaction Hash:
Block:
4961805 at Jan-24-2018 03:18:27 AM +UTC
Transaction Fee:
0.00341406 ETH
$8.61
Gas Used:
113,802 Gas / 30 Gwei
Emitted Events:
30 |
0x10e9c804d5419237f390fa06189bea54279f438f.0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef( 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef, 0x000000000000000000000000c4575b61286053c0ac362f70cdaa17becd90aacb, 0x000000000000000000000000d6e911edff4b1b3475fd276948324b98b295abd7, 0000000000000000000000000000000000000000000000b3c2be8f143b500000 )
|
31 |
0x10e9c804d5419237f390fa06189bea54279f438f.0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef( 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef, 0x000000000000000000000000c4575b61286053c0ac362f70cdaa17becd90aacb, 0x0000000000000000000000001a836128518533c4aa1a21e178cdeadba30addb8, 00000000000000000000000000000000000000000000000de801a9f565c9b999 )
|
32 |
0x10e9c804d5419237f390fa06189bea54279f438f.0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef( 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef, 0x000000000000000000000000c4575b61286053c0ac362f70cdaa17becd90aacb, 0x00000000000000000000000052b622010c2ac7a6bf50f86e3468b6f151085487, 00000000000000000000000000000000000000000000000b1e56ecbaf18fb008 )
|
33 |
Wallet.Deposit( from=[Receiver] Crowdsale, value=1010000000000000000 )
|
Account State Difference:
Address | Before | After | State Difference | ||
---|---|---|---|---|---|
0x10E9c804...4279F438f | |||||
0x5505b841...FeD15642e | 1,736.551695966213457747 Eth | 1,737.561695966213457747 Eth | 1.01 | ||
0x829BD824...93333A830
Miner
| (F2Pool Old) | 9,110.585043843079807565 Eth | 9,110.588457903079807565 Eth | 0.00341406 | |
0xC4575B61...ecD90aAcB | (GizaDevice: Token Sale) | ||||
0xD6E911ED...8b295ABd7 |
3.04763007375 Eth
Nonce: 10
|
2.03421601375 Eth
Nonce: 11
| 1.01341406 |
Execution Trace
ETH 1.01
Crowdsale.CALL( )
-
0x10e9c804d5419237f390fa06189bea54279f438f.70a08231( )
-
0x10e9c804d5419237f390fa06189bea54279f438f.a9059cbb( )
-
0x10e9c804d5419237f390fa06189bea54279f438f.a9059cbb( )
-
0x10e9c804d5419237f390fa06189bea54279f438f.a9059cbb( )
- ETH 1.01
Wallet.CALL( )
[Crowdsale (ln:424)]
buyTokens[Crowdsale (ln:425)]
calcTokensToSend[Crowdsale (ln:410)]
getCurrentTokenPriceInCents[Crowdsale (ln:363)]
Div[Crowdsale (ln:368)]
Mul[Crowdsale (ln:368)]
Div[Crowdsale (ln:369)]
Mul[Crowdsale (ln:373)]
Div[Crowdsale (ln:373)]
Add[Crowdsale (ln:382)]
Mul[Crowdsale (ln:382)]
Div[Crowdsale (ln:382)]
Mul[Crowdsale (ln:411)]
Add[Crowdsale (ln:415)]
transferTokens[Crowdsale (ln:418)]
revert[Crowdsale (ln:418)]
Add[Crowdsale (ln:419)]
Div[Crowdsale (ln:419)]
forwardFunds[Crowdsale (ln:420)]
transfer[Crowdsale (ln:389)]
File 1 of 2: Crowdsale
File 2 of 2: Wallet
pragma solidity ^0.4.18; /** * @title SafeMath for performing valid mathematics. */ library SafeMath { function Mul (uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } function Div (uint256 a, uint256 b) internal pure returns (uint256) { //assert(b > 0); // Solidity automatically throws when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } function Sub (uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function Add (uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } /** * Contract "Ownable" * Purpose: Defines Owner for contract * Status : Complete * */ contract Ownable { //owner variable to store contract owner account address public owner; //Constructor for the contract to store owner's account on deployement function Ownable() public { owner = msg.sender; } //modifier to check transaction initiator is only owner modifier onlyOwner() { require(msg.sender == owner); _; } } // ERC20 Interface contract ERC20 { uint256 public totalSupply; function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); function allowance(address owner, address spender) public view returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); event Transfer(address indexed from, address indexed to, uint256 value); } /** * @title GIZA to implement token */ contract GIZAToken is ERC20, Ownable { using SafeMath for uint256; //The name of the token bytes32 public name; //The token symbol bytes32 public symbol; //The precision used in the calculations in contract uint8 public decimals; //To denote the locking on transfer of tokens among token holders bool public locked; // Founder address. Need to froze for 8 moths address public founder; // Team address. Need to froze for 8 moths address public team; // Start of Pre-ICO date uint256 public start; //Mapping to relate number of token to the account mapping(address => uint256 ) balances; //Mapping to relate owner and spender to the tokens allowed to transfer from owner mapping(address => mapping(address => uint256)) allowed; event Burn(address indexed burner, uint indexed value); /** * @dev Constructor of GIZA */ function GIZAToken(address _founder, address _team) public { require( _founder != address(0) && _team != address(0) ); /* Public variables of the token */ //The name of the token name = "GIZA Token"; //The token symbol symbol = "GIZA"; //Number of zeroes to be treated as decimals decimals = 18; //initial token supply 0 totalSupply = 368e23; // 36 800 000 tokens total //Transfer of tokens is locked (not allowed) when contract is deployed locked = true; // Save founder and team address founder = _founder; team = _team; balances[msg.sender] = totalSupply; start = 0; } function startNow() external onlyOwner { start = now; } //To handle ERC20 short address attack modifier onlyPayloadSize(uint256 size) { require(msg.data.length >= size + 4); _; } modifier onlyUnlocked() { require (!locked); _; } modifier ifNotFroze() { if ( (msg.sender == founder || msg.sender == team) && (start == 0 || now < (start + 80 days) ) ) revert(); _; } //To enable transfer of tokens function unlockTransfer() external onlyOwner{ locked = false; } /** * @dev Check balance of given account address * * @param _owner The address account whose balance you want to know * @return balance of the account */ function balanceOf(address _owner) public view returns (uint256 _value){ return balances[_owner]; } /** * @dev Transfer tokens to an address given by sender * * @param _to The address which you want to transfer to * @param _value the amount of tokens to be transferred * @return A bool if the transfer was a success or not */ function transfer(address _to, uint256 _value) onlyPayloadSize(2 * 32) onlyUnlocked ifNotFroze public returns(bool _success) { require( _to != address(0) ); if((balances[msg.sender] > _value) && _value > 0){ balances[msg.sender] = balances[msg.sender].Sub(_value); balances[_to] = balances[_to].Add(_value); Transfer(msg.sender, _to, _value); return true; } else{ return false; } } /** * @dev Transfer tokens from one address to another, for ERC20. * * @param _from The address which you want to send tokens from * @param _to The address which you want to transfer to * @param _value the amount of tokens to be transferred * @return A bool if the transfer was a success or not */ function transferFrom(address _from, address _to, uint256 _value) onlyPayloadSize(3 * 32) onlyUnlocked ifNotFroze public returns (bool success){ require( _to != address(0) && (_from != address(0))); if((_value > 0) && (allowed[_from][msg.sender] > _value )){ balances[_from] = balances[_from].Sub(_value); balances[_to] = balances[_to].Add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].Sub(_value); Transfer(_from, _to, _value); return true; } else{ return false; } } /** * @dev Function to check the amount of tokens that an owner has allowed a spender to recieve from owner. * * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender to spend. */ function allowance(address _owner, address _spender) public view returns (uint256){ return allowed[_owner][_spender]; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool){ if( (_value > 0) && (_spender != address(0)) && (balances[msg.sender] >= _value)){ allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } else{ return false; } } // Only owner can burn own tokens function burn(uint _value) public onlyOwner { require(_value > 0); address burner = msg.sender; balances[burner] = balances[burner].Sub(_value); totalSupply = totalSupply.Sub(_value); Burn(burner, _value); } } contract Crowdsale is Ownable { using SafeMath for uint256; GIZAToken token; address public token_address; address public owner; address founder; address team; address multisig; bool started = false; //price of token against 1 ether uint256 public dollarsForEther; //No of days for which pre ico will be open uint256 constant DURATION_PRE_ICO = 30; uint256 startBlock = 0; // Start timestamp uint256 tokensBought = 0; // Amount of bought tokens uint256 totalRaisedEth = 0; // Total raised ETH uint256 constant MAX_TOKENS_FIRST_7_DAYS_PRE_ICO = 11000000 * 1 ether; // 10 000 000 + 10% uint256 constant MAX_TOKENS_PRE_ICO = 14850000 * 1 ether; // max 14 850 000 tokens uint256 constant MAX_TOKENS_FIRST_5_DAYS_ICO = 3850000 * 1 ether; // 3 500 000 + 10% uint256 constant MAX_TOKENS_FIRST_10_DAYS_ICO = 10725000 * 1 ether; // 9 750 000 + 10% uint256 constant MAX_BOUNTY = 1390000 * 1 ether; uint256 bountySent = 0; enum CrowdsaleType { PreICO, ICO } CrowdsaleType etype = CrowdsaleType.PreICO; function Crowdsale(address _founder, address _team, address _multisig) public { require(_founder != address(0) && _team != address(0) && _multisig != address(0)); owner = msg.sender; team = _team; multisig = _multisig; founder = _founder; token = new GIZAToken(_founder, _team); token_address = address(token); } modifier isStarted() { require (started == true); _; } // Set current price of one Ether in dollars function setDollarForOneEtherRate(uint256 _dollars) public onlyOwner { dollarsForEther = _dollars; } function sendBounty(address _to, uint256 _amount) public onlyOwner returns(bool){ require(_amount != 0 && _to != address(0)); token.unlockTransfer(); uint256 totalToSend = _amount.Mul(1 ether); require(bountySent.Add(totalToSend) < MAX_BOUNTY); if ( transferTokens(_to, totalToSend) ){ bountySent = bountySent.Add(totalToSend); return true; }else return false; } function sendTokens(address _to, uint256 _amount) public onlyOwner returns(bool){ require(_amount != 0 && _to != address(0)); token.unlockTransfer(); return transferTokens(_to, _amount.Mul(1 ether)); } //To start Pre ICO function startPreICO(uint256 _dollarForOneEtherRate) public onlyOwner { require(startBlock == 0 && _dollarForOneEtherRate > 0); //Set block number to current block number startBlock = now; //to show pre Ico is running etype = CrowdsaleType.PreICO; started = true; dollarsForEther = _dollarForOneEtherRate; token.startNow(); token.unlockTransfer(); } // Finish pre ICO. function endPreICO() public onlyOwner { started = false; } //to start ICO function startICO(uint256 _dollarForOneEtherRate) public onlyOwner{ //ico can be started only after the end of pre ico require( startBlock != 0 && now > startBlock.Add(DURATION_PRE_ICO) ); startBlock = now; //to show iCO IS running etype = CrowdsaleType.ICO; started = true; dollarsForEther = _dollarForOneEtherRate; } // Get current price of token on current time interval function getCurrentTokenPriceInCents() public view returns(uint256){ require(startBlock != 0); uint256 _day = (now - startBlock).Div(1 days); // Pre-ICO if (etype == CrowdsaleType.PreICO){ require(_day <= DURATION_PRE_ICO && tokensBought < MAX_TOKENS_PRE_ICO); if (_day >= 0 && _day <= 7 && tokensBought < MAX_TOKENS_FIRST_7_DAYS_PRE_ICO) return 20; // $0.2 else return 30; // $0.3 // ICO } else { if (_day >= 0 && _day <= 5 && tokensBought < MAX_TOKENS_FIRST_5_DAYS_ICO) return 60; // $0.6 else if (_day > 5 && _day <= 10 && tokensBought < MAX_TOKENS_FIRST_10_DAYS_ICO) return 80; // $0.8 else return 100; // $1 } } // Calculate tokens to send function calcTokensToSend(uint256 _value) internal view returns (uint256){ require (_value > 0); // Current token price in cents uint256 currentTokenPrice = getCurrentTokenPriceInCents(); // Calculate value in dollars*100 // _value in dollars * 100 // Example: for $54.38 valueInDollars = 5438 uint256 valueInDollars = _value.Mul(dollarsForEther).Div(10**16); uint256 tokensToSend = valueInDollars.Div(currentTokenPrice); // Calculate bonus by purshase uint8 bonusPercent = 0; _value = _value.Div(1 ether).Mul(dollarsForEther); if ( _value >= 35000 ){ bonusPercent = 10; }else if ( _value >= 20000 ){ bonusPercent = 7; }else if ( _value >= 10000 ){ bonusPercent = 5; } // Add bonus tokens if (bonusPercent > 0) tokensToSend = tokensToSend.Add(tokensToSend.Div(100).Mul(bonusPercent)); return tokensToSend; } // Transfer funds to owner function forwardFunds(uint256 _value) internal { multisig.transfer(_value); } // transfer tokens function transferTokens(address _to, uint256 _tokensToSend) internal returns(bool){ uint256 tot = _tokensToSend.Mul(1222).Div(8778); // 5.43 + 6.79 = 12.22, 10000 - 1222 = 8778 uint256 tokensForTeam = tot.Mul(4443).Div(1e4);// 5.43% for Team (44,43% of (5.43 + 6.79) ) uint256 tokensForFounder = tot.Sub(tokensForTeam);// 6.79% for Founders uint256 totalToSend = _tokensToSend.Add(tokensForFounder).Add(tokensForTeam); if (token.balanceOf(this) >= totalToSend && token.transfer(_to, _tokensToSend) == true){ token.transfer(founder, tokensForFounder); token.transfer(team, tokensForTeam); tokensBought = tokensBought.Add(totalToSend); return true; }else return false; } function buyTokens(address _beneficiary) public isStarted payable { require(_beneficiary != address(0) && msg.value != 0 ); uint256 tokensToSend = calcTokensToSend(msg.value); tokensToSend = tokensToSend.Mul(1 ether); // Pre-ICO if (etype == CrowdsaleType.PreICO){ require(tokensBought.Add(tokensToSend) < MAX_TOKENS_PRE_ICO); } if (!transferTokens(_beneficiary, tokensToSend)) revert(); totalRaisedEth = totalRaisedEth.Add( (msg.value).Div(1 ether) ); forwardFunds(msg.value); } // Fallback function function () public payable { buyTokens(msg.sender); } // Burn unsold tokens function burnTokens() public onlyOwner { token.burn( token.balanceOf(this) ); started = false; } // destroy this contract function kill() public onlyOwner{ selfdestruct(multisig); } }
File 2 of 2: Wallet
//sol Wallet // Multi-sig, daily-limited account proxy/wallet. // @authors: // Gav Wood <[email protected]> // 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. contract multiowned { // TYPES // struct for the status of a pending operation. struct PendingState { uint yetNeeded; uint ownersDone; uint index; } // EVENTS // this contract only has five 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); // 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 // constructor is given number of sigs required to do protected "onlymanyowners" transactions // as well as the selection of addresses capable of confirming them. function multiowned(address[] _owners, uint _required) { 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, block.number)) 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, block.number)) 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, block.number)) 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, block.number)) external { if (_newRequired > m_numOwners) return; m_required = _newRequired; clearPending(); RequirementChanged(_newRequired); } function isOwner(address _addr) returns (bool) { return m_ownerIndex[uint(_addr)] > 0; } function hasConfirmed(bytes32 _operation, address _owner) 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; if (pending.ownersDone & ownerIndexBit == 0) { return false; } else { 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 returns (bool) { 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; } } } function clearPending() internal { uint length = m_pendingIndex.length; for (uint i = 0; i < length; ++i) if (m_pendingIndex[i] != 0) delete m_pending[m_pendingIndex[i]]; delete m_pendingIndex; } // FIELDS // 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; // 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; } // inheritable "property" contract that enables methods to be protected by placing a linear limit (specifiable) // on a particular resource per calendar day. is multiowned to allow the limit to be altered. resource that method // uses is specified in the modifier. contract daylimit is multiowned { // MODIFIERS // simple modifier for daily limit. modifier limitedDaily(uint _value) { if (underLimit(_value)) _ } // METHODS // constructor - stores initial daily limit and records the present day's index. function daylimit(uint _limit) { 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, block.number)) external { m_dailyLimit = _newLimit; } // (re)sets the daily limit. needs many of the owners to confirm. doesn't alter the amount already spent today. function resetSpentToday() onlymanyowners(sha3(msg.data, block.number)) external { m_spentToday = 0; } // INTERNAL METHODS // 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. 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; } // FIELDS uint public m_dailyLimit; uint public m_spentToday; uint public m_lastDay; } // interface contract for multisig proxy contracts; see below for docs. contract multisig { // EVENTS // logged events: // 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); // 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); // Confirmation still needed for a transaction. event ConfirmationNeeded(bytes32 operation, address initiator, uint value, address to, bytes data); // FUNCTIONS // TODO: document function changeOwner(address _from, address _to) external; function execute(address _to, uint _value, bytes _data) external returns (bytes32); function confirm(bytes32 _h) returns (bool); } // usage: // bytes32 h = Wallet(w).from(oneOwner).transact(to, value, data); // Wallet(w).from(anotherOwner).confirm(h); contract Wallet is multisig, multiowned, daylimit { uint public version = 2; // TYPES // Transaction structure to remember details of transaction lest it need be saved for a later call. struct Transaction { address to; uint value; bytes data; } // METHODS // constructor - just pass on the owner array to the multiowned and // the limit to daylimit function Wallet(address[] _owners, uint _required, uint _daylimit) multiowned(_owners, _required) daylimit(_daylimit) { } // kills the contract sending everything to `_to`. function kill(address _to) onlymanyowners(sha3(msg.data, block.number)) external { suicide(_to); } // gets called when no other function matches function() { // just being sent some cash? if (msg.value > 0) Deposit(msg.sender, msg.value); } // Outside-visible transact entry point. Executes transacion 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 _r) { // first, take the opportunity to check that we're under the daily limit. if (underLimit(_value)) { SingleTransact(msg.sender, _value, _to, _data); // yes - just execute the call. _to.call.value(_value)(_data); return 0; } // determine our operation hash. _r = sha3(msg.data, block.number); if (!confirm(_r) && m_txs[_r].to == 0) { m_txs[_r].to = _to; m_txs[_r].value = _value; m_txs[_r].data = _data; ConfirmationNeeded(_r, msg.sender, _value, _to, _data); } } // 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) { if (m_txs[_h].to != 0) { m_txs[_h].to.call.value(m_txs[_h].value)(m_txs[_h].data); MultiTransact(msg.sender, _h, m_txs[_h].value, m_txs[_h].to, m_txs[_h].data); delete m_txs[_h]; return true; } } // INTERNAL METHODS function clearPending() internal { uint length = m_pendingIndex.length; for (uint i = 0; i < length; ++i) delete m_txs[m_pendingIndex[i]]; super.clearPending(); } // FIELDS // pending transactions we have at present. mapping (bytes32 => Transaction) m_txs; }