├── README.md ├── LICENSE ├── BasicToken.sol └── MultiSigWallet.sol /README.md: -------------------------------------------------------------------------------- 1 | # ProofContracts -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Proof 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /BasicToken.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.11; 2 | 3 | 4 | library SafeMath { 5 | function mul(uint256 a, uint256 b) internal constant returns (uint256) { 6 | uint256 c = a * b; 7 | assert(a == 0 || c / a == b); 8 | return c; 9 | } 10 | function div(uint256 a, uint256 b) internal constant returns (uint256) { 11 | uint256 c = a / b; 12 | return c; 13 | } 14 | function sub(uint256 a, uint256 b) internal constant returns (uint256) { 15 | assert(b <= a); 16 | return a - b; 17 | } 18 | function add(uint256 a, uint256 b) internal constant returns (uint256) { 19 | uint256 c = a + b; 20 | assert(c >= a); 21 | return c; 22 | } 23 | } 24 | 25 | contract BasicToken { 26 | 27 | using SafeMath for uint256; 28 | 29 | mapping (address => mapping (address => uint256)) allowed; 30 | mapping(address => uint256) balances; 31 | 32 | uint256 public totalSupply; 33 | uint256 public decimals; 34 | address public owner; 35 | bytes32 public symbol; 36 | 37 | event Transfer(address indexed from, address indexed to, uint256 value); 38 | event Approval(address indexed _owner, address indexed spender, uint256 value); 39 | 40 | /* Edit these variables to set token initial issue */ 41 | /* Change the function BasicToken() name to to change name*/ 42 | function BasicToken(){ 43 | totalSupply = 1000; 44 | symbol = "^"; 45 | owner = msg.sender; /* For Platform: Add hardcoded address so we can pay for creation */ 46 | balances[msg.sender] = totalSupply; 47 | decimals = 0; 48 | } 49 | 50 | function balanceOf(address _owner) constant returns (uint256 balance) { 51 | return balances[_owner]; 52 | } 53 | 54 | function allowance(address _owner, address _spender) constant returns (uint256 remaining) { 55 | return allowed[_owner][_spender]; 56 | } 57 | 58 | function transfer(address _to, uint256 _value) returns (bool) { 59 | balances[msg.sender] = balances[msg.sender].sub(_value); 60 | balances[_to] = balances[_to].add(_value); 61 | Transfer(msg.sender, _to, _value); 62 | return true; 63 | } 64 | 65 | function transferFrom(address _from, address _to, uint256 _value) returns (bool) { 66 | var _allowance = allowed[_from][msg.sender]; 67 | balances[_to] = balances[_to].add(_value); 68 | balances[_from] = balances[_from].sub(_value); 69 | allowed[_from][msg.sender] = _allowance.sub(_value); 70 | Transfer(_from, _to, _value); 71 | return true; 72 | } 73 | 74 | function approve(address _spender, uint256 _value) returns (bool) { 75 | require((_value == 0) || (allowed[msg.sender][_spender] == 0)); 76 | allowed[msg.sender][_spender] = _value; 77 | Approval(msg.sender, _spender, _value); 78 | return true; 79 | } 80 | 81 | function (){ 82 | revert(); 83 | } 84 | 85 | 86 | } 87 | -------------------------------------------------------------------------------- /MultiSigWallet.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.4; 2 | 3 | 4 | /// @title Multisignature wallet - Allows multiple parties to agree on transactions before execution. 5 | /// @author Stefan George - 6 | contract MultiSigWallet { 7 | 8 | event Confirmation(address sender, bytes32 transactionHash); 9 | event Revocation(address sender, bytes32 transactionHash); 10 | event Submission(bytes32 transactionHash); 11 | event Execution(bytes32 transactionHash); 12 | event Deposit(address sender, uint value); 13 | event OwnerAddition(address owner); 14 | event OwnerRemoval(address owner); 15 | event RequiredUpdate(uint required); 16 | 17 | mapping (bytes32 => Transaction) public transactions; 18 | mapping (bytes32 => mapping (address => bool)) public confirmations; 19 | mapping (address => bool) public isOwner; 20 | address[] owners; 21 | bytes32[] transactionList; 22 | uint public required; 23 | 24 | struct Transaction { 25 | address destination; 26 | uint value; 27 | bytes data; 28 | uint nonce; 29 | bool executed; 30 | } 31 | 32 | modifier onlyWallet() { 33 | if (msg.sender != address(this)) 34 | throw; 35 | _; 36 | } 37 | 38 | modifier signaturesFromOwners(bytes32 transactionHash, uint8[] v, bytes32[] rs) { 39 | for (uint i=0; i _ownerCount 83 | || _required == 0 84 | || _ownerCount == 0) 85 | throw; 86 | _; 87 | } 88 | 89 | function addOwner(address owner) 90 | external 91 | onlyWallet 92 | ownerDoesNotExist(owner) 93 | { 94 | isOwner[owner] = true; 95 | owners.push(owner); 96 | OwnerAddition(owner); 97 | } 98 | 99 | function removeOwner(address owner) 100 | external 101 | onlyWallet 102 | ownerExists(owner) 103 | { 104 | isOwner[owner] = false; 105 | for (uint i=0; i owners.length) 112 | updateRequired(owners.length); 113 | OwnerRemoval(owner); 114 | } 115 | 116 | function updateRequired(uint _required) 117 | public 118 | onlyWallet 119 | validRequired(owners.length, _required) 120 | { 121 | required = _required; 122 | RequiredUpdate(_required); 123 | } 124 | 125 | function addTransaction(address destination, uint value, bytes data, uint nonce) 126 | private 127 | notNull(destination) 128 | returns (bytes32 transactionHash) 129 | { 130 | transactionHash = sha3(destination, value, data, nonce); 131 | if (transactions[transactionHash].destination == 0) { 132 | transactions[transactionHash] = Transaction({ 133 | destination: destination, 134 | value: value, 135 | data: data, 136 | nonce: nonce, 137 | executed: false 138 | }); 139 | transactionList.push(transactionHash); 140 | Submission(transactionHash); 141 | } 142 | } 143 | 144 | function submitTransaction(address destination, uint value, bytes data, uint nonce) 145 | external 146 | returns (bytes32 transactionHash) 147 | { 148 | transactionHash = addTransaction(destination, value, data, nonce); 149 | confirmTransaction(transactionHash); 150 | } 151 | 152 | function submitTransactionWithSignatures(address destination, uint value, bytes data, uint nonce, uint8[] v, bytes32[] rs) 153 | external 154 | returns (bytes32 transactionHash) 155 | { 156 | transactionHash = addTransaction(destination, value, data, nonce); 157 | confirmTransactionWithSignatures(transactionHash, v, rs); 158 | } 159 | 160 | function addConfirmation(bytes32 transactionHash, address owner) 161 | private 162 | notConfirmed(transactionHash, owner) 163 | { 164 | confirmations[transactionHash][owner] = true; 165 | Confirmation(owner, transactionHash); 166 | } 167 | 168 | function confirmTransaction(bytes32 transactionHash) 169 | public 170 | ownerExists(msg.sender) 171 | { 172 | addConfirmation(transactionHash, msg.sender); 173 | executeTransaction(transactionHash); 174 | } 175 | 176 | function confirmTransactionWithSignatures(bytes32 transactionHash, uint8[] v, bytes32[] rs) 177 | public 178 | signaturesFromOwners(transactionHash, v, rs) 179 | { 180 | for (uint i=0; i 0) 221 | Deposit(msg.sender, msg.value); 222 | } 223 | 224 | function isConfirmed(bytes32 transactionHash) 225 | public 226 | constant 227 | returns (bool) 228 | { 229 | uint count = 0; 230 | for (uint i=0; i 0) 263 | _transactionList[i] = _transactionListTemp[i]; 264 | } 265 | 266 | function getPendingTransactions() 267 | external 268 | constant 269 | returns (bytes32[] _transactionList) 270 | { 271 | return filterTransactions(true); 272 | } 273 | 274 | function getExecutedTransactions() 275 | external 276 | constant 277 | returns (bytes32[] _transactionList) 278 | { 279 | return filterTransactions(false); 280 | } 281 | } --------------------------------------------------------------------------------