├── BCAPTokenDeploy.js ├── README.md ├── abi └── BCAPToken.abi ├── bin └── BCAPToken.bin ├── description.pdf ├── doc ├── BCAPToken.docdev ├── BCAPToken.docuser ├── api.md ├── functional-requirements.md └── storage.md └── sol ├── AbstractToken.sol ├── BCAPToken.sol ├── SafeMath.sol ├── StandardToken.sol └── Token.sol /BCAPTokenDeploy.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Deployment script for Blockchain Capital Token Smart Contract. 3 | * Copyright © 2017 by ABDK Consulting. 4 | */ 5 | 6 | if (!web3.eth.contract ([{"constant":false,"inputs":[],"name":"freezeTransfers","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_value","type":"uint256"}],"name":"approve","outputs":[{"name":"success","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"supply","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transferFrom","outputs":[{"name":"success","type":"bool"}],"payable":false,"type":"function"},{"constant":false,"inputs":[],"name":"unfreezeTransfers","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"}],"name":"balanceOf","outputs":[{"name":"balance","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transfer","outputs":[{"name":"success","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"},{"name":"_spender","type":"address"}],"name":"allowance","outputs":[{"name":"remaining","type":"uint256"}],"payable":false,"type":"function"},{"inputs":[{"name":"_tokenIssuer","type":"address"}],"payable":false,"type":"constructor"},{"anonymous":false,"inputs":[],"name":"Freeze","type":"event"},{"anonymous":false,"inputs":[],"name":"Unfreeze","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_from","type":"address"},{"indexed":true,"name":"_to","type":"address"},{"indexed":false,"name":"_value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_owner","type":"address"},{"indexed":true,"name":"_spender","type":"address"},{"indexed":false,"name":"_value","type":"uint256"}],"name":"Approval","type":"event"}]).new ( 7 | tokenIssuer, 8 | {from: web3.eth.accounts[0], data: "0x60606040526003805460a060020a60ff0219169055341561001c57fe5b6040516020806107c483398101604052515b805b5b5b60028054600160a060020a031916600160a060020a038316908117909155600090815260208190526040902060001990555b5060038054600160a060020a031916600160a060020a0383161790555b505b610732806100926000396000f300606060405236156100725763ffffffff60e060020a600035041663015024608114610074578063095ea7b31461008657806318160ddd146100b957806323b872dd146100db57806331c420d41461011457806370a0823114610126578063a9059cbb14610154578063dd62ed3e14610187575bfe5b341561007c57fe5b6100846101bb565b005b341561008e57fe5b6100a5600160a060020a036004351660243561023b565b604080519115158252519081900360200190f35b34156100c157fe5b6100c96102a6565b60408051918252519081900360200190f35b34156100e357fe5b6100a5600160a060020a03600435811690602435166044356102d4565b604080519115158252519081900360200190f35b341561011c57fe5b610084610307565b005b341561012e57fe5b6100c9600160a060020a0360043516610380565b60408051918252519081900360200190f35b341561015c57fe5b6100a5600160a060020a03600435166024356103b1565b604080519115158252519081900360200190f35b341561018f57fe5b6100c9600160a060020a03600435811690602435166103e6565b60408051918252519081900360200190f35b60035433600160a060020a039081169116146101d75760006000fd5b60035460a060020a900460ff161515610238576003805474ff0000000000000000000000000000000000000000191660a060020a1790556040517f615acbaede366d76a8b8cb2a9ada6a71495f0786513d71aa97aaf0c3910b78de90600090a15b5b565b600160a060020a03338116600081815260016020908152604080832094871680845294825280832086905580518681529051929493927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929181900390910190a35060015b92915050565b600254600160a060020a03166000908152602081905260408120546102ce9060001990610413565b90505b90565b60035460009060a060020a900460ff16156102f1575060006102ff565b6102fc84848461042e565b90505b5b9392505050565b60035433600160a060020a039081169116146103235760006000fd5b60035460a060020a900460ff1615610238576003805474ff0000000000000000000000000000000000000000191690556040517f2f05ba71d0df11bf5fa562a6569d70c4f80da84284badbe015ce1456063d0ded90600090a15b5b565b600254600090600160a060020a038381169116146103a6576103a1826105c5565b6103a9565b60005b90505b919050565b60035460009060a060020a900460ff16156103ce575060006102a0565b6103d883836105e4565b90506102a0565b5b92915050565b600160a060020a038083166000908152600160209081526040808320938516835292905220545b92915050565b6000818310156104235760006000fd5b508082035b92915050565b600160a060020a0380841660009081526001602090815260408083203390941683529290529081205482901015610467575060006102ff565b600160a060020a03841660009081526020819052604090205482901015610490575060006102ff565b600160a060020a03808516600090815260016020908152604080832033909416835292905220546104c19083610413565b600160a060020a038086166000908152600160209081526040808320339094168352929052908120919091558211801561050d575082600160a060020a031684600160a060020a031614155b156105ba57600160a060020a0384166000908152602081905260409020546105359083610413565b600160a060020a03808616600090815260208190526040808220939093559085168152205461056490836106e7565b600160a060020a038085166000818152602081815260409182902094909455805186815290519193928816927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a35b5060015b9392505050565b600160a060020a0381166000908152602081905260409020545b919050565b600160a060020a0333166000908152602081905260408120548290101561060d575060006102a0565b60008211801561062f575082600160a060020a031633600160a060020a031614155b156106dd57600160a060020a0333166000908152602081905260409020546106579083610413565b600160a060020a03338116600090815260208190526040808220939093559085168152205461068690836106e7565b600160a060020a03808516600081815260208181526040918290209490945580518681529051919333909316927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a35b5060015b92915050565b600081600019038311156106fb5760006000fd5b508181015b929150505600a165627a7a723058205e64ce47ca67e1c613a62eff9d1f0be90ee852f0ad9fa29c4ca14e102bb4215d0029", gas: 1000000}, 9 | function (e, r) { 10 | if (e) throw e; 11 | if (typeof r.address !== "undefined") { 12 | console.log ( 13 | "Deployed at " + r.address + " (tx: " + r.transactionHash + ")"); 14 | } 15 | }).transactionHash) { 16 | console.log ("Deployment failed. Probably web3.eth.accounts[0] is locked."); 17 | } 18 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Blockchain Capital Token Smart Contract # 2 | 3 | Blockchain Capital Token Smart Contract. 4 | Copyright © 2017 by ABDK Consulting. 5 | 6 | 7 | ## How to Deploy ## 8 | 9 | In order to deploy Blockchain Capital Token Smart Contract you need the 10 | following software to be properly installed on your system: 11 | 12 | 1. Geth 1.5.2+ (https://geth.ethereum.org/) 13 | 14 | Also, you need Ethereum node running on your system and synchronized with the 15 | network. If you do not have one, you may run it via one of the following 16 | commands depending on whether you want to connect to PRODNET or TESTNET: 17 | 18 | geth 19 | geth --testnet 20 | 21 | If you are running Ethereum node for the first time, you may also add "--fast" 22 | flag to speed up initial synchronization: 23 | 24 | geth --fast 25 | geth --testnet --fast 26 | 27 | Also you need at least one account in your node. If you do not have any 28 | accounts, you may create one using the following commands: 29 | 30 | geth attach 31 | > personal.newAccount (); 32 | > exit 33 | 34 | It will ask you to choose passphrase and enter it twice, and it will output an 35 | address of your new created account. 36 | 37 | You will also need some ether on your primary account. 38 | 39 | In order to deploy Blockchain Capital Token Smart Contract do the following: 40 | 41 | 1. Go to the directory containing deployment script, i.e. file named 42 | `BCAPTokenDeploy.js`. 43 | 2. Attach to your local Ethereum node: `geth attach` 44 | 3. Set token issuer address like this: 45 | `var tokenIssuer = "0xe489665cc93a8e3286bdd70a4e513360bcb14a48";` 46 | 4. Unlock your primary account: 47 | `personal.unlockAccount (web3.eth.accounts [0]);` (you will be 48 | asked for your passphrase here) 49 | 5. Run deployment script: `loadScript ("BCAPTokenDeploy.js");` 50 | 6. If everything will go fine, after several seconds you will see message like 51 | the following: `Deployed at ... (tx: ...)`, 52 | which means that your contract was deployed (message shows address of the 53 | contract and hash of the transaction the contract was deployed by) 54 | -------------------------------------------------------------------------------- /abi/BCAPToken.abi: -------------------------------------------------------------------------------- 1 | [{"constant":false,"inputs":[],"name":"freezeTransfers","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_value","type":"uint256"}],"name":"approve","outputs":[{"name":"success","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"supply","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transferFrom","outputs":[{"name":"success","type":"bool"}],"payable":false,"type":"function"},{"constant":false,"inputs":[],"name":"unfreezeTransfers","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"}],"name":"balanceOf","outputs":[{"name":"balance","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transfer","outputs":[{"name":"success","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"},{"name":"_spender","type":"address"}],"name":"allowance","outputs":[{"name":"remaining","type":"uint256"}],"payable":false,"type":"function"},{"inputs":[{"name":"_tokenIssuer","type":"address"}],"payable":false,"type":"constructor"},{"anonymous":false,"inputs":[],"name":"Freeze","type":"event"},{"anonymous":false,"inputs":[],"name":"Unfreeze","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_from","type":"address"},{"indexed":true,"name":"_to","type":"address"},{"indexed":false,"name":"_value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_owner","type":"address"},{"indexed":true,"name":"_spender","type":"address"},{"indexed":false,"name":"_value","type":"uint256"}],"name":"Approval","type":"event"}] -------------------------------------------------------------------------------- /bin/BCAPToken.bin: -------------------------------------------------------------------------------- 1 | 60606040526003805460a060020a60ff0219169055341561001c57fe5b6040516020806107c483398101604052515b805b5b5b60028054600160a060020a031916600160a060020a038316908117909155600090815260208190526040902060001990555b5060038054600160a060020a031916600160a060020a0383161790555b505b610732806100926000396000f300606060405236156100725763ffffffff60e060020a600035041663015024608114610074578063095ea7b31461008657806318160ddd146100b957806323b872dd146100db57806331c420d41461011457806370a0823114610126578063a9059cbb14610154578063dd62ed3e14610187575bfe5b341561007c57fe5b6100846101bb565b005b341561008e57fe5b6100a5600160a060020a036004351660243561023b565b604080519115158252519081900360200190f35b34156100c157fe5b6100c96102a6565b60408051918252519081900360200190f35b34156100e357fe5b6100a5600160a060020a03600435811690602435166044356102d4565b604080519115158252519081900360200190f35b341561011c57fe5b610084610307565b005b341561012e57fe5b6100c9600160a060020a0360043516610380565b60408051918252519081900360200190f35b341561015c57fe5b6100a5600160a060020a03600435166024356103b1565b604080519115158252519081900360200190f35b341561018f57fe5b6100c9600160a060020a03600435811690602435166103e6565b60408051918252519081900360200190f35b60035433600160a060020a039081169116146101d75760006000fd5b60035460a060020a900460ff161515610238576003805474ff0000000000000000000000000000000000000000191660a060020a1790556040517f615acbaede366d76a8b8cb2a9ada6a71495f0786513d71aa97aaf0c3910b78de90600090a15b5b565b600160a060020a03338116600081815260016020908152604080832094871680845294825280832086905580518681529051929493927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929181900390910190a35060015b92915050565b600254600160a060020a03166000908152602081905260408120546102ce9060001990610413565b90505b90565b60035460009060a060020a900460ff16156102f1575060006102ff565b6102fc84848461042e565b90505b5b9392505050565b60035433600160a060020a039081169116146103235760006000fd5b60035460a060020a900460ff1615610238576003805474ff0000000000000000000000000000000000000000191690556040517f2f05ba71d0df11bf5fa562a6569d70c4f80da84284badbe015ce1456063d0ded90600090a15b5b565b600254600090600160a060020a038381169116146103a6576103a1826105c5565b6103a9565b60005b90505b919050565b60035460009060a060020a900460ff16156103ce575060006102a0565b6103d883836105e4565b90506102a0565b5b92915050565b600160a060020a038083166000908152600160209081526040808320938516835292905220545b92915050565b6000818310156104235760006000fd5b508082035b92915050565b600160a060020a0380841660009081526001602090815260408083203390941683529290529081205482901015610467575060006102ff565b600160a060020a03841660009081526020819052604090205482901015610490575060006102ff565b600160a060020a03808516600090815260016020908152604080832033909416835292905220546104c19083610413565b600160a060020a038086166000908152600160209081526040808320339094168352929052908120919091558211801561050d575082600160a060020a031684600160a060020a031614155b156105ba57600160a060020a0384166000908152602081905260409020546105359083610413565b600160a060020a03808616600090815260208190526040808220939093559085168152205461056490836106e7565b600160a060020a038085166000818152602081815260409182902094909455805186815290519193928816927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a35b5060015b9392505050565b600160a060020a0381166000908152602081905260409020545b919050565b600160a060020a0333166000908152602081905260408120548290101561060d575060006102a0565b60008211801561062f575082600160a060020a031633600160a060020a031614155b156106dd57600160a060020a0333166000908152602081905260409020546106579083610413565b600160a060020a03338116600090815260208190526040808220939093559085168152205461068690836106e7565b600160a060020a03808516600081815260208181526040918290209490945580518681529051919333909316927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a35b5060015b92915050565b600081600019038311156106fb5760006000fd5b508181015b929150505600a165627a7a723058205e64ce47ca67e1c613a62eff9d1f0be90ee852f0ad9fa29c4ca14e102bb4215d0029 -------------------------------------------------------------------------------- /description.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BCAPtoken/BCAPToken/e93785baf24d2dbd4023526d49aa37f8ac8b9337/description.pdf -------------------------------------------------------------------------------- /doc/BCAPToken.docdev: -------------------------------------------------------------------------------- 1 | { 2 | "methods" : { 3 | "allowance(address,address)" : { 4 | "params" : { 5 | "_owner" : "address to get number of tokens allowed to be transferred\r from the owner of\r", 6 | "_spender" : "address to get number of tokens allowed to be transferred\r by the owner of\r" 7 | }, 8 | "return" : "number of tokens given spender is currently allowed to transfer\r from given owner\r" 9 | }, 10 | "approve(address,uint256)" : { 11 | "params" : { 12 | "_spender" : "address to allow the owner of to transfer tokens from\r message sender\r", 13 | "_value" : "number of tokens to allow to transfer\r" 14 | }, 15 | "return" : "true if token transfer was successfully approved, false otherwise\r" 16 | }, 17 | "balanceOf(address)" : { 18 | "params" : { 19 | "_owner" : "address to get number of tokens currently belonging to the\r owner of\r" 20 | }, 21 | "return" : "number of tokens currently belonging to the owner of given address\r" 22 | }, 23 | "totalSupply()" : { 24 | "return" : "total number of tokens in circulation\r" 25 | }, 26 | "transfer(address,uint256)" : { 27 | "params" : { 28 | "_to" : "address to transfer tokens to the owner of", 29 | "_value" : "number of tokens to transfer to the owner of given address" 30 | }, 31 | "return" : "true if tokens were transferred successfully, false otherwise" 32 | }, 33 | "transferFrom(address,address,uint256)" : { 34 | "params" : { 35 | "_from" : "address to transfer tokens from the owner of", 36 | "_to" : "address to transfer tokens to the owner of", 37 | "_value" : "number of tokens to transfer from given owner to given recipient" 38 | }, 39 | "return" : "true if tokens were transferred successfully, false otherwise" 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /doc/BCAPToken.docuser: -------------------------------------------------------------------------------- 1 | { 2 | "methods" : { 3 | "allowance(address,address)" : { 4 | "notice" : "Tell how many tokens given spender is currently allowed to transfer from\r given owner.\r " 5 | }, 6 | "approve(address,uint256)" : { 7 | "notice" : "Allow given spender to transfer given number of tokens from message sender.\r " 8 | }, 9 | "balanceOf(address)" : { 10 | "notice" : "Get number of tokens currently belonging to given owner.\r " 11 | }, 12 | "freezeTransfers()" : { 13 | "notice" : "Freeze token transfers." 14 | }, 15 | "totalSupply()" : { 16 | "notice" : "Get total number of tokens in circulation.\r " 17 | }, 18 | "transfer(address,uint256)" : { 19 | "notice" : "Transfer given number of tokens from message sender to given recipient." 20 | }, 21 | "transferFrom(address,address,uint256)" : { 22 | "notice" : "Transfer given number of tokens from given owner to given recipient." 23 | }, 24 | "unfreezeTransfers()" : { 25 | "notice" : "Unfreeze token transfers." 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /doc/api.md: -------------------------------------------------------------------------------- 1 | # Blockchain Capital Token Smart Contract: API 2 | 3 | This document defines and API of Blockchain Capital Token Smart Contract. 4 | 5 | ## 1. Constructor 6 | 7 | ### Signature 8 | 9 | function BCAPToken (address _tokenIssuer) 10 | 11 | ### Description 12 | 13 | Deploy smart contract with given token issuer address and makes token issuer to be the owner of smart contract. 14 | 15 | ### Use Cases 16 | 17 | * Administration:Deploy 18 | 19 | ## 2. Methods 20 | 21 | ### 2.1. totalSupply 22 | 23 | #### Signature 24 | 25 | function totalSupply () 26 | constant returns (uint256 totalSupply) 27 | 28 | #### Description 29 | 30 | Return total number of tokens in circulation. 31 | May be called by anybody. 32 | Does not accept ether. 33 | Defined by ERC-20. 34 | 35 | #### Use Cases 36 | 37 | * ERC-20:TotalSupply 38 | 39 | ### 2.2. balanceOf 40 | 41 | #### Signature 42 | 43 | function balanceOf (address _owner) 44 | constant returns (uint256 balance) 45 | 46 | Return number of tokens currently belonging to the owner of address _owner. 47 | May be called by anybody. 48 | Does not accept ether. 49 | Defined by ERC-20. 50 | 51 | #### Use Cases 52 | 53 | * ERC-20:BalanceOf 54 | 55 | ### 2.3. transfer 56 | 57 | #### Signature 58 | 59 | function transfer (address _to, uint356 _value) 60 | returns (bool success) 61 | 62 | #### Description 63 | 64 | Transfer _value tokens from message sender to the owner of address _to. 65 | Returns true on success, false on error. 66 | If this method returned false, it is guaranteed that state of the smart contract was not changed. 67 | May be called by anybody. 68 | Does not accept ether. 69 | Defined by ERC-20. 70 | 71 | #### Use Cases 72 | 73 | * ERC-20:Transfer 74 | 75 | ### 2.4. transferFrom 76 | 77 | #### Signature 78 | 79 | function transferFrom (address _from, address _to, uint256 _value) 80 | returns (bool success) 81 | 82 | #### Description 83 | 84 | Transfer _value tokens from the owner of address _from to the owner of address _to. 85 | The transfer should be approved in advance by the owner of address _from. 86 | Returns true on success, false on error. 87 | If this method returned false, it is guaranteed that state of the smart contract was not changed. 88 | May be called by anybody. 89 | Does not accept ether. 90 | Defined by ERC-20. 91 | 92 | #### Use Cases 93 | 94 | * ERC-20:TransferFrom 95 | 96 | ### 2.5. approve 97 | 98 | #### Signature 99 | 100 | function approve (address _spender, uint256 _value) 101 | returns (bool success) 102 | 103 | #### Description 104 | 105 | Allow the owner of address _spender to transfer _value tokens from message sender. 106 | Call to this method overrides any existing allowance of the owner of _spender address to transfer tokens belonging to message sender. 107 | Returns true on success, false on error. 108 | If this method returned false, it is guaranteed that state of the smart contract was not changed. 109 | May be called by anybody. 110 | Does not accept ether. 111 | Defined by ERC-20. 112 | 113 | #### Use Cases 114 | 115 | * ERC-20:Approve 116 | 117 | ### 2.6. allowance 118 | 119 | #### Signature 120 | 121 | function allowance (address _owner, address _spender) 122 | constant returns (uint256 remaining) 123 | 124 | #### Description 125 | 126 | Return number of tokens belonging to the owner of _owner address the owner of _spender address is currently allowed to transfer. 127 | May be called by anybody. 128 | Does not accept ether. 129 | Defined by ERC-20. 130 | 131 | #### Use Cases 132 | 133 | * ERC-20:Allowance 134 | 135 | ### 2.7. freezeTransfers 136 | 137 | #### Signature 138 | 139 | function freezeTransfers () 140 | 141 | #### Description 142 | 143 | Freeze transfers. 144 | May be called only by the owner of smart contract. 145 | Does not accept ether. 146 | 147 | #### Use Cases 148 | 149 | * Administration:Freeze 150 | 151 | ### 2.8. unfreezeTransfers 152 | 153 | #### Signature 154 | 155 | function unfreezeTransfers () 156 | 157 | #### Description 158 | 159 | Unfreeze transfers. 160 | May be called only by the owner of smart contract. 161 | Does not accept ether. 162 | 163 | #### Use Cases 164 | 165 | * Administration:Unfreeze 166 | 167 | ## 3. Events 168 | 169 | ### 3.1. Transfer 170 | 171 | #### Signature 172 | 173 | event Transfer (indexed address _from, indexed address _to, uint256 _value) 174 | 175 | #### Description 176 | 177 | Logged when _value tokens were transferred from the owner of address _from to the owner of address _to. 178 | 179 | #### Use Cases 180 | 181 | * ERC-20:Transfer 182 | * ERC-20:TransferFrom 183 | 184 | ### 3.2. Approval 185 | 186 | #### Signature 187 | 188 | event Approval (indexed address _owner, indexed address _spender, uint256 _value) 189 | 190 | #### Description 191 | 192 | Logged with owner of address _owner allowed the owner of address _spender to transfer _value of tokens belonging to the owner of address _owner. 193 | 194 | #### Use Cases 195 | 196 | * ERC-20:Approve 197 | 198 | ### 3.3. Freeze 199 | 200 | #### Signature 201 | 202 | event Freeze () 203 | 204 | #### Description 205 | 206 | Logged when token transfers were frozen. 207 | 208 | #### Use Cases 209 | 210 | * Administracion:Freeze 211 | 212 | ### 3.3. Unfreeze 213 | 214 | #### Signature 215 | 216 | event Unfreeze () 217 | 218 | #### Description 219 | 220 | Logged when token transfers were unfrozen. 221 | 222 | #### Use Cases 223 | 224 | * Administracion:Unfreeze 225 | -------------------------------------------------------------------------------- /doc/functional-requirements.md: -------------------------------------------------------------------------------- 1 | # Blockchain Capital Token Smart Contract: Functional Requirements 2 | 3 | This document summarizes functional requirements for Blockchain Capital Token Smart 4 | Contract. 5 | 6 | ## 0. Introduction 7 | 8 | Blockchain Capital Token Smart Contract is an [ERC-20](https://github.com/ethereum/EIPs/issues/20) compliant [Ethereum](https://ethereum.org) smart contract that manages Blockchain Capital Tokens - lightweight cryptocurrency whose units represents shares in Blockchain Capital investment fund. 9 | The following sections of this document describe functional requirements for Blockchain Capital Token Smart Contract. 10 | 11 | ## 1. Use Cases 12 | 13 | This sections describes use cases for Blockchain Capital Token Smart Contract. 14 | Related use cases are grouped into following functional. 15 | 16 | ### 1.1. ERC-20 Functional Block 17 | 18 | This functional block contains use cases required by [ERC-20](https://github.com/ethereum/EIPs/issues/20) standard. 19 | 20 | #### 1.1.1. ERC-20:TotalSupply 21 | 22 | **Actors**: *User*, *Smart Contract* 23 | 24 | **Goal:** *User* wants to know how many tokens are currently in circulation 25 | 26 | ##### Main Flow: 27 | 28 | 1. *User* calls constant method on *Smart Contract* 29 | 2. *Smart Contract* returns to *User* total number of tokens in circulation 30 | 31 | #### 1.1.2. ERC-20:BalanceOf 32 | 33 | **Actors**: *User*, *Smart Contract* 34 | 35 | **Goal:** *User* wants to know how many tokens are currently belonging to the owner of certain address 36 | 37 | ##### Main Flow: 38 | 39 | 1. *User* calls constant method on *Smart Contract* providing the following information as method parameters: address to get number of tokens currently belonging to the owner of 40 | 2. *Smart Contract* returns to *User* number of tokens currently belonging to the owner of given address 41 | 42 | #### 1.1.3. ERC-20:Transfer 43 | 44 | **Actors**: *User*, *Smart Contract* 45 | 46 | **Goal**: *User* wants to transfer some of his tokens to the owner of certain address 47 | 48 | ##### Main Flow: 49 | 50 | 1. *User* calls method on *Smart Contract* providing the following information as method parameters: address to transfer tokens to the owner of and number of tokens to transfer 51 | 2. Token transfers are not currently frozen 52 | 3. *User* is not token issuer 53 | 4. There are enough tokens currently belonging to *User* 54 | 5. Destination address is not token issuer address 55 | 6. *Smart Contract* transfers requested number of tokens from *User* to the owner of given address 56 | 7. Some tokens actually did change hands during the transfer, i.e. destination address was not the same as *User*'s own address and number of tokens transferred is greater than zero 57 | 8. *Smart Contract* logs tokens transfer event with the following information: address tokens were transferred from the owner of, address tokens were transferred to the owner of, and number of tokens transferred 58 | 9. *Smart Contract* returns success indicator to *User* 59 | 60 | ##### Exceptional Flow #1: 61 | 62 | 1. Same as in Main Flow 63 | 2. Token transfers are currently frozen 64 | 3. *Smart Contract* returns error indicator to *User* 65 | 66 | ##### Exceptional Flow #2: 67 | 68 | 1. Same as in Main Flow 69 | 2. Same as in Main Flow 70 | 3. *User* is token issuer 71 | 4. Number of tokens currently in circulation plus number of tokens to transfer is not greater than maximum allowed number of tokens in circulation 72 | 5. Destination address in not token issuer address 73 | 6. *Smart Contract* creates as many new tokens as many tokens are to be transferred 74 | 7. *Smart Contract* transfers newly created tokens to the owner of given address 75 | 8. Some tokens were actually created, i.e. number of tokens created is greater than zero 76 | 9. *Smart Contract* logs tokens transfer event with the following information: token issuer address as source address, address tokens were transferred to the owner of, and number of tokens transferred 77 | 10. *Smart Contract* returns success indicator to *User* 78 | 79 | ##### Exceptional Flow #3: 80 | 81 | 1. Same as in Main Flow 82 | 2. Same as in Main Flow 83 | 3. Same as in Exceptional Flow #2 84 | 4. Number of tokens currently in circulation plus number of tokens to transfer is greater than maximum allowed number of tokens in circulation 85 | 5. *Smart Contract* returns error indicator to *User* 86 | 87 | ##### Exceptional Flow #4: 88 | 89 | 1. Same as in Main Flow 90 | 2. Same as in Main Flow 91 | 3. Same as in Exceptional Flow #2 92 | 4. Same as in Exceptional Flow #2 93 | 5. Destination address in token issuer address 94 | 6. *Smart Contract* returns success indicator to *User* 95 | 96 | ##### Exceptional Flow #5: 97 | 98 | 1. Same as in Main Flow 99 | 2. Same as in Main Flow 100 | 3. Same as in Exceptional Flow #2 101 | 4. Same as in Exceptional Flow #2 102 | 5. Same as in Exceptional Flow #2 103 | 6. Same as in Exceptional Flow #2 104 | 7. Same as in Exceptional Flow #2 105 | 8. No tokens were actually created, i.e. number of tokens created is zero 106 | 9. *Smart Contract* returns success indicator to *User* 107 | 108 | ##### Exceptional Flow #6: 109 | 110 | 1. Same as in Main Flow 111 | 2. Same as in Main Flow 112 | 3. Same as in Main Flow 113 | 4. There is not enough tokens currently belonging to *User* 114 | 5. *Smart Contract* returns error indicator to *User* 115 | 116 | ##### Exceptional Flow #7: 117 | 118 | 1. Same as in Main Flow 119 | 2. Same as in Main Flow 120 | 3. Same as in Main Flow 121 | 4. Same as in Main Flow 122 | 5. Destination address is token issuer address 123 | 6. *Smart Contract* destroys as many tokens belonging to *User* as many tokens are to be transferred 124 | 7. Some tokens actually were destroyed, i.e. number of tokens destroyed is greater than zero 125 | 8. *Smart Contract* logs tokens transfer event with the following information: *User* address as source address, token issuer address as destination address, and number of tokens destroyed 126 | 9. *Smart Contract* returns success indicator to *User* 127 | 128 | ##### Exceptional Flow #8: 129 | 130 | 1. Same as in Main Flow 131 | 2. Same as in Main Flow 132 | 3. Same as in Main Flow 133 | 4. Same as in Main Flow 134 | 5. Same as in Exceptional Flow #7 135 | 6. Same as in Exceptional Flow #7 136 | 7. No tokens were actually destroyed, i.e. number of tokens destroyed is zero 137 | 8. *Smart Contract* returns success indicator to *User* 138 | 139 | ##### Exceptional Flow 9: 140 | 141 | 1. Same as in Main Flow 142 | 2. Same as in Main Flow 143 | 3. Same as in Main Flow 144 | 4. Same as in Main Flow 145 | 5. Same as in Main Flow 146 | 6. Same as in Main Flow 147 | 7. No tokens actually did change hands during the transfer, i.e. destination address was *User*'s own address, or number of tokens transferred was zero 148 | 8. *Smart Contract* returns success indicator to *User* 149 | 150 | #### 1.1.4. ERC-20:TransferFrom 151 | 152 | **Actors**: *User*, *Smart Contract* 153 | 154 | **Goal**: *User* wants to transfer some of the tokens currently belonging to the owner of certain source address to the owner of certain destination address 155 | 156 | ##### Main Flow: 157 | 158 | 1. *User* calls method on *Smart Contract* providing the following information as method parameters: source address, destination address, and number of tokens to transfer 159 | 2. Token transfers are not currently frozen 160 | 3. *User* is currently allowed to transfer requested number of tokens from the owner of source address 161 | 4. Source address is not token issuer address 162 | 5. There are enough tokens currently belonging to the owner of source address 163 | 6. Destination address is not token issuer address 164 | 7. *Smart Contract* transfers requested number of tokens from the owner of source address to the owner of destination address 165 | 8. *Smart Contract* decreases by the number of tokens transferred the number of tokens *User* is allowed to transfer from the owner of source address 166 | 9. Some tokens actually did change hands during the transfer, i.e. destination address was not the same as source address and number of tokens transferred was greater than zero 167 | 10. *Smart Contract* logs token transfer event with the following information: source address, destination address, and number of tokens transferred 168 | 11. *Smart Contract* returns success indicator to *User* 169 | 170 | ##### Exceptional Flow #1: 171 | 172 | 1. Same as in Main Flow 173 | 2. Token transfers are currently frozen 174 | 3. *Smart Contract* returns error indicator to *User* 175 | 176 | ##### Exceptional Flow #2: 177 | 178 | 1. Same as in Main Flow 179 | 2. Same as in Main Flow 180 | 3. *User* is not currently allowed to transfer requested number of tokens from the owner of source address 181 | 4. *Smart Contract* returns error indicator to *User* 182 | 183 | ##### Exceptional flow #3: 184 | 185 | 1. Same as in Main Flow 186 | 2. Same as in Main Flow 187 | 3. Same as in Main Flow 188 | 4. Source address is token issuer address 189 | 5. Number of tokens currently in circulation plus number of tokens to transfer is not greater than maximum allowed number of tokens in circulation 190 | 6. Destination address is not token issuer address 191 | 7. *Smart Contract* creates as many new tokens as many tokens are to be transferred 192 | 8. *Smart Contract* transfers newly created tokens to the owner of given address 193 | 9. *Smart Contract* decreases by the number of tokens created the number of tokens *User* is allowed to transfer from the owner of source address 194 | 10. Some tokens were actually created, i.e. number of tokens created is greater than zero 195 | 11. *Smart Contract* logs token transfer event with the following information: source address, destination address, and number of tokens transferred 196 | 12. *Smart Contract* returns success indicator to *User* 197 | 198 | ##### Exceptional Flow #4: 199 | 200 | 1. Same as in Main Flow 201 | 2. Same as in Main Flow 202 | 3. Same as in Main Flow 203 | 4. Same as in Exceptional Flow #3 204 | 5. Number of tokens currently in circulation plus number of tokens to transfer is greater than maximum allowed number of tokens in circulation 205 | 6. *Smart Contract* returns error indicator to *User* 206 | 207 | ##### Exceptional Flow #5: 208 | 209 | 1. Same as in Main Flow 210 | 2. Same as in Main Flow 211 | 3. Same as in Main Flow 212 | 4. Same as in Exceptional Flow #3 213 | 5. Same as in Exceptional Flow #3 214 | 6. Destination address is token issuer address 215 | 7. *Smart Contract* returns success indicator to *User* 216 | 217 | ##### Exceptional Flow #6: 218 | 219 | 1. Same as in Main Flow 220 | 2. Same as in Main Flow 221 | 3. Same as in Main Flow 222 | 4. Same as in Exceptional Flow #3 223 | 5. Same as in Exceptional Flow #3 224 | 6. Same as in Exceptional Flow #3 225 | 7. Same as in Exceptional Flow #3 226 | 8. Same as in Exceptional Flow #3 227 | 9. Same as in Exceptional Flow #3 228 | 10. No tokens were actually created, i.e. number of tokens created is zero 229 | 11. *Smart Contract* returns success indicator to *User* 230 | 231 | ##### Exceptional Flow #7: 232 | 233 | 1. Same as in Main Flow 234 | 2. Same as in Main Flow 235 | 3. Same as in Main Flow 236 | 4. Same as in Main Flow 237 | 5. There are not enough tokens currently belonging to the owner of source address 238 | 6. *Smart Contract* returns error indicator to *User* 239 | 240 | ##### Exceptional Flow #8: 241 | 242 | 1. Same as in Main Flow 243 | 2. Same as in Main Flow 244 | 3. Same as in Main Flow 245 | 4. Same as in Main Flow 246 | 5. Same as in Main Flow 247 | 6. Destination address is token issuer address 248 | 7. *Smart Contract* destroys as many tokens belonging to *User* as many tokens are to be transferred 249 | 8. *Smart Contract* decreases by the number of tokens destroyed the number of tokens *User* is allowed to transfer from the owner of source address 250 | 9. Some tokens actually were destroyed, i.e. number of tokens destroyed is greater than zero 251 | 10. *Smart Contract* logs tokens transfer event with the following information: source address, destination address, and number of tokens destroyed 252 | 11. *Smart Contract* returns success indicator to *User* 253 | 254 | ##### Exceptional Flow #9: 255 | 256 | 1. Same as in Main Flow 257 | 2. Same as in Main Flow 258 | 3. Same as in Main Flow 259 | 4. Same as in Main Flow 260 | 5. Same as in Main Flow 261 | 6. Same as in Exceptional Flow #8 262 | 7. Same as in Exceptional Flow #8 263 | 8. Same as in Exceptional Flow #8 264 | 9. No tokens were actually destroyed, i.e. number of tokens destroyed is zero 265 | 10. *Smart Contract* returns success indicator to *User* 266 | 267 | ##### Exceptional Flow #10: 268 | 269 | 1. Same as in Main Flow 270 | 2. Same as in Main Flow 271 | 3. Same as in Main Flow 272 | 4. Same as in Main Flow 273 | 5. Same as in Main Flow 274 | 6. same as in Main Flow 275 | 7. same as in Main Flow 276 | 8. same as in Main Flow 277 | 9. No tokens actually did change hands during the transfer, i.e. destination address was the same as source address or number of tokens transferred was zero 278 | 10. *Smart Contract* returns success indicator to *User* 279 | 280 | #### 1.1.5. ERC-20:Approve 281 | 282 | **Actors**: *User*, *Smart Contract* 283 | 284 | **Goal**: *User* wants to set how many tokens belonging to *User* the owner of certain address is allowed to transfer 285 | 286 | ##### Main Flow: 287 | 288 | 1. *User* calls method on *Smart Contract* providing the following information as method parameters: address to allow the owner of to transfer tokens belonging to *User and number of tokens to allow transfer of 289 | 2. *Smart Contract* set the number of tokens belonging to *User* the owner of given address is allowed to transfer 290 | 3. *Smart Contract* logs token transfer approval event with the following information: *User*'s address, address the owner of was allowed to transfer tokens belonging to *User*, and number of tokens the transfer was allowed of 291 | 4. *Smart Contract* returns success indicator to *User* 292 | 293 | #### 1.1.6. ERC-20:Allowance 294 | 295 | **Actors**: *User*, *Smart Contract* 296 | 297 | **Goal**: *User* wants to know how many tokens belonging to the owner of certain source address the owner of certain spender address is currently allowed to transfer 298 | 299 | ##### Main Flow: 300 | 301 | 1. *User* calls constant method on *Smart Contract* providing the following information as method parameters: source address and spender address 302 | 2. *Smart Contract* returns to *User* the number of tokens belonging to the owner of source address the owner of spender address is currently allowed to transfer 303 | 304 | ### 1.2. Administration Functional Block 305 | 306 | This functional block contains use cases related to smart contract administration. 307 | 308 | #### 1.2.1. Administration:Deploy 309 | 310 | **Actors**: *User*, *Smart Contract* 311 | 312 | **Goal**: *User* wants to deploy *Smart Contract* with certain token issuer address 313 | 314 | ##### Main Flow: 315 | 316 | 1. *User* deploys *Smart Contract* providing the following information as constructor arguments: token issuer address 317 | 2. *Smart Contract* remember given token issuer address 318 | 319 | #### 1.2.2. Administration:Freeze 320 | 321 | **Actors**: *User*, *Smart Contract* 322 | 323 | **Goal**: *User* wants to freeze token transfers 324 | 325 | ##### Main Flow: 326 | 327 | 1. *User* calls method on *Smart Contract* 328 | 2. *User* is the owner of *Smart Contract* 329 | 3. Token transfers are not currently frozen 330 | 4. *Smart Contract* freezes token transfer 331 | 5. *Smart Contract* logs token transfers freeze event 332 | 333 | ##### Exceptional Flow #1: 334 | 335 | 1. Same as in Main Flow 336 | 2. *User* is not the owner of *Smart Contract* 337 | 3. *Smart Contract cancels transaction 338 | 339 | ##### Exceptional Flow #2: 340 | 341 | 1. Same as in Main Flow 342 | 2. Same as in Main Flow 343 | 3. Token transfers are currently frozen 344 | 4. *Smart Contract* does nothing 345 | 346 | #### 1.2.3. Administration:Unfreeze 347 | 348 | **Actors**: *User*, *Smart Contract* 349 | 350 | **Goal**: *User* wants to unfreeze token transfers 351 | 352 | ##### Main Flow: 353 | 354 | 1. *User* calls method on *Smart Contract* 355 | 2. *User* is the owner of *Smart Contract* 356 | 3. Token transfers are currently frozen 357 | 4. *Smart Contract* unfreezes token transfer 358 | 5. *Smart Contract* logs token transfers unfreeze event 359 | 360 | ##### Exceptional Flow #1: 361 | 362 | 1. Same as in Main Flow 363 | 2. *User* is not the owner of *Smart Contract* 364 | 3. *Smart Contract cancels transaction 365 | 366 | ##### Exceptional Flow #2: 367 | 368 | 1. Same as in Main Flow 369 | 2. Same as in Main Flow 370 | 3. Token transfers are not currently frozen 371 | 4. *Smart Contract* does nothing 372 | 373 | ## 2. Limits 374 | 375 | The following limits are established: 376 | 377 | Limit | Value 378 | --------------------------------------- | ------- 379 | Maximum number of tokens in circulation | 2^256-1 380 | -------------------------------------------------------------------------------- /doc/storage.md: -------------------------------------------------------------------------------- 1 | # Blockchain Capital Token Smart Contract: Storage 2 | 3 | This document describes storage structure of Blockchain Capital Token Smart 4 | Contract. 5 | 6 | ## 1. tokenIssuer 7 | 8 | ### Signature 9 | 10 | address tokenIssuer 11 | 12 | ### Description 13 | 14 | Token issuer address. 15 | 16 | ### Read in use cases 17 | 18 | * ERC-20:TotalSupply 19 | * ERC-20:BalanceOf 20 | 21 | ### Modified in use cases 22 | 23 | * Administration:Deploy 24 | 25 | ## 2. accounts 26 | 27 | ### Signature 28 | 29 | mapping (address => uint256) accounts 30 | 31 | ### Description 32 | 33 | If `owner` is not the token issuer address, value of `accounts [owner]` is the number of tokens currently belonging to the owner of address `owner`. If `owner` is token issuer address, value of `accounts [owner]` is maximum allowed number of tokens in circulation minus number of tokens currently in circulation or in other words, the number of tokens that still may be issued. 34 | 35 | ### Read in use cases 36 | 37 | * ERC-20:TotalSupply 38 | * ERC-20:BalanceOf 39 | * ERC-20:Transfer 40 | * ERC-20:TransferFrom 41 | 42 | ### Modified in use cases 43 | 44 | * ERC-20:Transfer 45 | * ERC-20:TransferFrom 46 | * Administration:Deploy 47 | 48 | ## 3. allowances 49 | 50 | ### Signature 51 | 52 | mapping (address => mapping (address => uint256)) allowances 53 | 54 | ### Description 55 | 56 | Value of `allowances [_owner][_spender]` is how many tokens belonging to the owner of address _owner the owner of address _spender is currently allowed to transfer. 57 | 58 | ### Read in use cases 59 | 60 | * ERC-20:TransferFrom 61 | * ERC-20:Allowance 62 | 63 | ### Modified in use cases 64 | 65 | * ERC-20:TransferFrom 66 | * ERC-20:Approve 67 | 68 | ## 4. owner 69 | 70 | ### Signature 71 | 72 | address owner 73 | 74 | ### Description 75 | 76 | Address of the owner of smart contract. 77 | 78 | ### Read in use cases 79 | 80 | * Administration:Freeze 81 | * Administraction:Unfreeze 82 | 83 | ### Modifier in use cases 84 | 85 | * Administration:Deploy 86 | 87 | ## 5. transfersFrozen 88 | 89 | ### Signature 90 | 91 | bool transfersFrozen 92 | 93 | ### Description 94 | 95 | Whether transfers are currently frozen or not. 96 | 97 | ### Read in use cases 98 | 99 | * ERC-20:Transfer 100 | * ERC-20:TransferFrom 101 | * ERC-20:Freeze 102 | * ERC-20:Unfreeze 103 | 104 | ### Modifier in use cases 105 | 106 | * ERC-20:Freeze 107 | * ERC-20:Unfreeze 108 | -------------------------------------------------------------------------------- /sol/AbstractToken.sol: -------------------------------------------------------------------------------- 1 | /* 2 | * Abstract Token Smart Contract. Copyright © 2017 by ABDK Consulting. 3 | */ 4 | pragma solidity ^0.4.1; 5 | 6 | import "./Token.sol"; 7 | import "./SafeMath.sol"; 8 | 9 | /** 10 | * Abstract Token Smart Contract that could be used as a base contract for 11 | * ERC-20 token contracts. 12 | */ 13 | contract AbstractToken is Token, SafeMath { 14 | /** 15 | * Create new Abstract Token contract. 16 | */ 17 | function AbstractToken () { 18 | // Do nothing 19 | } 20 | 21 | /** 22 | * Get number of tokens currently belonging to given owner. 23 | * 24 | * @param _owner address to get number of tokens currently belonging to the 25 | owner of 26 | * @return number of tokens currently belonging to the owner of given address 27 | */ 28 | function balanceOf (address _owner) constant returns (uint256 balance) { 29 | return accounts [_owner]; 30 | } 31 | 32 | /** 33 | * Transfer given number of tokens from message sender to given recipient. 34 | * 35 | * @param _to address to transfer tokens to the owner of 36 | * @param _value number of tokens to transfer to the owner of given address 37 | * @return true if tokens were transferred successfully, false otherwise 38 | */ 39 | function transfer (address _to, uint256 _value) returns (bool success) { 40 | if (accounts [msg.sender] < _value) return false; 41 | if (_value > 0 && msg.sender != _to) { 42 | accounts [msg.sender] = safeSub (accounts [msg.sender], _value); 43 | accounts [_to] = safeAdd (accounts [_to], _value); 44 | Transfer (msg.sender, _to, _value); 45 | } 46 | return true; 47 | } 48 | 49 | /** 50 | * Transfer given number of tokens from given owner to given recipient. 51 | * 52 | * @param _from address to transfer tokens from the owner of 53 | * @param _to address to transfer tokens to the owner of 54 | * @param _value number of tokens to transfer from given owner to given 55 | recipient 56 | * @return true if tokens were transferred successfully, false otherwise 57 | */ 58 | function transferFrom (address _from, address _to, uint256 _value) 59 | returns (bool success) { 60 | if (allowances [_from][msg.sender] < _value) return false; 61 | if (accounts [_from] < _value) return false; 62 | 63 | allowances [_from][msg.sender] = 64 | safeSub (allowances [_from][msg.sender], _value); 65 | 66 | if (_value > 0 && _from != _to) { 67 | accounts [_from] = safeSub (accounts [_from], _value); 68 | accounts [_to] = safeAdd (accounts [_to], _value); 69 | Transfer (_from, _to, _value); 70 | } 71 | return true; 72 | } 73 | 74 | /** 75 | * Allow given spender to transfer given number of tokens from message sender. 76 | * 77 | * @param _spender address to allow the owner of to transfer tokens from 78 | message sender 79 | * @param _value number of tokens to allow to transfer 80 | * @return true if token transfer was successfully approved, false otherwise 81 | */ 82 | function approve (address _spender, uint256 _value) returns (bool success) { 83 | allowances [msg.sender][_spender] = _value; 84 | Approval (msg.sender, _spender, _value); 85 | 86 | return true; 87 | } 88 | 89 | /** 90 | * Tell how many tokens given spender is currently allowed to transfer from 91 | * given owner. 92 | * 93 | * @param _owner address to get number of tokens allowed to be transferred 94 | * from the owner of 95 | * @param _spender address to get number of tokens allowed to be transferred 96 | * by the owner of 97 | * @return number of tokens given spender is currently allowed to transfer 98 | * from given owner 99 | */ 100 | function allowance (address _owner, address _spender) constant 101 | returns (uint256 remaining) { 102 | return allowances [_owner][_spender]; 103 | } 104 | 105 | /** 106 | * Mapping from addresses of token holders to the numbers of tokens belonging 107 | * to these token holders. 108 | */ 109 | mapping (address => uint256) accounts; 110 | 111 | /** 112 | * Mapping from addresses of token holders to the mapping of addresses of 113 | * spenders to the allowances set by these token holders to these spenders. 114 | */ 115 | mapping (address => mapping (address => uint256)) private allowances; 116 | } 117 | -------------------------------------------------------------------------------- /sol/BCAPToken.sol: -------------------------------------------------------------------------------- 1 | /* 2 | * Blockchain Capital Token Smart Contract. Copyright © 2017 by ABDK 3 | * Consulting. 4 | */ 5 | pragma solidity ^0.4.1; 6 | 7 | import "./StandardToken.sol"; 8 | 9 | /** 10 | * Blockchain Capital Token Smart Contract. 11 | */ 12 | contract BCAPToken is StandardToken { 13 | /** 14 | * Create new Blockchain Capital Token contract with given token issuer 15 | * address. 16 | * 17 | * @param _tokenIssuer address of token issuer 18 | */ 19 | function BCAPToken (address _tokenIssuer) 20 | StandardToken (_tokenIssuer) { 21 | owner = _tokenIssuer; 22 | } 23 | 24 | /** 25 | * Freeze token transfers. 26 | */ 27 | function freezeTransfers () { 28 | if (msg.sender != owner) throw; 29 | 30 | if (!transfersFrozen) { 31 | transfersFrozen = true; 32 | Freeze (); 33 | } 34 | } 35 | 36 | /** 37 | * Unfreeze token transfers. 38 | */ 39 | function unfreezeTransfers () { 40 | if (msg.sender != owner) throw; 41 | 42 | if (transfersFrozen) { 43 | transfersFrozen = false; 44 | Unfreeze (); 45 | } 46 | } 47 | 48 | /** 49 | * Transfer given number of tokens from message sender to given recipient. 50 | * 51 | * @param _to address to transfer tokens to the owner of 52 | * @param _value number of tokens to transfer to the owner of given address 53 | * @return true if tokens were transferred successfully, false otherwise 54 | */ 55 | function transfer (address _to, uint256 _value) returns (bool success) { 56 | if (transfersFrozen) return false; 57 | else return AbstractToken.transfer (_to, _value); 58 | } 59 | 60 | /** 61 | * Transfer given number of tokens from given owner to given recipient. 62 | * 63 | * @param _from address to transfer tokens from the owner of 64 | * @param _to address to transfer tokens to the owner of 65 | * @param _value number of tokens to transfer from given owner to given 66 | recipient 67 | * @return true if tokens were transferred successfully, false otherwise 68 | */ 69 | function transferFrom (address _from, address _to, uint256 _value) 70 | returns (bool success) { 71 | if (transfersFrozen) return false; 72 | else return AbstractToken.transferFrom (_from, _to, _value); 73 | } 74 | 75 | /** 76 | * Logged when transfers were frozen. 77 | */ 78 | event Freeze (); 79 | 80 | /** 81 | * Logged when transfers were unfrozen. 82 | */ 83 | event Unfreeze (); 84 | 85 | /** 86 | * Address of the owner of smart contract. Only owner is allowed to 87 | * freeze/unfreeze transfers. 88 | */ 89 | address owner; 90 | 91 | /** 92 | * Whether transfers are currently frozen or not. 93 | */ 94 | bool transfersFrozen = false; 95 | } 96 | -------------------------------------------------------------------------------- /sol/SafeMath.sol: -------------------------------------------------------------------------------- 1 | /* 2 | * Safe Math Smart Contract. Copyright © 2016 by ABDK Consulting. 3 | */ 4 | pragma solidity ^0.4.1; 5 | 6 | /** 7 | * Provides methods to safely add, subtract and multiply uint256 numbers. 8 | */ 9 | contract SafeMath { 10 | uint256 constant private MAX_UINT256 = 11 | 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF; 12 | 13 | /** 14 | * Add two uint256 values, throw in case of overflow. 15 | * 16 | * @param x first value to add 17 | * @param y second value to add 18 | * @return x + y 19 | */ 20 | function safeAdd (uint256 x, uint256 y) 21 | constant internal 22 | returns (uint256 z) { 23 | if (x > MAX_UINT256 - y) throw; 24 | return x + y; 25 | } 26 | 27 | /** 28 | * Subtract one uint256 value from another, throw in case of underflow. 29 | * 30 | * @param x value to subtract from 31 | * @param y value to subtract 32 | * @return x - y 33 | */ 34 | function safeSub (uint256 x, uint256 y) 35 | constant internal 36 | returns (uint256 z) { 37 | if (x < y) throw; 38 | return x - y; 39 | } 40 | 41 | /** 42 | * Multiply two uint256 values, throw in case of overflow. 43 | * 44 | * @param x first value to multiply 45 | * @param y second value to multiply 46 | * @return x * y 47 | */ 48 | function safeMul (uint256 x, uint256 y) 49 | constant internal 50 | returns (uint256 z) { 51 | if (y == 0) return 0; // Prevent division by zero at the next line 52 | if (x > MAX_UINT256 / y) throw; 53 | return x * y; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /sol/StandardToken.sol: -------------------------------------------------------------------------------- 1 | /* 2 | * Standard Token Smart Contract. Copyright © 2016 by ABDK Consulting. 3 | */ 4 | pragma solidity ^0.4.1; 5 | 6 | import "./AbstractToken.sol"; 7 | 8 | /** 9 | * Standard Token Smart Contract that implements ERC-20 token with special 10 | * unlimited supply "token issuer" account. 11 | */ 12 | contract StandardToken is AbstractToken { 13 | uint256 constant private MAX_UINT256 = 14 | 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF; 15 | 16 | /** 17 | * Create new Standard Token contract with given "token issuer" account. 18 | * 19 | * @param _tokenIssuer address of "token issuer" account 20 | */ 21 | function StandardToken (address _tokenIssuer) AbstractToken () { 22 | tokenIssuer = _tokenIssuer; 23 | accounts [_tokenIssuer] = MAX_UINT256; 24 | } 25 | 26 | /** 27 | * Get total number of tokens in circulation. 28 | * 29 | * @return total number of tokens in circulation 30 | */ 31 | function totalSupply () constant returns (uint256 supply) { 32 | return safeSub (MAX_UINT256, accounts [tokenIssuer]); 33 | } 34 | 35 | /** 36 | * Get number of tokens currently belonging to given owner. 37 | * 38 | * @param _owner address to get number of tokens currently belonging to the 39 | owner of 40 | * @return number of tokens currently belonging to the owner of given address 41 | */ 42 | function balanceOf (address _owner) constant returns (uint256 balance) { 43 | return _owner == tokenIssuer ? 0 : AbstractToken.balanceOf (_owner); 44 | } 45 | 46 | /** 47 | * Address of "token issuer" account. 48 | */ 49 | address private tokenIssuer; 50 | } 51 | -------------------------------------------------------------------------------- /sol/Token.sol: -------------------------------------------------------------------------------- 1 | /* 2 | * ERC-20 Standard Token Smart Contract Interface. 3 | * Copyright © 2016 by ABDK Consulting. 4 | */ 5 | pragma solidity ^0.4.1; 6 | 7 | /** 8 | * ERC-20 standard token interface, as defined 9 | * here. 10 | */ 11 | contract Token { 12 | /** 13 | * Get total number of tokens in circulation. 14 | * 15 | * @return total number of tokens in circulation 16 | */ 17 | function totalSupply () constant returns (uint256 supply); 18 | 19 | /** 20 | * Get number of tokens currently belonging to given owner. 21 | * 22 | * @param _owner address to get number of tokens currently belonging to the 23 | owner of 24 | * @return number of tokens currently belonging to the owner of given address 25 | */ 26 | function balanceOf (address _owner) constant returns (uint256 balance); 27 | 28 | /** 29 | * Transfer given number of tokens from message sender to given recipient. 30 | * 31 | * @param _to address to transfer tokens to the owner of 32 | * @param _value number of tokens to transfer to the owner of given address 33 | * @return true if tokens were transferred successfully, false otherwise 34 | */ 35 | function transfer (address _to, uint256 _value) returns (bool success); 36 | 37 | /** 38 | * Transfer given number of tokens from given owner to given recipient. 39 | * 40 | * @param _from address to transfer tokens from the owner of 41 | * @param _to address to transfer tokens to the owner of 42 | * @param _value number of tokens to transfer from given owner to given 43 | recipient 44 | * @return true if tokens were transferred successfully, false otherwise 45 | */ 46 | function transferFrom (address _from, address _to, uint256 _value) 47 | returns (bool success); 48 | 49 | /** 50 | * Allow given spender to transfer given number of tokens from message sender. 51 | * 52 | * @param _spender address to allow the owner of to transfer tokens from 53 | message sender 54 | * @param _value number of tokens to allow to transfer 55 | * @return true if token transfer was successfully approved, false otherwise 56 | */ 57 | function approve (address _spender, uint256 _value) returns (bool success); 58 | 59 | /** 60 | * Tell how many tokens given spender is currently allowed to transfer from 61 | * given owner. 62 | * 63 | * @param _owner address to get number of tokens allowed to be transferred 64 | * from the owner of 65 | * @param _spender address to get number of tokens allowed to be transferred 66 | * by the owner of 67 | * @return number of tokens given spender is currently allowed to transfer 68 | * from given owner 69 | */ 70 | function allowance (address _owner, address _spender) constant 71 | returns (uint256 remaining); 72 | 73 | /** 74 | * Logged when tokens were transferred from one owner to another. 75 | * 76 | * @param _from address of the owner, tokens were transferred from 77 | * @param _to address of the owner, tokens were transferred to 78 | * @param _value number of tokens transferred 79 | */ 80 | event Transfer (address indexed _from, address indexed _to, uint256 _value); 81 | 82 | /** 83 | * Logged when owner approved his tokens to be transferred by some spender. 84 | * 85 | * @param _owner owner who approved his tokens to be transferred 86 | * @param _spender spender who were allowed to transfer the tokens belonging 87 | * to the owner 88 | * @param _value number of tokens belonging to the owner, approved to be 89 | * transferred by the spender 90 | */ 91 | event Approval ( 92 | address indexed _owner, address indexed _spender, uint256 _value); 93 | } 94 | --------------------------------------------------------------------------------