├── .gitignore
├── LICENSE
├── README.md
├── _config.yml
├── contracts
├── TestERC20Token.sol
├── TokenSellerFactory.sol
└── TokenTraderFactory.sol
├── doc
└── images
│ ├── 1STWatchContract.png
│ ├── 1STWatchToken.png
│ ├── ARCWatchContract.png
│ ├── ARCWatchToken.png
│ ├── DAOWatchContract.png
│ ├── DAOWatchToken.png
│ ├── DGDWatchContract.png
│ ├── DGDWatchToken.png
│ ├── DGDbWatchContract.png
│ ├── DGDbWatchToken.png
│ ├── EDGWatchContract.png
│ ├── EDGWatchToken.png
│ ├── GNTCheckTokenBalance.png
│ ├── GNTCheckTokenBalanceEtherScanIo.png
│ ├── GNTCheckTokenBalanceEtherScanIoAddress.png
│ ├── GNTTokenTraderExecutedTradeReport.png
│ ├── GNTTokenTraderFactoryCreateTradeContract.png
│ ├── GNTTokenTraderFactoryWatchContract.png
│ ├── GNTTokenTraderFindContractCryptoDerivativesMarket.png
│ ├── GNTTokenTraderFindContractEthereumWallet.png
│ ├── GNTTokenTraderFindContractEtherscanIo1.png
│ ├── GNTTokenTraderFindContractEtherscanIo2.png
│ ├── GNTTokenTraderVerifyContractEthereumWallet.png
│ ├── GNTTokenTraderVerifyContractEtherscanIo1.png
│ ├── GNTTokenTraderVerifyContractEtherscanIo2.png
│ ├── GNTTokenTraderWatchContract.png
│ ├── GNTTokenTraderWatchContractScreen1.png
│ ├── GNTTokenTraderWatchContractScreen2.png
│ ├── GNTTokenTraderWatchContractScreenActivate.png
│ ├── GNTTokenTraderWatchContractScreenWithdraw.png
│ ├── GNTTokenTraderWatchContractScreenWithdrawAsset.png
│ ├── GNTTokenTraderWatchContractScreenWithdrawToken.png
│ ├── GNTTransferTokens.png
│ ├── GNTTransferTokensCheckGas.png
│ ├── GNTWWatchContract.png
│ ├── GNTWWatchToken.png
│ ├── GNTWatchContract.png
│ ├── GNTWatchToken.png
│ ├── HKGWatchContract.png
│ ├── HKGWatchToken.png
│ ├── ICNWatchContract.png
│ ├── ICNWatchToken.png
│ ├── JonnyLatteTokenTraderBugTx_20170205.png
│ ├── JonnyLatteTokenTraderBug_20170205.png
│ ├── MKRWatchContract.png
│ ├── MKRWatchToken.png
│ ├── MLNWatchContract.png
│ ├── MLNWatchToken.png
│ ├── OcytkoEmail_20170212.png
│ ├── PLUWatchContract.png
│ ├── PLUWatchToken.png
│ ├── RBXCheckTokenBalance.png
│ ├── RBXMoveToWaves.png
│ ├── RBXTransferTokens.png
│ ├── RBXWatchContract.png
│ ├── RBXWatchToken.png
│ ├── REPWatchContract.png
│ ├── REPWatchToken.png
│ ├── ROUNDWatchContract.png
│ ├── ROUNDWatchToken.png
│ ├── SNGLSWatchContract.png
│ ├── SNGLSWatchToken.png
│ ├── SWTWatchContract.png
│ ├── SWTWatchToken.png
│ ├── TIMEWatchContract.png
│ ├── TIMEWatchToken.png
│ ├── TokenSellerFactoryWatchContract.png
│ ├── TokenTraderActivate.png
│ ├── TokenTraderDepositEthers.png
│ ├── TokenTraderFactoryCheckInvalidGNT.png
│ ├── TokenTraderFactoryCreateTradeContract.png
│ ├── TokenTraderFactoryCreateTradeContractEtherScanContractSource.png
│ ├── TokenTraderFactoryCreateTradeContractEtherScanTransaction.png
│ ├── TokenTraderFactoryCreateTradeContractEtherScanTransactionInternal.png
│ ├── TokenTraderFactoryCreateTradeContractWatchContract.png
│ ├── TokenTraderFactoryWatchContract.png
│ ├── TokenTraderFactoryWatchContractFunctions.png
│ ├── TokenTraderREP395Contract.png
│ ├── TokenTraderREP395Rate.png
│ ├── TokenTraderSNGLS109872Contract.png
│ ├── TokenTraderSNGLS109872Rate.png
│ ├── TokenTraderTokenTransfer.png
│ ├── TokenTraderTransferAsset.png
│ ├── TokenTraderTransferEthers.png
│ ├── TokenTraderWithdrawAsset.png
│ ├── TokenTraderWithdrawEthers.png
│ ├── TokenTraderWithdrawOtherTokens.png
│ ├── VSLWatchContract.png
│ ├── VSLWatchToken.png
│ ├── WCTCheckTokenBalance.png
│ ├── WCTMoveToWaves.png
│ ├── WCTTransferTokens.png
│ ├── WCTWatchContract.png
│ └── WCTWatchToken.png
├── scripts
├── README.md
└── getGNTBalances
└── testing
├── test_20170115_1619
├── 00_runGeth.sh
├── 01_deployERC20Token.sh
├── 02_deployTokenTraderFactory.sh
├── 03_executeOrder.sh
├── 04_testOther.sh
├── 05_checkEvents.sh
├── GNTTokenTraderFactory.sol
├── README.md
├── TestERC20Token.sol
├── TokenSellerFactory.sol
├── TokenTraderFactory.sol
├── eventResults.txt
├── executionOutput.txt
├── executionResults.txt
├── factoryData.txt
├── factoryOutput.txt
├── factoryResults.txt
├── genesis.json
├── otherOutput.txt
├── otherResults.txt
├── settings.txt
├── stripCrLf
├── testchain
│ └── keystore
│ │ ├── UTC--2016-12-16T01-36-05.134620242Z--000d1009bd8f0b1301cc5edc28ed1222a3ce671e
│ │ ├── UTC--2016-12-16T01-36-45.681050789Z--0014060ff383c9b21c6840a3b14aab06741e5c49
│ │ ├── UTC--2016-12-16T01-37-12.717455318Z--0020017ba4c67f76c76b1af8c41821ee54f37171
│ │ └── UTC--2016-12-16T01-37-37.923741925Z--0036f6addb6d64684390f55a92f0f4988266901b
├── testpassword
├── tokenData.txt
├── tokenOutput.txt
└── tokenResults.txt
├── test_20170125_0829
├── 00_runGeth.sh
├── 01_deployERC20Token.sh
├── 02_deployTokenTraderFactory.sh
├── 03_executeOrder.sh
├── 04_testOther.sh
├── 05_checkEvents.sh
├── GNTTokenTraderFactory.sol
├── README.md
├── TestERC20Token.sol
├── TokenSellerFactory.sol
├── TokenTraderFactory.sol
├── eventResults.txt
├── executionOutput.txt
├── executionResults.txt
├── factoryData.txt
├── factoryOutput.txt
├── factoryResults.txt
├── genesis.json
├── otherOutput.txt
├── otherResults.txt
├── settings.txt
├── stripCrLf
├── testchain
│ └── keystore
│ │ ├── UTC--2016-12-16T01-36-05.134620242Z--000d1009bd8f0b1301cc5edc28ed1222a3ce671e
│ │ ├── UTC--2016-12-16T01-36-45.681050789Z--0014060ff383c9b21c6840a3b14aab06741e5c49
│ │ ├── UTC--2016-12-16T01-37-12.717455318Z--0020017ba4c67f76c76b1af8c41821ee54f37171
│ │ └── UTC--2016-12-16T01-37-37.923741925Z--0036f6addb6d64684390f55a92f0f4988266901b
├── testpassword
├── tokenData.txt
├── tokenOutput.txt
└── tokenResults.txt
└── test_20170205_1849
├── 00_runGeth.sh
├── 01_deployERC20Token.sh
├── 02_deployTokenTraderFactory.sh
├── 03_executeOrder.sh
├── 04_testOther.sh
├── 05_testBug.sh
├── 06_checkEvents.sh
├── GNTTokenTraderFactory.sol
├── README.md
├── TestERC20Token.sol
├── TokenSellerFactory.sol
├── TokenTraderFactory.sol
├── bugOutput.txt
├── bugResults.txt
├── eventResults.txt
├── executionOutput.txt
├── executionResults.txt
├── factoryData.txt
├── factoryOutput.txt
├── factoryResults.txt
├── genesis.json
├── otherOutput.txt
├── otherResults.txt
├── settings.txt
├── stripCrLf
├── testchain
└── keystore
│ ├── UTC--2016-12-16T01-36-05.134620242Z--000d1009bd8f0b1301cc5edc28ed1222a3ce671e
│ ├── UTC--2016-12-16T01-36-45.681050789Z--0014060ff383c9b21c6840a3b14aab06741e5c49
│ ├── UTC--2016-12-16T01-37-12.717455318Z--0020017ba4c67f76c76b1af8c41821ee54f37171
│ └── UTC--2016-12-16T01-37-37.923741925Z--0036f6addb6d64684390f55a92f0f4988266901b
├── testpassword
├── tokenData.txt
├── tokenOutput.txt
└── tokenResults.txt
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | .project
3 | private
4 | private/*
5 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2016 JonnyLatte, Cintix & BokkyPooBah
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 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # TokenTrader
2 | Decentralised trustless ether/ERC20-compliant token exchange contract on the Ethereum blockchain.
3 |
4 | TokenTrader, TokenTraderFactory, TokenSeller, TokenSellerFactory, GNTTokenTrader, GNTTokenTraderFactory - See the [wiki](https://github.com/bokkypoobah/TokenTrader/wiki) for the latest information.
5 |
6 |
7 |
8 | ---
9 |
10 | Enjoy. (c) JonnyLatte, Cintix & BokkyPooBah 2016. The MIT licence.
11 |
--------------------------------------------------------------------------------
/_config.yml:
--------------------------------------------------------------------------------
1 | theme: jekyll-theme-architect
--------------------------------------------------------------------------------
/contracts/TestERC20Token.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.4.2;
2 |
3 | // ----------------------------------------------------------------------------------------------
4 | // Basic ERC20 Token Contract For **TESTING ONLY** on Testnet or Dev blockchain.
5 | //
6 | // Enjoy. (c) Bok Consulting Pty Ltd 2016. The MIT Licence.
7 | // ----------------------------------------------------------------------------------------------
8 |
9 | // ERC Token Standard #20 Interface
10 | // https://github.com/ethereum/EIPs/issues/20
11 | contract ERC20Interface {
12 |
13 | // Get the total token supply
14 | function totalSupply() constant returns (uint256 totalSupply);
15 |
16 | // Get the account balance of another account with address _owner
17 | function balanceOf(address _owner) constant returns (uint256 balance);
18 |
19 | // Send _value amount of tokens to address _to
20 | function transfer(address _to, uint256 _value) returns (bool success);
21 |
22 | // Send _value amount of tokens from address _from to address _to
23 | // The transferFrom method is used for a withdraw workflow, allowing contracts to send
24 | // tokens on your behalf, for example to "deposit" to a contract address and/or to charge
25 | // fees in sub-currencies; the command should fail unless the _from account has
26 | // deliberately authorized the sender of the message via some mechanism; we propose
27 | // these standardized APIs for approval:
28 | function transferFrom(address _from, address _to, uint256 _value) returns (bool success);
29 |
30 | // Allow _spender to withdraw from your account, multiple times, up to the _value amount.
31 | // If this function is called again it overwrites the current allowance with _value.
32 | function approve(address _spender, uint256 _value) returns (bool success);
33 |
34 | // Returns the amount which _spender is still allowed to withdraw from _owner
35 | function allowance(address _owner, address _spender) constant returns (uint256 remaining);
36 |
37 | // Triggered when tokens are transferred.
38 | event Transfer(address indexed _from, address indexed _to, uint256 _value);
39 |
40 | // Triggered whenever approve(address _spender, uint256 _value) is called.
41 | event Approval(address indexed _owner, address indexed _spender, uint256 _value);
42 | }
43 |
44 | contract TestERC20Token is ERC20Interface {
45 |
46 | string public name;
47 | string public symbol;
48 | uint8 public decimals;
49 |
50 | // Owner of this contract
51 | address public owner;
52 |
53 | // Balances for each account
54 | mapping(address => uint256) balances;
55 |
56 | // Owner of account approves the transfer of an amount to another account
57 | mapping(address => mapping (address => uint256)) allowed;
58 |
59 | // Total supply
60 | uint256 _totalSupply;
61 |
62 | // Functions with this modifier can only be executed by the owner
63 | modifier onlyOwner() {
64 | if (msg.sender != owner) {
65 | throw;
66 | }
67 | _;
68 | }
69 |
70 | // Constructor
71 | function TestERC20Token(string _name, string _symbol, uint8 _decimals) {
72 | name = _name;
73 | symbol = _symbol;
74 | decimals = _decimals;
75 | owner = msg.sender;
76 | }
77 |
78 | function totalSupply() constant returns (uint256 totalSupply) {
79 | totalSupply = _totalSupply;
80 | }
81 |
82 | // What is the balance of a particular account?
83 | function balanceOf(address _owner) constant returns (uint256 balance) {
84 | return balances[_owner];
85 | }
86 |
87 | // Send _value amount of tokens to address _to
88 | function transfer(address _to, uint256 _amount) returns (bool success) {
89 | if (balances[msg.sender] >= _amount
90 | && _amount > 0
91 | && balances[_to] + _amount > balances[_to]) {
92 | balances[msg.sender] -= _amount;
93 | balances[_to] += _amount;
94 | Transfer(msg.sender, _to, _amount);
95 | return true;
96 | } else {
97 | return false;
98 | }
99 | }
100 |
101 | // Allow _spender to withdraw from your account, multiple times, up to the
102 | // _value amount. If this function is called again it overwrites the
103 | // current allowance with _value.
104 | function approve(
105 | address _spender,
106 | uint256 _amount
107 | ) returns (bool success) {
108 | allowed[msg.sender][_spender] = _amount;
109 | Approval(msg.sender, _spender, _amount);
110 | return true;
111 | }
112 |
113 | // Spender of tokens transfer an amount of tokens from the token owner's
114 | // balance to the spender's account. The owner of the tokens must already
115 | // have approve(...)-d this transfer
116 | function transferFrom(
117 | address _from,
118 | address _to,
119 | uint256 _amount
120 | ) returns (bool success) {
121 | if (balances[_from] >= _amount
122 | && allowed[_from][msg.sender] >= _amount
123 | && _amount > 0
124 | && balances[_to] + _amount > balances[_to]) {
125 | balances[_from] -= _amount;
126 | allowed[_from][msg.sender] -= _amount;
127 | balances[_to] += _amount;
128 | Transfer(_from, _to, _amount);
129 | return true;
130 | } else {
131 | return false;
132 | }
133 | }
134 |
135 | function allowance(address _owner, address _spender) constant returns (uint256 remaining) {
136 | return allowed[_owner][_spender];
137 | }
138 |
139 | function () payable {
140 | if (msg.value > 0) {
141 | _totalSupply += msg.value;
142 | balances[msg.sender] += msg.value;
143 | }
144 | }
145 |
146 | function withdrawEthers(uint256 ethers) onlyOwner returns (bool ok) {
147 | if (this.balance >= ethers) {
148 | return owner.send(ethers);
149 | }
150 | }
151 |
152 | // Triggered when fiat currency is converted to tokens
153 | event TokensCreated(address indexed _owner, uint256 _amount);
154 | }
155 |
--------------------------------------------------------------------------------
/doc/images/1STWatchContract.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/1STWatchContract.png
--------------------------------------------------------------------------------
/doc/images/1STWatchToken.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/1STWatchToken.png
--------------------------------------------------------------------------------
/doc/images/ARCWatchContract.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/ARCWatchContract.png
--------------------------------------------------------------------------------
/doc/images/ARCWatchToken.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/ARCWatchToken.png
--------------------------------------------------------------------------------
/doc/images/DAOWatchContract.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/DAOWatchContract.png
--------------------------------------------------------------------------------
/doc/images/DAOWatchToken.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/DAOWatchToken.png
--------------------------------------------------------------------------------
/doc/images/DGDWatchContract.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/DGDWatchContract.png
--------------------------------------------------------------------------------
/doc/images/DGDWatchToken.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/DGDWatchToken.png
--------------------------------------------------------------------------------
/doc/images/DGDbWatchContract.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/DGDbWatchContract.png
--------------------------------------------------------------------------------
/doc/images/DGDbWatchToken.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/DGDbWatchToken.png
--------------------------------------------------------------------------------
/doc/images/EDGWatchContract.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/EDGWatchContract.png
--------------------------------------------------------------------------------
/doc/images/EDGWatchToken.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/EDGWatchToken.png
--------------------------------------------------------------------------------
/doc/images/GNTCheckTokenBalance.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/GNTCheckTokenBalance.png
--------------------------------------------------------------------------------
/doc/images/GNTCheckTokenBalanceEtherScanIo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/GNTCheckTokenBalanceEtherScanIo.png
--------------------------------------------------------------------------------
/doc/images/GNTCheckTokenBalanceEtherScanIoAddress.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/GNTCheckTokenBalanceEtherScanIoAddress.png
--------------------------------------------------------------------------------
/doc/images/GNTTokenTraderExecutedTradeReport.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/GNTTokenTraderExecutedTradeReport.png
--------------------------------------------------------------------------------
/doc/images/GNTTokenTraderFactoryCreateTradeContract.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/GNTTokenTraderFactoryCreateTradeContract.png
--------------------------------------------------------------------------------
/doc/images/GNTTokenTraderFactoryWatchContract.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/GNTTokenTraderFactoryWatchContract.png
--------------------------------------------------------------------------------
/doc/images/GNTTokenTraderFindContractCryptoDerivativesMarket.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/GNTTokenTraderFindContractCryptoDerivativesMarket.png
--------------------------------------------------------------------------------
/doc/images/GNTTokenTraderFindContractEthereumWallet.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/GNTTokenTraderFindContractEthereumWallet.png
--------------------------------------------------------------------------------
/doc/images/GNTTokenTraderFindContractEtherscanIo1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/GNTTokenTraderFindContractEtherscanIo1.png
--------------------------------------------------------------------------------
/doc/images/GNTTokenTraderFindContractEtherscanIo2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/GNTTokenTraderFindContractEtherscanIo2.png
--------------------------------------------------------------------------------
/doc/images/GNTTokenTraderVerifyContractEthereumWallet.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/GNTTokenTraderVerifyContractEthereumWallet.png
--------------------------------------------------------------------------------
/doc/images/GNTTokenTraderVerifyContractEtherscanIo1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/GNTTokenTraderVerifyContractEtherscanIo1.png
--------------------------------------------------------------------------------
/doc/images/GNTTokenTraderVerifyContractEtherscanIo2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/GNTTokenTraderVerifyContractEtherscanIo2.png
--------------------------------------------------------------------------------
/doc/images/GNTTokenTraderWatchContract.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/GNTTokenTraderWatchContract.png
--------------------------------------------------------------------------------
/doc/images/GNTTokenTraderWatchContractScreen1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/GNTTokenTraderWatchContractScreen1.png
--------------------------------------------------------------------------------
/doc/images/GNTTokenTraderWatchContractScreen2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/GNTTokenTraderWatchContractScreen2.png
--------------------------------------------------------------------------------
/doc/images/GNTTokenTraderWatchContractScreenActivate.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/GNTTokenTraderWatchContractScreenActivate.png
--------------------------------------------------------------------------------
/doc/images/GNTTokenTraderWatchContractScreenWithdraw.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/GNTTokenTraderWatchContractScreenWithdraw.png
--------------------------------------------------------------------------------
/doc/images/GNTTokenTraderWatchContractScreenWithdrawAsset.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/GNTTokenTraderWatchContractScreenWithdrawAsset.png
--------------------------------------------------------------------------------
/doc/images/GNTTokenTraderWatchContractScreenWithdrawToken.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/GNTTokenTraderWatchContractScreenWithdrawToken.png
--------------------------------------------------------------------------------
/doc/images/GNTTransferTokens.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/GNTTransferTokens.png
--------------------------------------------------------------------------------
/doc/images/GNTTransferTokensCheckGas.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/GNTTransferTokensCheckGas.png
--------------------------------------------------------------------------------
/doc/images/GNTWWatchContract.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/GNTWWatchContract.png
--------------------------------------------------------------------------------
/doc/images/GNTWWatchToken.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/GNTWWatchToken.png
--------------------------------------------------------------------------------
/doc/images/GNTWatchContract.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/GNTWatchContract.png
--------------------------------------------------------------------------------
/doc/images/GNTWatchToken.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/GNTWatchToken.png
--------------------------------------------------------------------------------
/doc/images/HKGWatchContract.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/HKGWatchContract.png
--------------------------------------------------------------------------------
/doc/images/HKGWatchToken.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/HKGWatchToken.png
--------------------------------------------------------------------------------
/doc/images/ICNWatchContract.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/ICNWatchContract.png
--------------------------------------------------------------------------------
/doc/images/ICNWatchToken.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/ICNWatchToken.png
--------------------------------------------------------------------------------
/doc/images/JonnyLatteTokenTraderBugTx_20170205.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/JonnyLatteTokenTraderBugTx_20170205.png
--------------------------------------------------------------------------------
/doc/images/JonnyLatteTokenTraderBug_20170205.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/JonnyLatteTokenTraderBug_20170205.png
--------------------------------------------------------------------------------
/doc/images/MKRWatchContract.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/MKRWatchContract.png
--------------------------------------------------------------------------------
/doc/images/MKRWatchToken.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/MKRWatchToken.png
--------------------------------------------------------------------------------
/doc/images/MLNWatchContract.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/MLNWatchContract.png
--------------------------------------------------------------------------------
/doc/images/MLNWatchToken.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/MLNWatchToken.png
--------------------------------------------------------------------------------
/doc/images/OcytkoEmail_20170212.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/OcytkoEmail_20170212.png
--------------------------------------------------------------------------------
/doc/images/PLUWatchContract.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/PLUWatchContract.png
--------------------------------------------------------------------------------
/doc/images/PLUWatchToken.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/PLUWatchToken.png
--------------------------------------------------------------------------------
/doc/images/RBXCheckTokenBalance.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/RBXCheckTokenBalance.png
--------------------------------------------------------------------------------
/doc/images/RBXMoveToWaves.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/RBXMoveToWaves.png
--------------------------------------------------------------------------------
/doc/images/RBXTransferTokens.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/RBXTransferTokens.png
--------------------------------------------------------------------------------
/doc/images/RBXWatchContract.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/RBXWatchContract.png
--------------------------------------------------------------------------------
/doc/images/RBXWatchToken.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/RBXWatchToken.png
--------------------------------------------------------------------------------
/doc/images/REPWatchContract.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/REPWatchContract.png
--------------------------------------------------------------------------------
/doc/images/REPWatchToken.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/REPWatchToken.png
--------------------------------------------------------------------------------
/doc/images/ROUNDWatchContract.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/ROUNDWatchContract.png
--------------------------------------------------------------------------------
/doc/images/ROUNDWatchToken.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/ROUNDWatchToken.png
--------------------------------------------------------------------------------
/doc/images/SNGLSWatchContract.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/SNGLSWatchContract.png
--------------------------------------------------------------------------------
/doc/images/SNGLSWatchToken.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/SNGLSWatchToken.png
--------------------------------------------------------------------------------
/doc/images/SWTWatchContract.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/SWTWatchContract.png
--------------------------------------------------------------------------------
/doc/images/SWTWatchToken.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/SWTWatchToken.png
--------------------------------------------------------------------------------
/doc/images/TIMEWatchContract.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/TIMEWatchContract.png
--------------------------------------------------------------------------------
/doc/images/TIMEWatchToken.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/TIMEWatchToken.png
--------------------------------------------------------------------------------
/doc/images/TokenSellerFactoryWatchContract.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/TokenSellerFactoryWatchContract.png
--------------------------------------------------------------------------------
/doc/images/TokenTraderActivate.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/TokenTraderActivate.png
--------------------------------------------------------------------------------
/doc/images/TokenTraderDepositEthers.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/TokenTraderDepositEthers.png
--------------------------------------------------------------------------------
/doc/images/TokenTraderFactoryCheckInvalidGNT.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/TokenTraderFactoryCheckInvalidGNT.png
--------------------------------------------------------------------------------
/doc/images/TokenTraderFactoryCreateTradeContract.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/TokenTraderFactoryCreateTradeContract.png
--------------------------------------------------------------------------------
/doc/images/TokenTraderFactoryCreateTradeContractEtherScanContractSource.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/TokenTraderFactoryCreateTradeContractEtherScanContractSource.png
--------------------------------------------------------------------------------
/doc/images/TokenTraderFactoryCreateTradeContractEtherScanTransaction.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/TokenTraderFactoryCreateTradeContractEtherScanTransaction.png
--------------------------------------------------------------------------------
/doc/images/TokenTraderFactoryCreateTradeContractEtherScanTransactionInternal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/TokenTraderFactoryCreateTradeContractEtherScanTransactionInternal.png
--------------------------------------------------------------------------------
/doc/images/TokenTraderFactoryCreateTradeContractWatchContract.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/TokenTraderFactoryCreateTradeContractWatchContract.png
--------------------------------------------------------------------------------
/doc/images/TokenTraderFactoryWatchContract.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/TokenTraderFactoryWatchContract.png
--------------------------------------------------------------------------------
/doc/images/TokenTraderFactoryWatchContractFunctions.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/TokenTraderFactoryWatchContractFunctions.png
--------------------------------------------------------------------------------
/doc/images/TokenTraderREP395Contract.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/TokenTraderREP395Contract.png
--------------------------------------------------------------------------------
/doc/images/TokenTraderREP395Rate.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/TokenTraderREP395Rate.png
--------------------------------------------------------------------------------
/doc/images/TokenTraderSNGLS109872Contract.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/TokenTraderSNGLS109872Contract.png
--------------------------------------------------------------------------------
/doc/images/TokenTraderSNGLS109872Rate.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/TokenTraderSNGLS109872Rate.png
--------------------------------------------------------------------------------
/doc/images/TokenTraderTokenTransfer.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/TokenTraderTokenTransfer.png
--------------------------------------------------------------------------------
/doc/images/TokenTraderTransferAsset.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/TokenTraderTransferAsset.png
--------------------------------------------------------------------------------
/doc/images/TokenTraderTransferEthers.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/TokenTraderTransferEthers.png
--------------------------------------------------------------------------------
/doc/images/TokenTraderWithdrawAsset.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/TokenTraderWithdrawAsset.png
--------------------------------------------------------------------------------
/doc/images/TokenTraderWithdrawEthers.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/TokenTraderWithdrawEthers.png
--------------------------------------------------------------------------------
/doc/images/TokenTraderWithdrawOtherTokens.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/TokenTraderWithdrawOtherTokens.png
--------------------------------------------------------------------------------
/doc/images/VSLWatchContract.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/VSLWatchContract.png
--------------------------------------------------------------------------------
/doc/images/VSLWatchToken.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/VSLWatchToken.png
--------------------------------------------------------------------------------
/doc/images/WCTCheckTokenBalance.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/WCTCheckTokenBalance.png
--------------------------------------------------------------------------------
/doc/images/WCTMoveToWaves.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/WCTMoveToWaves.png
--------------------------------------------------------------------------------
/doc/images/WCTTransferTokens.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/WCTTransferTokens.png
--------------------------------------------------------------------------------
/doc/images/WCTWatchContract.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/WCTWatchContract.png
--------------------------------------------------------------------------------
/doc/images/WCTWatchToken.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bokkypoobah/TokenTrader/0ac50b691ad72145a0879a9215cb8606a03c9106/doc/images/WCTWatchToken.png
--------------------------------------------------------------------------------
/scripts/README.md:
--------------------------------------------------------------------------------
1 | Download and run the [`getGNTBalances`](https://github.com/bokkypoobah/TokenTrader/blob/master/scripts/getGNTBalances) script above to produce the following type of output:
2 |
3 | # Account GNT ETH
4 | ------- ------------------------------------------ ---------------------------- --------------------------
5 | 0 0x4319c142f7b6cd722fc3a49289b8a22a7a51ca1e 180000000.000000000000000000 0.000000000000000000
6 | 1 0x168ae36b4386cea14475faa41498a0ea63c67dd7 100000999.999999991611392000 11717.218877544008288507
7 | 2 0xd39379d7887c6a9ebd01007e2b96efc774652047 57459993.000000000000000000 106160.984854218882216845
8 | ------- ------------------------------------------ ---------------------------- --------------------------
9 | 3 Total 337460992.999999991611392000 117878.203731762890505352
10 |
11 | Further instructions are at the top of the `getGNTBalances` file.
12 |
--------------------------------------------------------------------------------
/scripts/getGNTBalances:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | # ------------------------------------------------------------------------------
4 | # Find Golem Network Token (GNT) Balances
5 | #
6 | # Works on Linux and OS/X. May work on Windows with Cygwin.
7 | #
8 | # Cut and paste the JavaScript between the two EOF lines to run directly in
9 | # `geth` console.
10 | #
11 | # Usage:
12 | # 1. Download this script to getGNTBalances
13 | # 2. `chmod 700 getGNTBalances`
14 | # 3. Run `geth console` in a window.
15 | # 4. Then run this script `./getGNTBalances` in a separate window.
16 | #
17 | # History:
18 | # * Jan 30 2016 - Version 1.0
19 | #
20 | # Enjoy. (c) BokkyPooBah 2016. The MIT licence.
21 | # ------------------------------------------------------------------------------
22 |
23 | # Don't define PARAM to use the standard IPC comms
24 | # Use below to connect to RPC port
25 | # PARAM="rpc:http://192.168.1.123:8545"
26 |
27 | geth attach $PARAM << EOF | grep "Data:" | sed "s/Data: //"
28 |
29 | function padTokens(s, n, m) {
30 | var o = s.toFixed(n);
31 | while (o.length < m) {
32 | o = " " + o;
33 | }
34 | return o;
35 | }
36 |
37 | function padEthers(s, n) {
38 | var o = s.toFixed(18);
39 | while (o.length < 27) {
40 | o = " " + o;
41 | }
42 | return o;
43 | }
44 |
45 | function checkAllBalances() {
46 | var erc20ABI = [{"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":"totalSupply","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":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"},{"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"}];
47 | var golemAddress = "0xa74476443119a942de498590fe1f2454d7d4ac0d";
48 | var golemContract = eth.contract(erc20ABI).at(golemAddress);
49 | var golemTotal = new BigNumber(0);
50 | var ethersTotal = new BigNumber(0);
51 |
52 | console.log("Data: # Account GNT ETH");
53 | console.log("Data: ------- ------------------------------------------ ---------------------------- --------------------------");
54 | var i =0;
55 | // Standard accounts
56 | var accounts = eth.accounts;
57 | // Add additional accounts
58 | accounts.push("0x4319c142f7b6cd722fc3a49289b8a22a7a51ca1e");
59 | accounts.push("0x168ae36b4386cea14475faa41498a0ea63c67dd7");
60 | accounts.push("0xd39379d7887c6a9ebd01007e2b96efc774652047");
61 | accounts.forEach( function(e){
62 | var golemTokens = golemContract.balanceOf(e).div(1e18);
63 | golemTotal = golemTotal.add(golemTokens);
64 | var ethers = web3.fromWei(eth.getBalance(e), "ether");
65 | ethersTotal = ethersTotal.add(ethers);
66 | console.log("Data: " + i + "\t" + e + " " + padTokens(golemTokens, 18, 28) + " " + padTokens(ethers, 18, 26));
67 | i++;
68 | })
69 | console.log("Data: ------- ------------------------------------------ ---------------------------- --------------------------");
70 | console.log("Data: " + i + " Total " + padTokens(golemTotal, 18, 28) + " " + padTokens(ethersTotal, 18, 26));
71 | };
72 |
73 | checkAllBalances()
74 |
75 | exit;
76 |
77 | EOF
78 |
79 |
--------------------------------------------------------------------------------
/testing/test_20170115_1619/00_runGeth.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | rm -f ./testchain/geth/chaindata/*
4 |
5 | geth --datadir ./testchain init genesis.json
6 |
7 | geth --datadir ./testchain --unlock 0 --password ./testpassword --rpc --rpccorsdomain '*' --rpcport 8646 --port 32323 --mine --minerthreads 1 --maxpeers 0 console
8 |
9 |
--------------------------------------------------------------------------------
/testing/test_20170115_1619/01_deployERC20Token.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | # --------------------------------------------------------------------
3 | # Testing Contracts At https://github.com/bokkypoobah/TokenTrader
4 | #
5 | # Deploy ERC20 Token
6 | #
7 | # (c) BokkyPooBah 2017. The MIT licence.
8 | # --------------------------------------------------------------------
9 |
10 | GETHATTACHPOINT=`grep IPCFILE settings.txt | sed "s/^.*=//"`
11 | PASSWORD=`grep PASSWORD settings.txt | sed "s/^.*=//"`
12 |
13 | TYPE=`grep TYPE settings.txt | sed "s/^.*=//"`
14 | INITIALETH=`grep INITIALETH settings.txt | sed "s/^.*=//"`
15 |
16 | TEMPINFILE=`grep TEMPINFILE settings.txt | sed "s/^.*=//"`
17 | TOKENOUTPUTFILE=`grep TOKENOUTPUTFILE settings.txt | sed "s/^.*=//"`
18 |
19 | TOKENSOL=`grep TOKENSOL settings.txt | sed "s/^.*=//"`
20 | FLATTENEDSOL=`./stripCrLf $TOKENSOL`
21 | printf "var tokenSource = \"$FLATTENEDSOL\"" > $TEMPINFILE
22 |
23 | TOKENDATAFILE=`grep TOKENDATA settings.txt | sed "s/^.*=//"`
24 | TOKENRESULTFILE=`grep TOKENRESULTFILE settings.txt | sed "s/^.*=//"`
25 |
26 | printf "geth endpoint '$GETHATTACHPOINT'\n" | tee $TOKENOUTPUTFILE
27 |
28 | geth --verbosity 3 attach $GETHATTACHPOINT << EOF | tee -a $TOKENOUTPUTFILE
29 |
30 | var ACCOUNTS = 3;
31 |
32 | function pad(s) {
33 | var o = s.toFixed(18);
34 | while (o.length < 27) {
35 | o = " " + o;
36 | }
37 | return o;
38 | }
39 |
40 | var accounts = [eth.accounts[0], eth.accounts[1], eth.accounts[2]];
41 | var accountName = {};
42 | accountName[eth.accounts[0]] = "Account #0";
43 | accountName[eth.accounts[1]] = "Account #1";
44 | accountName[eth.accounts[2]] = "Account #2";
45 |
46 | function printBalances(accounts) {
47 | var i = 0;
48 | console.log("RESULT: # Account EtherBalance TokenABalance TokenBBalance TokenCBalance Name");
49 | accounts.forEach(function(e) {
50 | i++;
51 | var etherBalance = web3.fromWei(eth.getBalance(e), "ether");
52 | var tokenABalance = web3.fromWei(tokenA.balanceOf(e), "ether");
53 | var tokenBBalance = web3.fromWei(tokenB.balanceOf(e), "ether");
54 | var tokenCBalance = web3.fromWei(tokenC.balanceOf(e), "ether");
55 | console.log("RESULT: " + i + " " + e + " " + pad(etherBalance) + " " + pad(tokenABalance) + " " + pad(tokenBBalance) + " " +
56 | pad(tokenCBalance) + " " + accountName[e]);
57 | });
58 | }
59 |
60 | function printTxData(name, txId) {
61 | var tx = eth.getTransaction(txId);
62 | var txReceipt = eth.getTransactionReceipt(txId);
63 | console.log("RESULT: " + name + " gas=" + tx.gas + " gasUsed=" + txReceipt.gasUsed + " cost=" + tx.gasPrice.mul(txReceipt.gasUsed).div(1e18) +
64 | " block=" + txReceipt.blockNumber + " txId=" + txId);
65 | }
66 |
67 | function assertEtherBalance(account, testBalance) {
68 | var etherBalance = web3.fromWei(eth.getBalance(account), "ether");
69 | if (etherBalance == testBalance) {
70 | console.log("RESULT: OK " + account + " has expected balance " + testBalance);
71 | } else {
72 | console.log("RESULT: FAILURE " + account + " has balance " + etherBalance + " <> expected " + testBalance);
73 | }
74 | }
75 |
76 | function assertTokenBalance(account, token, testBalance) {
77 | var tokenBalance = token.balanceOf(account).div(1e18);
78 | if (tokenBalance == testBalance) {
79 | console.log("RESULT: OK " + account + " has expected " + accountName[token.address] + " token balance " + testBalance);
80 | } else {
81 | console.log("RESULT: FAILURE " + account + " has " + accountName[token.address] + " token balance " + tokenBalance + " <> expected " + testBalance);
82 | }
83 | }
84 |
85 | console.log("RESULT: Creating ERC20 Token @ " + new Date());
86 |
87 | for (var i = 0; i < ACCOUNTS; i++) {
88 | personal.unlockAccount(eth.accounts[i], "$PASSWORD", 100000);
89 | }
90 |
91 | loadScript("$TEMPINFILE");
92 |
93 | var tokenCompiled = web3.eth.compile.solidity(tokenSource);
94 | console.log("DATA: tokenABI=" + JSON.stringify(tokenCompiled.TestERC20Token.info.abiDefinition));
95 | var tokenContract = web3.eth.contract(tokenCompiled.TestERC20Token.info.abiDefinition);
96 |
97 | // TokenA
98 | var tokenAddressA = null;
99 | var tokenTxA = null;
100 | var tokenA = tokenContract.new({from: eth.accounts[1], data: tokenCompiled.TestERC20Token.code, gas: 400000},
101 | function(e, contract) {
102 | if (!e) {
103 | if (!contract.address) {
104 | tokenTxA = contract.transactionHash;
105 | console.log("tokenTxA=" + tokenTxA);
106 | } else {
107 | tokenAddressA = contract.address;
108 | accountName[tokenAddressA] = "ERC20A";
109 | console.log("DATA: tokenAddressA=" + tokenAddressA);
110 | printTxData("tokenAddressA=" + tokenAddressA, tokenTxA);
111 | }
112 | }
113 | }
114 | );
115 | while (txpool.status.pending > 0) {
116 | }
117 |
118 | // TokenB
119 | var tokenAddressB = null;
120 | var tokenTxB = null;
121 | var tokenB = tokenContract.new({from: eth.accounts[1], data: tokenCompiled.TestERC20Token.code, gas: 400000},
122 | function(e, contract) {
123 | if (!e) {
124 | if (!contract.address) {
125 | tokenTxB = contract.transactionHash;
126 | console.log("tokenTxB=" + tokenTxB);
127 | } else {
128 | tokenAddressB = contract.address;
129 | accountName[tokenAddressB] = "ERC20B";
130 | console.log("DATA: tokenAddressB=" + tokenAddressB);
131 | printTxData("tokenAddressB=" + tokenAddressB, tokenTxB);
132 | }
133 | }
134 | }
135 | );
136 | while (txpool.status.pending > 0) {
137 | }
138 |
139 | // TokenC
140 | var tokenAddressC = null;
141 | var tokenTxC = null;
142 | var tokenC = tokenContract.new({from: eth.accounts[1], data: tokenCompiled.TestERC20Token.code, gas: 400000},
143 | function(e, contract) {
144 | if (!e) {
145 | if (!contract.address) {
146 | tokenTxC = contract.transactionHash;
147 | console.log("tokenTxC=" + tokenTxC);
148 | } else {
149 | tokenAddressC = contract.address;
150 | accountName[tokenAddressC] = "ERC20C";
151 | console.log("DATA: tokenAddressC=" + tokenAddressC);
152 | printTxData("tokenAddressC=" + tokenAddressC, tokenTxC);
153 | }
154 | }
155 | }
156 | );
157 | while (txpool.status.pending > 0) {
158 | }
159 |
160 | var txIdsA = [];
161 | for (var i = 0; i < ACCOUNTS; i++) {
162 | console.log("Sending $INITIALETH ETH from eth.accounts[" + i + "] to tokenA " + tokenAddressA);
163 | txIdsA[i] = eth.sendTransaction({from: eth.accounts[i], to: tokenAddressA, value: web3.toWei("$INITIALETH", "ether"), gas: 100000});
164 | console.log("txIdsA[" + i + "]=" + txIdsA[i]);
165 | }
166 |
167 | var txIdsB = [];
168 | for (var i = 0; i < ACCOUNTS; i++) {
169 | console.log("Sending $INITIALETH ETH from eth.accounts[" + i + "] to tokenB " + tokenAddressB);
170 | txIdsB[i] = eth.sendTransaction({from: eth.accounts[i], to: tokenAddressB, value: web3.toWei("$INITIALETH", "ether"), gas: 100000});
171 | console.log("txIdsB[" + i + "]=" + txIdsB[i]);
172 | }
173 |
174 | var txIdsC = [];
175 | for (var i = 0; i < ACCOUNTS; i++) {
176 | console.log("Sending $INITIALETH ETH from eth.accounts[" + i + "] to tokenC " + tokenAddressC);
177 | txIdsC[i] = eth.sendTransaction({from: eth.accounts[i], to: tokenAddressC, value: web3.toWei("$INITIALETH", "ether"), gas: 100000});
178 | console.log("txIdsC[" + i + "]=" + txIdsC[i]);
179 | }
180 | while (txpool.status.pending > 0) {
181 | }
182 |
183 | for (var i = 0; i < ACCOUNTS; i++) {
184 | printTxData("Sent $INITIALETH ETH from accounts[" + i + "] to tokenA " + tokenAddressA.substring(0, 10), txIdsA[i]);
185 | }
186 | for (var i = 0; i < ACCOUNTS; i++) {
187 | printTxData("Sent $INITIALETH ETH from accounts[" + i + "] to tokenB " + tokenAddressB.substring(0, 10), txIdsB[i]);
188 | }
189 | for (var i = 0; i < ACCOUNTS; i++) {
190 | printTxData("Sent $INITIALETH ETH from accounts[" + i + "] to tokenC " + tokenAddressC.substring(0, 10), txIdsC[i]);
191 | }
192 |
193 | printBalances([eth.accounts[0], eth.accounts[1], eth.accounts[2], tokenAddressA, tokenAddressB, tokenAddressC]);
194 |
195 | assertEtherBalance(tokenAddressA, 3000);
196 | assertEtherBalance(tokenAddressB, 3000);
197 | assertEtherBalance(tokenAddressC, 3000);
198 |
199 | assertTokenBalance(eth.accounts[0], tokenA, 1000);
200 | assertTokenBalance(eth.accounts[1], tokenA, 1000);
201 | assertTokenBalance(eth.accounts[2], tokenA, 1000);
202 |
203 | assertTokenBalance(eth.accounts[0], tokenB, 1000);
204 | assertTokenBalance(eth.accounts[1], tokenB, 1000);
205 | assertTokenBalance(eth.accounts[2], tokenB, 1000);
206 |
207 | assertTokenBalance(eth.accounts[0], tokenB, 1000);
208 | assertTokenBalance(eth.accounts[1], tokenB, 1000);
209 | assertTokenBalance(eth.accounts[2], tokenB, 1000);
210 |
211 | EOF
212 |
213 | grep "DATA: " $TOKENOUTPUTFILE | sed "s/DATA: //" > $TOKENDATAFILE
214 | grep "RESULT: " $TOKENOUTPUTFILE | sed "s/RESULT: //" > $TOKENRESULTFILE
215 | cat $TOKENRESULTFILE
216 |
--------------------------------------------------------------------------------
/testing/test_20170115_1619/05_checkEvents.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # --------------------------------------------------------------------
3 | # Testing Contracts At https://github.com/bokkypoobah/TokenTrader
4 | # for https://cryptoderivatives.market/
5 | #
6 | # Checking Generated Events
7 | #
8 | # (c) BokkyPooBah 2017. The MIT licence.
9 | # --------------------------------------------------------------------
10 |
11 | GETHATTACHPOINT=`grep IPCFILE settings.txt | sed "s/^.*=//"`
12 | PASSWORD=`grep PASSWORD settings.txt | sed "s/^.*=//"`
13 |
14 | TEMPOUTFILE=`grep TEMPOUTFILE settings.txt | sed "s/^.*=//"`
15 | EVENTRESULTFILE=`grep EVENTRESULTFILE settings.txt | sed "s/^.*=//"`
16 |
17 | TOKENDATAFILE=`grep TOKENDATA settings.txt | sed "s/^.*=//"`
18 | TOKENADDRESSA=`grep tokenAddressA $TOKENDATAFILE | tail -n 1 | sed "s/^.*=//"`
19 | TOKENADDRESSB=`grep tokenAddressB $TOKENDATAFILE | tail -n 1 | sed "s/^.*=//"`
20 | TOKENADDRESSC=`grep tokenAddressC $TOKENDATAFILE | tail -n 1 | sed "s/^.*=//"`
21 | TOKENABI=`grep tokenABI $TOKENDATAFILE | tail -n 1 | sed "s/^.*=//"`
22 |
23 | FACTORYDATAFILE=`grep FACTORYDATAFILE settings.txt | sed "s/^.*=//"`
24 | TOKENTRADERFACTORYADDRESS=`grep ^tokenTraderFactoryAddress $FACTORYDATAFILE | tail -n 1 | sed "s/^.*=//"`
25 | TOKENTRADERFACTORYABI=`grep ^tokenTraderFactoryABI $FACTORYDATAFILE | tail -n 1 | sed "s/^.*=//"`
26 | TOKENTRADERADDRESS=`grep ^tokenTraderAddress $FACTORYDATAFILE | tail -n 1 | sed "s/^.*=//"`
27 | TOKENTRADERABI=`grep ^tokenTraderABI $FACTORYDATAFILE | tail -n 1 | sed "s/^.*=//"`
28 | TOKENSELLERFACTORYADDRESS=`grep tokenSellerFactoryAddress $FACTORYDATAFILE | tail -n 1 | sed "s/^.*=//"`
29 | TOKENSELLERFACTORYABI=`grep tokenSellerFactoryABI $FACTORYDATAFILE | tail -n 1 | sed "s/^.*=//"`
30 | TOKENSELLERADDRESS=`grep tokenSellerAddress $FACTORYDATAFILE | tail -n 1 | sed "s/^.*=//"`
31 | TOKENSELLERABI=`grep tokenSellerABI $FACTORYDATAFILE | tail -n 1 | sed "s/^.*=//"`
32 | GNTTOKENTRADERFACTORYADDRESS=`grep gntTokenTraderFactoryAddress $FACTORYDATAFILE | tail -n 1 | sed "s/^.*=//"`
33 | GNTTOKENTRADERFACTORYABI=`grep gntTokenTraderFactoryABI $FACTORYDATAFILE | tail -n 1 | sed "s/^.*=//"`
34 | GNTTOKENTRADERADDRESS=`grep gntTokenTraderAddress $FACTORYDATAFILE | tail -n 1 | sed "s/^.*=//"`
35 | GNTTOKENTRADERABI=`grep gntTokenTraderABI $FACTORYDATAFILE | tail -n 1 | sed "s/^.*=//"`
36 |
37 | printf "Connecting to geth on endpoint '$GETHATTACHPOINT'\n" | tee $TEMPOUTFILE
38 | printf "TokenA address '$TOKENADDRESSA'\n" | tee -a $TEMPOUTFILE
39 | printf "TokenB address '$TOKENADDRESSB'\n" | tee -a $TEMPOUTFILE
40 | printf "TokenC address '$TOKENADDRESSC'\n" | tee -a $TEMPOUTFILE
41 | printf "Token ABI '$TOKENABI'\n" | tee -a $TEMPOUTFILE
42 | printf "TokenTraderFactory address '$TOKENTRADERFACTORYADDRESS'\n" | tee -a $TEMPOUTFILE
43 | printf "TokenTraderFactory ABI '$TOKENTRADERFACTORYABI'\n" | tee -a $TEMPOUTFILE
44 | printf "TokenTrader address '$TOKENTRADERADDRESS'\n" | tee -a $TEMPOUTFILE
45 | printf "TokenTrader ABI '$TOKENTRADERABI'\n" | tee -a $TEMPOUTFILE
46 | printf "TokenSellerFactory address '$TOKENSELLERFACTORYADDRESS'\n" | tee -a $TEMPOUTFILE
47 | printf "TokenSellerFactory ABI '$TOKENSELLERFACTORYABI'\n" | tee -a $TEMPOUTFILE
48 | printf "TokenSeller address '$TOKENSELLERADDRESS'\n" | tee -a $TEMPOUTFILE
49 | printf "TokenSeller ABI '$TOKENSELLERABI'\n" | tee -a $TEMPOUTFILE
50 | printf "GNTTokenTraderFactory address '$GNTTOKENTRADERFACTORYADDRESS'\n" | tee -a $TEMPOUTFILE
51 | printf "GNTTokenTraderFactory ABI '$GNTTOKENTRADERFACTORYABI'\n" | tee -a $TEMPOUTFILE
52 | printf "GNTTokenTrader address '$GNTTOKENTRADERADDRESS'\n" | tee -a $TEMPOUTFILE
53 | printf "GNTTokenTrader ABI '$GNTTOKENTRADERABI'\n" | tee -a $TEMPOUTFILE
54 | printf "EventResult '$EVENTRESULTFILE'\n" | tee -a $TEMPOUTFILE
55 |
56 | geth --verbosity 3 attach $GETHATTACHPOINT << EOF | tee -a $TEMPOUTFILE
57 |
58 | var token = web3.eth.contract($TOKENABI).at("$TOKENADDRESS");
59 | var tokenTraderFactory = web3.eth.contract($TOKENTRADERFACTORYABI).at("$TOKENTRADERFACTORYADDRESS");
60 | var tokenTrader = web3.eth.contract($TOKENTRADERABI).at("$TOKENTRADERADDRESS");
61 | var tokenSellerFactory = web3.eth.contract($TOKENSELLERFACTORYABI).at("$TOKENSELLERFACTORYADDRESS");
62 | var tokenSeller = web3.eth.contract($TOKENSELLERABI).at("$TOKENSELLERADDRESS");
63 | var gntTokenTraderFactory = web3.eth.contract($GNTTOKENTRADERFACTORYABI).at("$GNTTOKENTRADERFACTORYADDRESS");
64 | var gntTokenTrader = web3.eth.contract($GNTTOKENTRADERABI).at("$GNTTOKENTRADERADDRESS");
65 |
66 | function pad(s) {
67 | var o = s.toFixed(18);
68 | while (o.length < 27) {
69 | o = " " + o;
70 | }
71 | return o;
72 | }
73 |
74 | var accounts = [eth.accounts[0], eth.accounts[1], "$TOKENADDRESSA", "$TOKENADDRESSB", "$TOKENADDRESSC", "$TOKENTRADERADDRESS", "$TOKENSELLERADDRESS", "$GNTTOKENTRADERADDRESS"];
75 | var accountName = {};
76 | accountName[eth.accounts[0]] = "Account #0";
77 | accountName[eth.accounts[1]] = "Account #1";
78 | accountName["$TOKENADDRESSA"] = "ERC20A";
79 | accountName["$TOKENADDRESSB"] = "ERC20B";
80 | accountName["$TOKENADDRESSC"] = "ERC20C";
81 | accountName["$TOKENTRADERFACTORYADDRESS"] = "TokenTraderFactory";
82 | accountName["$TOKENTRADERADDRESS"] = "TokenTrader b1.1,s1.2";
83 | accountName["$TOKENSELLERFACTORYADDRESS"] = "TokenSellerFactory";
84 | accountName["$TOKENSELLERADDRESS"] = "TokenSeller s1.2";
85 | accountName["$GNTTOKENTRADERFACTORYADDRESS"] = "GNTTokenTraderFactory";
86 | accountName["$GNTTOKENTRADERADDRESS"] = "GNTTokenTrader s1.3";
87 |
88 | function printBalances(accounts) {
89 | var i = 0;
90 | console.log("RESULT: # Account EtherBalance TokenABalance TokenBBalance TokenCBalance Name");
91 | accounts.forEach(function(e) {
92 | var etherBalance = web3.fromWei(eth.getBalance(e), "ether");
93 | var tokenABalance = web3.fromWei(tokenA.balanceOf(e), "ether");
94 | var tokenBBalance = web3.fromWei(tokenB.balanceOf(e), "ether");
95 | var tokenCBalance = web3.fromWei(tokenC.balanceOf(e), "ether");
96 | console.log("RESULT: " + i + " " + e + " " + pad(etherBalance) + " " + pad(tokenABalance) + " " + pad(tokenBBalance) + " " + pad(tokenCBalance) + " " + accountName[e]);
97 | i++;
98 | });
99 | }
100 |
101 | function printTxData(name, txId) {
102 | var tx = eth.getTransaction(txId);
103 | var txReceipt = eth.getTransactionReceipt(txId);
104 | console.log("RESULT: " + name + " gas=" + tx.gas + " gasUsed=" + txReceipt.gasUsed + " cost=" + tx.gasPrice.mulß(txReceipt.gasUsed).div(1e18) +
105 | " block=" + txReceipt.blockNumber + " txId=" + txId);
106 | }
107 |
108 | printBalances(accounts);
109 |
110 | console.log("RESULT: Factory Events");
111 | var filter = web3.eth.filter({ address: ["$TOKENTRADERFACTORYADDRESS", "$TOKENSELLERFACTORYADDRESS", "$GNTTOKENTRADERFACTORYADDRESS", "$TOKENTRADERADDRESS", "$TOKENSELLERADDRESS", "$GNTTOKENTRADERADDRESS"], fromBlock: 0, toBlock: "latest" });
112 | var i = 0;
113 | filter.watch(function (error, result) {
114 | console.log("RESULT: Filter " + i++ + ": " + JSON.stringify(result));
115 | });
116 | filter.stopWatching();
117 |
118 | // Check TokenTrader Events
119 | console.log("RESULT: TokenTrader ActivatedEvent");
120 | var tokenTraderActivatedEvent = tokenTrader.ActivatedEvent({}, { fromBlock: 0, toBlock: "latest" });
121 | var i = 0;
122 | tokenTraderActivatedEvent.watch(function (error, result) {
123 | console.log("RESULT: tokenTraderActivatedEvent " + i++ + ": " + JSON.stringify(result));
124 | });
125 | tokenTraderActivatedEvent.stopWatching();
126 |
127 | console.log("RESULT: TokenTrader MakerDepositedEther");
128 | var tokenTraderMakerDepositedEther = tokenTrader.MakerDepositedEther({}, { fromBlock: 0, toBlock: "latest" });
129 | var i = 0;
130 | tokenTraderMakerDepositedEther.watch(function (error, result) {
131 | console.log("RESULT: tokenTraderMakerDepositedEther " + i++ + ": " + JSON.stringify(result));
132 | });
133 | tokenTraderMakerDepositedEther.stopWatching();
134 |
135 | console.log("RESULT: TokenTrader MakerWithdrewAsset");
136 | var tokenTraderMakerWithdrewAsset = tokenTrader.MakerWithdrewAsset({}, { fromBlock: 0, toBlock: "latest" });
137 | var i = 0;
138 | tokenTraderMakerWithdrewAsset.watch(function (error, result) {
139 | console.log("RESULT: tokenTraderMakerWithdrewAsset " + i++ + ": " + JSON.stringify(result));
140 | });
141 | tokenTraderMakerWithdrewAsset.stopWatching();
142 |
143 | console.log("RESULT: TokenTrader MakerWithdrewEther");
144 | var tokenTraderMakerWithdrewEther = tokenTrader.MakerWithdrewEther({}, { fromBlock: 0, toBlock: "latest" });
145 | var i = 0;
146 | tokenTraderMakerWithdrewEther.watch(function (error, result) {
147 | console.log("RESULT: tokenTraderMakerWithdrewEther " + i++ + ": " + JSON.stringify(result));
148 | });
149 | tokenTraderMakerWithdrewEther.stopWatching();
150 |
151 | console.log("RESULT: TokenTrader TakerBoughtAsset");
152 | var tokenTraderTakerBoughtAsset = tokenTrader.TakerBoughtAsset({}, { fromBlock: 0, toBlock: "latest" });
153 | var i = 0;
154 | tokenTraderTakerBoughtAsset.watch(function (error, result) {
155 | console.log("RESULT: tokenTraderTakerBoughtAsset " + i++ + ": " + JSON.stringify(result));
156 | });
157 | tokenTraderTakerBoughtAsset.stopWatching();
158 |
159 | console.log("RESULT: TokenTrader TakerSoldAsset");
160 | var tokenTraderTakerSoldAsset = tokenTrader.TakerSoldAsset({}, { fromBlock: 0, toBlock: "latest" });
161 | var i = 0;
162 | tokenTraderTakerSoldAsset.watch(function (error, result) {
163 | console.log("RESULT: tokenTraderTakerSoldAsset " + i++ + ": " + JSON.stringify(result));
164 | });
165 | tokenTraderTakerSoldAsset.stopWatching();
166 |
167 | // Check TokenSeller Events
168 | console.log("RESULT: TokenSeller ActivatedEvent");
169 | var tokenSellerActivatedEvent = tokenTrader.ActivatedEvent({}, { fromBlock: 0, toBlock: "latest" });
170 | var i = 0;
171 | tokenSellerActivatedEvent.watch(function (error, result) {
172 | console.log("RESULT: tokenSellerActivatedEvent " + i++ + ": " + JSON.stringify(result));
173 | });
174 | tokenSellerActivatedEvent.stopWatching();
175 |
176 | console.log("RESULT: TokenSeller MakerWithdrewAsset");
177 | var tokenSellerMakerWithdrewAsset = tokenTrader.MakerWithdrewAsset({}, { fromBlock: 0, toBlock: "latest" });
178 | var i = 0;
179 | tokenSellerMakerWithdrewAsset.watch(function (error, result) {
180 | console.log("RESULT: tokenSellerMakerWithdrewAsset " + i++ + ": " + JSON.stringify(result));
181 | });
182 | tokenSellerMakerWithdrewAsset.stopWatching();
183 |
184 | console.log("RESULT: TokenSeller MakerWithdrewEther");
185 | var tokenSellerMakerWithdrewEther = tokenTrader.MakerWithdrewEther({}, { fromBlock: 0, toBlock: "latest" });
186 | var i = 0;
187 | tokenSellerMakerWithdrewEther.watch(function (error, result) {
188 | console.log("RESULT: tokenSellerMakerWithdrewEther " + i++ + ": " + JSON.stringify(result));
189 | });
190 | tokenSellerMakerWithdrewEther.stopWatching();
191 |
192 | console.log("RESULT: TokenSeller TakerBoughtAsset");
193 | var tokenSellerTakerBoughtAsset = tokenTrader.TakerBoughtAsset({}, { fromBlock: 0, toBlock: "latest" });
194 | var i = 0;
195 | tokenSellerTakerBoughtAsset.watch(function (error, result) {
196 | console.log("RESULT: tokenSellerTakerBoughtAsset " + i++ + ": " + JSON.stringify(result));
197 | });
198 | tokenSellerMakerWithdrewEther.stopWatching();
199 |
200 | exit;
201 |
202 | EOF
203 |
204 | grep "RESULT: " $TEMPOUTFILE | sed "s/RESULT: //" > $EVENTRESULTFILE
205 | cat $EVENTRESULTFILE
206 |
--------------------------------------------------------------------------------
/testing/test_20170115_1619/GNTTokenTraderFactory.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.4.0;
2 |
3 | //https://github.com/nexusdev/erc20/blob/master/contracts/erc20.sol
4 |
5 | contract ERC20Constant {
6 | function balanceOf( address who ) constant returns (uint value);
7 | }
8 | contract ERC20Stateful {
9 | function transfer( address to, uint value) returns (bool ok);
10 | }
11 | contract ERC20Events {
12 | event Transfer(address indexed from, address indexed to, uint value);
13 | }
14 | contract ERC20 is ERC20Constant, ERC20Stateful, ERC20Events {}
15 |
16 | contract owned {
17 | address public owner;
18 |
19 | function owned() {
20 | owner = msg.sender;
21 | }
22 |
23 | modifier onlyOwner {
24 | if (msg.sender != owner) throw;
25 | _;
26 | }
27 |
28 | function transferOwnership(address newOwner) onlyOwner {
29 | owner = newOwner;
30 | }
31 | }
32 |
33 | // contract can sell tokens for ETH
34 | // prices are in amount of wei per batch of token units
35 |
36 | contract TokenTrader is owned {
37 |
38 | address public asset; // address of token
39 | uint256 public sellPrice; // contract sells lots of tokens at this price
40 | uint256 public units; // lot size (token-wei)
41 |
42 | bool public sellsTokens; // is contract selling
43 |
44 | event ActivatedEvent(bool sells);
45 | event UpdateEvent();
46 |
47 | function TokenTrader (
48 | address _asset,
49 | uint256 _sellPrice,
50 | uint256 _units,
51 | bool _sellsTokens
52 | )
53 | {
54 | asset = _asset;
55 | sellPrice = _sellPrice;
56 | units = _units;
57 | sellsTokens = _sellsTokens;
58 |
59 | ActivatedEvent(sellsTokens);
60 | }
61 |
62 | // modify trading behavior
63 | function activate (
64 | bool _sellsTokens
65 | ) onlyOwner
66 | {
67 | sellsTokens = _sellsTokens;
68 |
69 | ActivatedEvent(sellsTokens);
70 | }
71 |
72 | // allow owner to remove trade token
73 | function withdrawAsset(uint256 _value) onlyOwner returns (bool ok)
74 | {
75 | return ERC20(asset).transfer(owner,_value);
76 | UpdateEvent();
77 | }
78 |
79 | // allow owner to remove arbitrary tokens
80 | // included just in case contract receives wrong token
81 | function withdrawToken(address _token, uint256 _value) onlyOwner returns (bool ok)
82 | {
83 | return ERC20(_token).transfer(owner,_value);
84 | UpdateEvent();
85 | }
86 |
87 | // allow owner to remove ETH
88 | function withdraw(uint256 _value) onlyOwner returns (bool ok)
89 | {
90 | if(this.balance >= _value) {
91 | return owner.send(_value);
92 | }
93 | UpdateEvent();
94 | }
95 |
96 | //user buys token with ETH
97 | function buy() payable {
98 | if(sellsTokens || msg.sender == owner)
99 | {
100 | uint order = msg.value / sellPrice;
101 | uint can_sell = ERC20(asset).balanceOf(address(this)) / units;
102 |
103 | if(order > can_sell)
104 | {
105 | uint256 change = msg.value - (can_sell * sellPrice);
106 | order = can_sell;
107 | if(!msg.sender.send(change)) throw;
108 | }
109 |
110 | if(order > 0) {
111 | if(!ERC20(asset).transfer(msg.sender,order * units)) throw;
112 | }
113 | UpdateEvent();
114 | }
115 | else if(!msg.sender.send(msg.value)) throw; // return user funds if the contract is not selling
116 | }
117 |
118 | // sending ETH to contract sells GNT to user
119 | function () payable {
120 | buy();
121 | }
122 | }
123 |
124 | // This contract deploys TokenTrader contracts and logs the event
125 | // trade pairs are identified with sha3(asset,units)
126 |
127 | contract TokenTraderFactory {
128 |
129 | event TradeListing(bytes32 bookid, address owner, address addr);
130 | event NewBook(bytes32 bookid, address asset, uint256 units);
131 |
132 | mapping( address => bool ) _verify;
133 | mapping( bytes32 => bool ) pairExits;
134 |
135 | function verify(address tradeContract) constant returns (
136 | bool valid,
137 | address asset,
138 | uint256 sellPrice,
139 | uint256 units,
140 | bool sellsTokens
141 | ) {
142 |
143 | valid = _verify[tradeContract];
144 |
145 | if(valid) {
146 | TokenTrader t = TokenTrader(tradeContract);
147 |
148 | asset = t.asset();
149 | sellPrice = t.sellPrice();
150 | units = t.units();
151 | sellsTokens = t.sellsTokens();
152 | }
153 |
154 | }
155 |
156 | function createTradeContract(
157 | address _asset,
158 | uint256 _sellPrice,
159 | uint256 _units,
160 | bool _sellsTokens
161 | ) returns (address)
162 | {
163 | if(_units == 0) throw; // can't sell zero units
164 |
165 | address trader = new TokenTrader (
166 | _asset,
167 | _sellPrice,
168 | _units,
169 | _sellsTokens);
170 |
171 | var bookid = sha3(_asset,_units);
172 |
173 | _verify[trader] = true; // record that this factory created the trader
174 |
175 | TokenTrader(trader).transferOwnership(msg.sender); // set the owner to whoever called the function
176 |
177 | if(pairExits[bookid] == false) {
178 | pairExits[bookid] = true;
179 | NewBook(bookid, _asset, _units);
180 | }
181 |
182 | TradeListing(bookid,msg.sender,trader);
183 | }
184 |
185 | function () {
186 | throw; // Prevents accidental sending of ether to the factory
187 | }
188 | }
--------------------------------------------------------------------------------
/testing/test_20170115_1619/README.md:
--------------------------------------------------------------------------------
1 | The testing results are described in [Testing Results ‐ Jan 15 2017 16:19](https://github.com/bokkypoobah/TokenTrader/wiki/Testing-Results-%E2%80%90-Jan-15-2017-16:19).
2 |
--------------------------------------------------------------------------------
/testing/test_20170115_1619/TestERC20Token.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.4.2;
2 |
3 | // ----------------------------------------------------------------------------------------------
4 | // Basic ERC20 Token Contract For **TESTING ONLY** on Testnet or Dev blockchain.
5 | //
6 | // Enjoy. (c) Bok Consulting Pty Ltd 2016. The MIT Licence.
7 | // ----------------------------------------------------------------------------------------------
8 |
9 | // ERC Token Standard #20 Interface
10 | // https://github.com/ethereum/EIPs/issues/20
11 | contract ERC20Interface {
12 |
13 | // Get the total token supply
14 | function totalSupply() constant returns (uint256 totalSupply);
15 |
16 | // Get the account balance of another account with address _owner
17 | function balanceOf(address _owner) constant returns (uint256 balance);
18 |
19 | // Send _value amount of tokens to address _to
20 | function transfer(address _to, uint256 _value) returns (bool success);
21 |
22 | // Send _value amount of tokens from address _from to address _to
23 | // The transferFrom method is used for a withdraw workflow, allowing contracts to send
24 | // tokens on your behalf, for example to "deposit" to a contract address and/or to charge
25 | // fees in sub-currencies; the command should fail unless the _from account has
26 | // deliberately authorized the sender of the message via some mechanism; we propose
27 | // these standardized APIs for approval:
28 | function transferFrom(address _from, address _to, uint256 _value) returns (bool success);
29 |
30 | // Allow _spender to withdraw from your account, multiple times, up to the _value amount.
31 | // If this function is called again it overwrites the current allowance with _value.
32 | function approve(address _spender, uint256 _value) returns (bool success);
33 |
34 | // Returns the amount which _spender is still allowed to withdraw from _owner
35 | function allowance(address _owner, address _spender) constant returns (uint256 remaining);
36 |
37 | // Triggered when tokens are transferred.
38 | event Transfer(address indexed _from, address indexed _to, uint256 _value);
39 |
40 | // Triggered whenever approve(address _spender, uint256 _value) is called.
41 | event Approval(address indexed _owner, address indexed _spender, uint256 _value);
42 | }
43 |
44 | contract TestERC20Token is ERC20Interface {
45 |
46 | // Owner of this contract
47 | address public owner;
48 |
49 | // Balances for each account
50 | mapping(address => uint256) balances;
51 |
52 | // Owner of account approves the transfer of an amount to another account
53 | mapping(address => mapping (address => uint256)) allowed;
54 |
55 | // Total supply
56 | uint256 _totalSupply;
57 |
58 | // Functions with this modifier can only be executed by the bank
59 | modifier onlyOwner() {
60 | if (msg.sender != owner) {
61 | throw;
62 | }
63 | _;
64 | }
65 |
66 | // Constructor
67 | function TestERC20Token() {
68 | owner = msg.sender;
69 | }
70 |
71 | function totalSupply() constant returns (uint256 totalSupply) {
72 | totalSupply = _totalSupply;
73 | }
74 |
75 | // What is the balance of a particular account?
76 | function balanceOf(address _owner) constant returns (uint256 balance) {
77 | return balances[_owner];
78 | }
79 |
80 | // Transfer the balance from owner's account to another account
81 | function transfer(address _to, uint256 _amount) returns (bool success) {
82 | if (balances[msg.sender] >= _amount && _amount > 0) {
83 | balances[msg.sender] -= _amount;
84 | balances[_to] += _amount;
85 | Transfer(msg.sender, _to, _amount);
86 | return true;
87 | } else {
88 | return false;
89 | }
90 | }
91 |
92 | // Send _value amount of tokens from address _from to address _to
93 | // The transferFrom method is used for a withdraw workflow, allowing contracts to send
94 | // tokens on your behalf, for example to "deposit" to a contract address and/or to charge
95 | // fees in sub-currencies; the command should fail unless the _from account has
96 | // deliberately authorized the sender of the message via some mechanism; we propose
97 | // these standardized APIs for approval:
98 | function transferFrom(
99 | address _from,
100 | address _to,
101 | uint256 _amount
102 | ) returns (bool success) {
103 |
104 | if (balances[_from] >= _amount
105 | && allowed[_from][msg.sender] >= _amount
106 | && _amount > 0) {
107 |
108 | balances[_to] += _amount;
109 | balances[_from] -= _amount;
110 | allowed[_from][msg.sender] -= _amount;
111 | Transfer(_from, _to, _amount);
112 | return true;
113 | } else {
114 | return false;
115 | }
116 | }
117 |
118 | // Allow _spender to withdraw from your account, multiple times, up to the _value amount.
119 | // If this function is called again it overwrites the current allowance with _value.
120 | function approve(address _spender, uint256 _amount) returns (bool success) {
121 | allowed[msg.sender][_spender] = _amount;
122 | Approval(msg.sender, _spender, _amount);
123 | return true;
124 | }
125 |
126 | function allowance(address _owner, address _spender) constant returns (uint256 remaining) {
127 | return allowed[_owner][_spender];
128 | }
129 |
130 | function () payable {
131 | if (msg.value > 0) {
132 | _totalSupply += msg.value;
133 | balances[msg.sender] += msg.value;
134 | }
135 | }
136 |
137 | function withdrawEthers(uint256 ethers) onlyOwner returns (bool ok) {
138 | if (this.balance >= ethers) {
139 | return owner.send(ethers);
140 | }
141 | }
142 |
143 | // Triggered when fiat currency is converted to tokens
144 | event TokensCreated(address indexed _owner, uint256 _amount);
145 | }
146 |
--------------------------------------------------------------------------------
/testing/test_20170115_1619/TokenSellerFactory.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.4.4;
2 |
3 | // ------------------------------------------------------------------------
4 | // TokenSellerFactory
5 | //
6 | // Decentralised trustless ERC20-partially-compliant token to ETH exchange
7 | // contract on the Ethereum blockchain.
8 | //
9 | // This caters for the Golem Network Token which does not implement the
10 | // ERC20 transferFrom(...), approve(...) and allowance(...) methods
11 | //
12 | // Enjoy. (c) JonnyLatte, Cintix & BokkyPooBah 2016. The MIT licence.
13 | // ------------------------------------------------------------------------
14 |
15 | // https://github.com/ethereum/EIPs/issues/20
16 | contract ERC20Partial {
17 | function totalSupply() constant returns (uint totalSupply);
18 | function balanceOf(address _owner) constant returns (uint balance);
19 | function transfer(address _to, uint _value) returns (bool success);
20 | // function transferFrom(address _from, address _to, uint _value) returns (bool success);
21 | // function approve(address _spender, uint _value) returns (bool success);
22 | // function allowance(address _owner, address _spender) constant returns (uint remaining);
23 | event Transfer(address indexed _from, address indexed _to, uint _value);
24 | // event Approval(address indexed _owner, address indexed _spender, uint _value);
25 | }
26 |
27 | contract Owned {
28 | address public owner;
29 | event OwnershipTransferred(address indexed _from, address indexed _to);
30 |
31 | function Owned() {
32 | owner = msg.sender;
33 | }
34 |
35 | modifier onlyOwner {
36 | if (msg.sender != owner) throw;
37 | _;
38 | }
39 |
40 | function transferOwnership(address newOwner) onlyOwner {
41 | OwnershipTransferred(owner, newOwner);
42 | owner = newOwner;
43 | }
44 | }
45 |
46 | // contract can sell tokens for ETH
47 | // prices are in amount of wei per batch of token units
48 |
49 | contract TokenSeller is Owned {
50 |
51 | address public asset; // address of token
52 | uint256 public sellPrice; // contract sells lots of tokens at this price
53 | uint256 public units; // lot size (token-wei)
54 |
55 | bool public sellsTokens; // is contract selling
56 |
57 | event ActivatedEvent(bool sells);
58 | event MakerWithdrewAsset(uint256 tokens);
59 | event MakerWithdrewERC20Token(address tokenAddress, uint256 tokens);
60 | event MakerWithdrewEther(uint256 ethers);
61 | event TakerBoughtAsset(address indexed buyer, uint256 ethersSent,
62 | uint256 ethersReturned, uint256 tokensBought);
63 |
64 | // Constructor - only to be called by the TokenSellerFactory contract
65 | function TokenSeller (
66 | address _asset,
67 | uint256 _sellPrice,
68 | uint256 _units,
69 | bool _sellsTokens
70 | ) internal {
71 | asset = _asset;
72 | sellPrice = _sellPrice;
73 | units = _units;
74 | sellsTokens = _sellsTokens;
75 | ActivatedEvent(sellsTokens);
76 | }
77 |
78 | // Maker can activate or deactivate this contract's
79 | // selling status
80 | //
81 | // The ActivatedEvent() event is logged with the following
82 | // parameter:
83 | // sellsTokens this contract can sell asset tokens
84 | function activate (
85 | bool _sellsTokens
86 | ) onlyOwner {
87 | sellsTokens = _sellsTokens;
88 | ActivatedEvent(sellsTokens);
89 | }
90 |
91 | // Maker can withdraw asset tokens from this contract, with the
92 | // following parameter:
93 | // tokens is the number of asset tokens to be withdrawn
94 | //
95 | // The MakerWithdrewAsset() event is logged with the following
96 | // parameter:
97 | // tokens is the number of tokens withdrawn by the maker
98 | //
99 | // This method was called withdrawAsset() in the old version
100 | function makerWithdrawAsset(uint256 tokens) onlyOwner returns (bool ok) {
101 | MakerWithdrewAsset(tokens);
102 | return ERC20Partial(asset).transfer(owner, tokens);
103 | }
104 |
105 | // Maker can withdraw any ERC20 asset tokens from this contract
106 | //
107 | // This method is included in the case where this contract receives
108 | // the wrong tokens
109 | //
110 | // The MakerWithdrewERC20Token() event is logged with the following
111 | // parameter:
112 | // tokenAddress is the address of the tokens withdrawn by the maker
113 | // tokens is the number of tokens withdrawn by the maker
114 | //
115 | // This method was called withdrawToken() in the old version
116 | function makerWithdrawERC20Token(
117 | address tokenAddress,
118 | uint256 tokens
119 | ) onlyOwner returns (bool ok) {
120 | MakerWithdrewERC20Token(tokenAddress, tokens);
121 | return ERC20Partial(tokenAddress).transfer(owner, tokens);
122 | }
123 |
124 | // Maker withdraws ethers from this contract
125 | //
126 | // The MakerWithdrewEther() event is logged with the following parameter
127 | // ethers is the number of ethers withdrawn by the maker
128 | //
129 | // This method was called withdraw() in the old version
130 | function makerWithdrawEther(uint256 ethers) onlyOwner returns (bool ok) {
131 | if (this.balance >= ethers) {
132 | MakerWithdrewEther(ethers);
133 | return owner.send(ethers);
134 | }
135 | }
136 |
137 | // Taker buys asset tokens by sending ethers
138 | //
139 | // The TakerBoughtAsset() event is logged with the following parameters
140 | // buyer is the buyer's address
141 | // ethersSent is the number of ethers sent by the buyer
142 | // ethersReturned is the number of ethers sent back to the buyer as
143 | // change
144 | // tokensBought is the number of asset tokens sent to the buyer
145 | //
146 | // This method was called buy() in the old version
147 | function takerBuyAsset() payable {
148 | if (sellsTokens || msg.sender == owner) {
149 | // Note that sellPrice has already been validated as > 0
150 | uint order = msg.value / sellPrice;
151 | // Note that units has already been validated as > 0
152 | uint can_sell = ERC20Partial(asset).balanceOf(address(this)) / units;
153 | uint256 change = 0;
154 | if (order > can_sell) {
155 | change = msg.value - (can_sell * sellPrice);
156 | order = can_sell;
157 | if (!msg.sender.send(change)) throw;
158 | }
159 | if (order > 0) {
160 | if(!ERC20Partial(asset).transfer(msg.sender, order * units)) throw;
161 | }
162 | TakerBoughtAsset(msg.sender, msg.value, order * units, change);
163 | }
164 | // Return user funds if the contract is not selling
165 | else if (!msg.sender.send(msg.value)) throw;
166 | }
167 |
168 | // Taker buys tokens by sending ethers
169 | function () payable {
170 | takerBuyAsset();
171 | }
172 | }
173 |
174 | // This contract deploys TokenSeller contracts and logs the event
175 | contract TokenSellerFactory is Owned {
176 |
177 | event TradeListing(address indexed ownerAddress, address indexed tokenSellerAddress,
178 | address indexed asset, uint256 sellPrice, uint256 units, bool sellsTokens);
179 | event OwnerWithdrewERC20Token(address indexed tokenAddress, uint256 tokens);
180 |
181 | mapping(address => bool) _verify;
182 |
183 | // Anyone can call this method to verify the settings of a
184 | // TokenSeller contract. The parameters are:
185 | // tradeContract is the address of a TokenSeller contract
186 | //
187 | // Return values:
188 | // valid did this TokenTraderFactory create the TokenTrader contract?
189 | // owner is the owner of the TokenTrader contract
190 | // asset is the ERC20 asset address
191 | // sellPrice is the sell price in ethers per `units` of asset tokens
192 | // units is the number of units of asset tokens
193 | // sellsTokens is the TokenTrader contract selling tokens?
194 | //
195 | function verify(address tradeContract) constant returns (
196 | bool valid,
197 | address owner,
198 | address asset,
199 | uint256 sellPrice,
200 | uint256 units,
201 | bool sellsTokens
202 | ) {
203 | valid = _verify[tradeContract];
204 | if (valid) {
205 | TokenSeller t = TokenSeller(tradeContract);
206 | owner = t.owner();
207 | asset = t.asset();
208 | sellPrice = t.sellPrice();
209 | units = t.units();
210 | sellsTokens = t.sellsTokens();
211 | }
212 | }
213 |
214 | // Maker can call this method to create a new TokenSeller contract
215 | // with the maker being the owner of this new contract
216 | //
217 | // Parameters:
218 | // asset is the ERC20 asset address
219 | // sellPrice is the sell price in ethers per `units` of asset tokens
220 | // units is the number of units of asset tokens
221 | // sellsTokens is the TokenSeller contract selling tokens?
222 | //
223 | // For example, listing a TokenSeller contract on the GNT Golem Network Token
224 | // where the contract will sell GNT tokens at a rate of 170/100000 = 0.0017 ETH
225 | // per GNT token:
226 | // asset 0xa74476443119a942de498590fe1f2454d7d4ac0d
227 | // sellPrice 170
228 | // units 100000
229 | // sellsTokens true
230 | //
231 | // The TradeListing() event is logged with the following parameters
232 | // ownerAddress is the Maker's address
233 | // tokenSellerAddress is the address of the newly created TokenSeller contract
234 | // asset is the ERC20 asset address
235 | // sellPrice is the sell price in ethers per `units` of asset tokens
236 | // unit is the number of units of asset tokens
237 | // sellsTokens is the TokenSeller contract selling tokens?
238 | //
239 | // This method was called createTradeContract() in the old version
240 | //
241 | function createSaleContract(
242 | address asset,
243 | uint256 sellPrice,
244 | uint256 units,
245 | bool sellsTokens
246 | ) returns (address seller) {
247 | // Cannot have invalid asset
248 | if (asset == 0x0) throw;
249 | // Cannot set zero or negative price
250 | if (sellPrice <= 0) throw;
251 | // Cannot sell zero or negative units
252 | if (units <= 0) throw;
253 | seller = new TokenSeller(
254 | asset,
255 | sellPrice,
256 | units,
257 | sellsTokens);
258 | // Record that this factory created the trader
259 | _verify[seller] = true;
260 | // Set the owner to whoever called the function
261 | TokenSeller(seller).transferOwnership(msg.sender);
262 | TradeListing(msg.sender, seller, asset, sellPrice, units, sellsTokens);
263 | }
264 |
265 | // Factory owner can withdraw any ERC20 asset tokens from this contract
266 | //
267 | // This method is included in the case where this contract receives
268 | // the wrong tokens
269 | //
270 | // The OwnerWithdrewERC20Token() event is logged with the following
271 | // parameter:
272 | // tokenAddress is the address of the tokens withdrawn by the maker
273 | // tokens is the number of tokens withdrawn by the maker
274 | function ownerWithdrawERC20Token(address tokenAddress, uint256 tokens) onlyOwner returns (bool ok) {
275 | OwnerWithdrewERC20Token(tokenAddress, tokens);
276 | return ERC20Partial(tokenAddress).transfer(owner, tokens);
277 | }
278 |
279 | // Prevents accidental sending of ether to the factory
280 | function () {
281 | throw;
282 | }
283 | }
--------------------------------------------------------------------------------
/testing/test_20170115_1619/factoryResults.txt:
--------------------------------------------------------------------------------
1 | traderFactoryAddress=0x03d47b0d78f8dee3089037dffd5c9a1f7e7282af gas=3000000 gasUsed=1228433 cost=0.02456866 block=16 txId=0x18028944bf3154cb27027d9aa40d8bb7536bb267d5e10dbc31a61cc103ba04dc
2 | sellerFactoryAddress=0xcc643e6c5639d64ca3c0c484a6c0f23d11b87477 gas=3000000 gasUsed=977907 cost=0.01955814 block=17 txId=0xf3fda1737c89b3064412cd1d962cd4e1fd03f5d3eb0575b9a0474dabf5d9725a
3 | gntTraderFactoryAddress=0xbd7780c8773a6c99163ea9c1fa870450bc216aa6 gas=3000000 gasUsed=781907 cost=0.01563814 block=17 txId=0x14d5c771b48505f3619740a1d310104bd20974b2747c7c7d0c155ba19fb37fa2
4 | createTradeContractTxId gas=1000000 gasUsed=679023 cost=0.01358046 block=19 txId=0x43d62e293cb4bb0904a63c33026bc253cbbdf0ea90b27d768bc3bf393c600f6c
5 | createSaleContractTxId gas=1000000 gasUsed=528769 cost=0.01057538 block=19 txId=0x64703fa680227f8a029cd958e09e7e3e0244cb23c25503961b5737009d352d01
6 | createGNTTradeContractTxId gas=1000000 gasUsed=503624 cost=0.01007248 block=19 txId=0x53e287f5755cf7da4f2943439824b0b1cafb1a3bb858eeb2c9e355b98b5f6d57
7 | traderVerifyResults [true,"0x0014060ff383c9b21c6840a3b14aab06741e5c49","0xebb2634dd3194ba6d75eeb049cd0f73bf9801d95","110000","120000","100000",true,true]
8 | sellerVerifyResults [true,"0x0014060ff383c9b21c6840a3b14aab06741e5c49","0xebb2634dd3194ba6d75eeb049cd0f73bf9801d95","120000","100000",true]
9 | gntTraderVerifyResults [true,"0xebb2634dd3194ba6d75eeb049cd0f73bf9801d95","130000","100000",true]
10 | # Account EtherBalance TokenABalance TokenBBalance TokenCBalance Name
11 | 0 0x000d1009bd8f0b1301cc5edc28ed1222a3ce671e 97095.121316385207106619 1000.000000000000000000 1000.000000000000000000 1000.000000000000000000 Account #0
12 | 1 0x0014060ff383c9b21c6840a3b14aab06741e5c49 96999.881462694792893381 1000.000000000000000000 1000.000000000000000000 1000.000000000000000000 Account #1
13 | 2 0x0020017ba4c67f76c76b1af8c41821ee54f37171 96999.997220920000000000 1000.000000000000000000 1000.000000000000000000 1000.000000000000000000 Account #2
14 | 3 0xebb2634dd3194ba6d75eeb049cd0f73bf9801d95 3000.000000000000000000 0.000000000000000000 0.000000000000000000 0.000000000000000000 ERC20A
15 | 4 0xe9ba90b474ef72aa062d89a319c3e15b31e8fe65 3000.000000000000000000 0.000000000000000000 0.000000000000000000 0.000000000000000000 ERC20B
16 | 5 0x30da52ef30bdaec61b43317cc045e4f267eaf779 3000.000000000000000000 0.000000000000000000 0.000000000000000000 0.000000000000000000 ERC20C
17 | 6 0x03d47b0d78f8dee3089037dffd5c9a1f7e7282af 0.000000000000000000 0.000000000000000000 0.000000000000000000 0.000000000000000000 TokenTraderFactory
18 | 7 0xcc643e6c5639d64ca3c0c484a6c0f23d11b87477 0.000000000000000000 0.000000000000000000 0.000000000000000000 0.000000000000000000 TokenSellerFactory
19 | 8 0xbd7780c8773a6c99163ea9c1fa870450bc216aa6 0.000000000000000000 0.000000000000000000 0.000000000000000000 0.000000000000000000 GNTTokenTraderFactory
20 | 9 0xfb6ae08258f553335fd33b71081228e53794f8eb 0.000000000000000000 0.000000000000000000 0.000000000000000000 0.000000000000000000 TokenTrader
21 | 10 0x85e7378cb6a2ecbcaf5c178775764615f5046a9d 0.000000000000000000 0.000000000000000000 0.000000000000000000 0.000000000000000000 TokenSeller
22 | 11 0x7afc189b25beba65c5a2dec4804ea77b40f8c9a5 0.000000000000000000 0.000000000000000000 0.000000000000000000 0.000000000000000000 GNTTokenTrader
23 | Depositing 100 ETH to tokenTrader 0xfb6ae08258f553335fd33b71081228e53794f8eb
24 | Transferring 100 tokenAs to tokenTrader 0xfb6ae08258f553335fd33b71081228e53794f8eb
25 | Transferring 100 tokenAs to tokenSeller 0x85e7378cb6a2ecbcaf5c178775764615f5046a9d
26 | Transferring 100 tokenAs to gntTokenTrader 0x7afc189b25beba65c5a2dec4804ea77b40f8c9a5
27 | traderDepositEtherTxId gas=100000 gasUsed=22687 cost=0.00045374 block=22 txId=0xb33592561871f1b672e2fbac800093c33dd47471228f18111be90e122af5b108
28 | traderTransferTokenTxId gas=100000 gasUsed=50921 cost=0.00101842 block=22 txId=0x551b9295a3052f0ea7128d4220ae017b36bb6776113f1b57a00d39d5a9925709
29 | sellerTransferTokenTxId gas=100000 gasUsed=50921 cost=0.00101842 block=22 txId=0x3a4cc76a1370f7cf8bb575adc3918fa0c727b54b9518414b94798318cabd51cc
30 | gntTraderTransferTokenTxId gas=100000 gasUsed=50921 cost=0.00101842 block=22 txId=0xfc051c006f6778c7d525acc2aa2533db0ed388342904ce3f1e0ac6e2c7d5cecf
31 | OK 0xebb2634dd3194ba6d75eeb049cd0f73bf9801d95 has expected balance 3000
32 | Expecting 100 TokenABalance and 100 ETH in tokenTrader 0xfb6ae08258f553335fd33b71081228e53794f8eb
33 | Expecting 100 TokenABalance in tokenSeller 0x85e7378cb6a2ecbcaf5c178775764615f5046a9d
34 | Expecting 100 TokenABalance in gntTokenTrader 0x7afc189b25beba65c5a2dec4804ea77b40f8c9a5
35 | # Account EtherBalance TokenABalance TokenBBalance TokenCBalance Name
36 | 0 0x000d1009bd8f0b1301cc5edc28ed1222a3ce671e 97110.124825385207106619 1000.000000000000000000 1000.000000000000000000 1000.000000000000000000 Account #0
37 | 1 0x0014060ff383c9b21c6840a3b14aab06741e5c49 96899.877953694792893381 700.000000000000000000 1000.000000000000000000 1000.000000000000000000 Account #1
38 | 2 0x0020017ba4c67f76c76b1af8c41821ee54f37171 96999.997220920000000000 1000.000000000000000000 1000.000000000000000000 1000.000000000000000000 Account #2
39 | 3 0xebb2634dd3194ba6d75eeb049cd0f73bf9801d95 3000.000000000000000000 0.000000000000000000 0.000000000000000000 0.000000000000000000 ERC20A
40 | 4 0xe9ba90b474ef72aa062d89a319c3e15b31e8fe65 3000.000000000000000000 0.000000000000000000 0.000000000000000000 0.000000000000000000 ERC20B
41 | 5 0x30da52ef30bdaec61b43317cc045e4f267eaf779 3000.000000000000000000 0.000000000000000000 0.000000000000000000 0.000000000000000000 ERC20C
42 | 6 0x03d47b0d78f8dee3089037dffd5c9a1f7e7282af 0.000000000000000000 0.000000000000000000 0.000000000000000000 0.000000000000000000 TokenTraderFactory
43 | 7 0xcc643e6c5639d64ca3c0c484a6c0f23d11b87477 0.000000000000000000 0.000000000000000000 0.000000000000000000 0.000000000000000000 TokenSellerFactory
44 | 8 0xbd7780c8773a6c99163ea9c1fa870450bc216aa6 0.000000000000000000 0.000000000000000000 0.000000000000000000 0.000000000000000000 GNTTokenTraderFactory
45 | 9 0xfb6ae08258f553335fd33b71081228e53794f8eb 100.000000000000000000 100.000000000000000000 0.000000000000000000 0.000000000000000000 TokenTrader
46 | 10 0x85e7378cb6a2ecbcaf5c178775764615f5046a9d 0.000000000000000000 100.000000000000000000 0.000000000000000000 0.000000000000000000 TokenSeller
47 | 11 0x7afc189b25beba65c5a2dec4804ea77b40f8c9a5 0.000000000000000000 100.000000000000000000 0.000000000000000000 0.000000000000000000 GNTTokenTrader
48 | OK 0x03d47b0d78f8dee3089037dffd5c9a1f7e7282af has expected balance 0
49 | OK 0x03d47b0d78f8dee3089037dffd5c9a1f7e7282af has expected ERC20A token balance 0
50 | OK 0xcc643e6c5639d64ca3c0c484a6c0f23d11b87477 has expected balance 0
51 | OK 0xcc643e6c5639d64ca3c0c484a6c0f23d11b87477 has expected ERC20A token balance 0
52 | OK 0xbd7780c8773a6c99163ea9c1fa870450bc216aa6 has expected balance 0
53 | OK 0xbd7780c8773a6c99163ea9c1fa870450bc216aa6 has expected ERC20A token balance 0
54 | OK 0xfb6ae08258f553335fd33b71081228e53794f8eb has expected balance 100
55 | OK 0xfb6ae08258f553335fd33b71081228e53794f8eb has expected ERC20A token balance 100
56 | OK 0x85e7378cb6a2ecbcaf5c178775764615f5046a9d has expected balance 0
57 | OK 0x85e7378cb6a2ecbcaf5c178775764615f5046a9d has expected ERC20A token balance 100
58 | OK 0x7afc189b25beba65c5a2dec4804ea77b40f8c9a5 has expected balance 0
59 | OK 0x7afc189b25beba65c5a2dec4804ea77b40f8c9a5 has expected ERC20A token balance 100
60 |
--------------------------------------------------------------------------------
/testing/test_20170115_1619/genesis.json:
--------------------------------------------------------------------------------
1 | {
2 | "config": {
3 | "homesteadBlock": 1
4 | },
5 | "nonce": "0",
6 | "difficulty": "0x400",
7 | "mixhash": "0x00000000000000000000000000000000000000647572616c65787365646c6578",
8 | "coinbase": "0x0000000000000000000000000000000000000000",
9 | "timestamp": "0x00",
10 | "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
11 | "extraData": "0x",
12 | "gasLimit": "0x3B4A1B44",
13 | "alloc": {
14 | "0x000d1009bd8f0b1301cc5edc28ed1222a3ce671e": {
15 | "balance": "100000000000000000000000"
16 | },
17 | "0x0014060ff383c9b21c6840a3b14aab06741e5c49": {
18 | "balance": "100000000000000000000000"
19 | },
20 | "0x0020017ba4c67f76c76b1af8c41821ee54f37171": {
21 | "balance": "100000000000000000000000"
22 | },
23 | "0x0036f6addb6d64684390f55a92f0f4988266901b": {
24 | "balance": "100000000000000000000000"
25 | },
26 | "0x004e64833635cd1056b948b57286b7c91e62731c": {
27 | "balance": "100000000000000000000000"
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/testing/test_20170115_1619/settings.txt:
--------------------------------------------------------------------------------
1 | IxPCFILE=ipc://Users/bok/ESE/gethgenesis/geth.ipc
2 |
3 | IPCFILE=ipc:./testchain/geth.ipc
4 | PASSWORD=testtest
5 |
6 | TYPE=Trader
7 | INITIALETH=1000
8 |
9 | TOKENSOL=TestERC20Token.sol
10 | TOKENTRADERFACTORYSOL=TokenTraderFactory.sol
11 | TOKENSELLERFACTORYSOL=TokenSellerFactory.sol
12 | GNTTOKENTRADERFACTORYSOL=GNTTokenTraderFactory.sol
13 |
14 | TEMPINFILE=zzinput.tmp
15 | TEMPOUTFILE=zzoutput.tmp
16 |
17 | TOKENOUTPUTFILE=tokenOutput.txt
18 | TOKENDATAFILE=tokenData.txt
19 | TOKENRESULTFILE=tokenResults.txt
20 |
21 | FACTORYOUTPUTFILE=factoryOutput.txt
22 | FACTORYDATAFILE=factoryData.txt
23 | FACTORYRESULTFILE=factoryResults.txt
24 |
25 | EXECUTIONOUTPUTFILE=executionOutput.txt
26 | EXECUTIONRESULTFILE=executionResults.txt
27 |
28 | OTHEROUTPUTFILE=otherOutput.txt
29 | OTHERRESULTFILE=otherResults.txt
30 |
31 | EVENTRESULTFILE=eventResults.txt
32 |
--------------------------------------------------------------------------------
/testing/test_20170115_1619/stripCrLf:
--------------------------------------------------------------------------------
1 | #!/usr/bin/perl
2 | while (<>) {
3 | chomp; # Remove newline
4 | s#/\*.*?\*/##sg; # Remove multiline comments
5 | s/\/\/.*$//go; # Remove // comments
6 | s/\s+/ /go; # Collapse space
7 | print;
8 | }
9 | print "\n";
10 |
--------------------------------------------------------------------------------
/testing/test_20170115_1619/testchain/keystore/UTC--2016-12-16T01-36-05.134620242Z--000d1009bd8f0b1301cc5edc28ed1222a3ce671e:
--------------------------------------------------------------------------------
1 | {"address":"000d1009bd8f0b1301cc5edc28ed1222a3ce671e","crypto":{"cipher":"aes-128-ctr","ciphertext":"d59bbf7979a49434bb5b9fd62deee6bade6d3863d51007ac5a68075493dc025c","cipherparams":{"iv":"4ea160bd84819089c721da4721094f1c"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":262144,"p":1,"r":8,"salt":"f3916dcd671250a149a2fa5dd1b9049e6f66f856460c0d156f6ca8d8804d1337"},"mac":"74e459f91acf536cd90182031043a1832f2c52d1e914b5c6fa9068e599a71b7c"},"id":"59f697eb-7fd7-4c97-bb7f-642f0efc875d","version":3}
--------------------------------------------------------------------------------
/testing/test_20170115_1619/testchain/keystore/UTC--2016-12-16T01-36-45.681050789Z--0014060ff383c9b21c6840a3b14aab06741e5c49:
--------------------------------------------------------------------------------
1 | {"address":"0014060ff383c9b21c6840a3b14aab06741e5c49","crypto":{"cipher":"aes-128-ctr","ciphertext":"05d4f6408ff59ef400fd251fdac2c05e634d6fb56abb2aafbb34c1960f4da43e","cipherparams":{"iv":"bdd2aa67855754664ca87b7d8f355730"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":262144,"p":1,"r":8,"salt":"13a9ee72e426c421fef154b1ae468d79e2cef70c7c04c44a7de5ff85211dcf9a"},"mac":"dde360e4b44ef71e71172edcf9869d481a099fa655e6f5ca481b5d30887e21f7"},"id":"163e5bfa-c75d-426b-95f9-68715ae38ed4","version":3}
--------------------------------------------------------------------------------
/testing/test_20170115_1619/testchain/keystore/UTC--2016-12-16T01-37-12.717455318Z--0020017ba4c67f76c76b1af8c41821ee54f37171:
--------------------------------------------------------------------------------
1 | {"address":"0020017ba4c67f76c76b1af8c41821ee54f37171","crypto":{"cipher":"aes-128-ctr","ciphertext":"56598c7aef98104a2e29731ea2e5962e74b09bf7b3dd4d5d97c78292977752df","cipherparams":{"iv":"0d696d5d1e2680d7a04f0be8062f4ed3"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":262144,"p":1,"r":8,"salt":"3b601ed2bdf111bdc11dee3f5a9b85ca5b566f521fd4444596c197ed35e87e1a"},"mac":"90664c391a208a2779c931a98ac7c27424d81ec6ede00bc132ae6ba566ad2a96"},"id":"78fe49c7-fd71-4c64-b78d-bf461cb3e71c","version":3}
--------------------------------------------------------------------------------
/testing/test_20170115_1619/testchain/keystore/UTC--2016-12-16T01-37-37.923741925Z--0036f6addb6d64684390f55a92f0f4988266901b:
--------------------------------------------------------------------------------
1 | {"address":"0036f6addb6d64684390f55a92f0f4988266901b","crypto":{"cipher":"aes-128-ctr","ciphertext":"f8d7c3bb1d2142dd3d45426a39c32ce21668647c4cbaa86b0b8021378c825fb5","cipherparams":{"iv":"e94709dc5f877f678e444a16bfd0dcad"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":262144,"p":1,"r":8,"salt":"1fbba771a9e7a34184fcbb03a8b30e1f0c6a6034a46f090a78242ed590ebc1af"},"mac":"977971908c8061c81756fd378337bc11f786146783a5a7089b6a5efa16822ed0"},"id":"ebc305b9-3e9f-4d6b-82a4-4d6c59a6807f","version":3}
--------------------------------------------------------------------------------
/testing/test_20170115_1619/testpassword:
--------------------------------------------------------------------------------
1 | testtest
2 |
--------------------------------------------------------------------------------
/testing/test_20170115_1619/tokenData.txt:
--------------------------------------------------------------------------------
1 | tokenABI=[{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_amount","type":"uint256"}],"name":"approve","outputs":[{"name":"success","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"totalSupply","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_amount","type":"uint256"}],"name":"transferFrom","outputs":[{"name":"success","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"}],"name":"balanceOf","outputs":[{"name":"balance","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_amount","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"},{"constant":false,"inputs":[{"name":"ethers","type":"uint256"}],"name":"withdrawEthers","outputs":[{"name":"ok","type":"bool"}],"payable":false,"type":"function"},{"inputs":[],"type":"constructor"},{"payable":true,"type":"fallback"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_owner","type":"address"},{"indexed":false,"name":"_amount","type":"uint256"}],"name":"TokensCreated","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"}]
2 | tokenAddressA=0xebb2634dd3194ba6d75eeb049cd0f73bf9801d95
3 | tokenAddressB=0xe9ba90b474ef72aa062d89a319c3e15b31e8fe65
4 | tokenAddressC=0x30da52ef30bdaec61b43317cc045e4f267eaf779
5 |
--------------------------------------------------------------------------------
/testing/test_20170115_1619/tokenOutput.txt:
--------------------------------------------------------------------------------
1 | geth endpoint 'ipc:./testchain/geth.ipc'
2 | Welcome to the Geth JavaScript console!
3 |
4 | instance: Geth/v1.5.5-stable-ff07d548/darwin/go1.7.4
5 | coinbase: 0x000d1009bd8f0b1301cc5edc28ed1222a3ce671e
6 | at block: 0 (Thu, 01 Jan 1970 10:00:00 AEST)
7 | datadir: /Users/bok/CryptoDerivatives/TokenTraderFactory/testchain
8 | modules: admin:1.0 debug:1.0 eth:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 txpool:1.0 web3:1.0
9 |
10 | >
11 | >
12 | undefined
13 | >
14 | >
15 | ...
16 | ...
17 | ......
18 | ......
19 | ...
20 | ...
21 | undefined
22 | >
23 | >
24 | undefined
25 | >
26 | undefined
27 | >
28 | "Account #0"
29 | >
30 | "Account #1"
31 | >
32 | "Account #2"
33 | >
34 | >
35 | ...
36 | ...
37 | ...
38 | .........
39 | .........
40 | .........
41 | .........
42 | .........
43 | .........
44 | ............
45 | .........
46 | ...
47 | undefined
48 | >
49 | >
50 | ...
51 | ...
52 | ...
53 | ......
54 | ...
55 | undefined
56 | >
57 | >
58 | ...
59 | ...
60 | ......
61 | ......
62 | ......
63 | ......
64 | ...
65 | undefined
66 | >
67 | >
68 | ...
69 | ...
70 | ......
71 | ......
72 | ......
73 | ......
74 | ...
75 | undefined
76 | >
77 | >
78 | RESULT: Creating ERC20 Token @ Sun, 15 Jan 2017 16:15:47 AEDT
79 | undefined
80 | >
81 | >
82 | ...
83 | ...
84 | true
85 | >
86 | >
87 | true
88 | >
89 | >
90 | undefined
91 | >
92 | DATA: tokenABI=[{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_amount","type":"uint256"}],"name":"approve","outputs":[{"name":"success","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"totalSupply","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_amount","type":"uint256"}],"name":"transferFrom","outputs":[{"name":"success","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"}],"name":"balanceOf","outputs":[{"name":"balance","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_amount","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"},{"constant":false,"inputs":[{"name":"ethers","type":"uint256"}],"name":"withdrawEthers","outputs":[{"name":"ok","type":"bool"}],"payable":false,"type":"function"},{"inputs":[],"type":"constructor"},{"payable":true,"type":"fallback"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_owner","type":"address"},{"indexed":false,"name":"_amount","type":"uint256"}],"name":"TokensCreated","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"}]
93 | undefined
94 | >
95 | undefined
96 | >
97 | >
98 | undefined
99 | >
100 | undefined
101 | >
102 | undefined
103 | >
104 | ...
105 | ......
106 | .........
107 | ............
108 | ............
109 | ............
110 | ............
111 | ............
112 | ............
113 | ............
114 | ............
115 | .........
116 | ......
117 | ...
118 | tokenTxA=0xe6781102ca54691e5ff695e2b68c1ee251b6da766ae9621f64a14006dbc0f7d2
119 | undefined
120 | >
121 | ...
122 | undefined
123 | >
124 | >
125 | DATA: tokenAddressA=0xebb2634dd3194ba6d75eeb049cd0f73bf9801d95
126 | RESULT: tokenAddressA=0xebb2634dd3194ba6d75eeb049cd0f73bf9801d95 gas=400000 gasUsed=350123 cost=0.007402476877574288 block=5 txId=0xe6781102ca54691e5ff695e2b68c1ee251b6da766ae9621f64a14006dbc0f7d2
127 | undefined
128 | >
129 | undefined
130 | >
131 | undefined
132 | >
133 | ...
134 | ......
135 | .........
136 | ............
137 | ............
138 | ............
139 | ............
140 | ............
141 | ............
142 | ............
143 | ............
144 | .........
145 | ......
146 | ...
147 | tokenTxB=0x5bf2b8cdac5673ff30ee38cefb1352cda552df1211268e9443296bcbf1ee8752
148 | undefined
149 | >
150 | ...
151 | undefined
152 | >
153 | >
154 | DATA: tokenAddressB=0xe9ba90b474ef72aa062d89a319c3e15b31e8fe65
155 | RESULT: tokenAddressB=0xe9ba90b474ef72aa062d89a319c3e15b31e8fe65 gas=400000 gasUsed=350123 cost=0.007250624035494476 block=7 txId=0x5bf2b8cdac5673ff30ee38cefb1352cda552df1211268e9443296bcbf1ee8752
156 | undefined
157 | >
158 | undefined
159 | >
160 | undefined
161 | >
162 | ...
163 | ......
164 | .........
165 | ............
166 | ............
167 | ............
168 | ............
169 | ............
170 | ............
171 | ............
172 | ............
173 | .........
174 | ......
175 | ...
176 | tokenTxC=0x8da9f5682581f4c9ee8bd2456353ca29098543b488ff592a660ab6bba087b3c9
177 | undefined
178 | >
179 | ...
180 | undefined
181 | >
182 | >
183 | DATA: tokenAddressC=0x30da52ef30bdaec61b43317cc045e4f267eaf779
184 | RESULT: tokenAddressC=0x30da52ef30bdaec61b43317cc045e4f267eaf779 gas=400000 gasUsed=350123 cost=0.007111864294037855 block=9 txId=0x8da9f5682581f4c9ee8bd2456353ca29098543b488ff592a660ab6bba087b3c9
185 | undefined
186 | >
187 | ...
188 | ...
189 | ...
190 | ...
191 | Sending 1000 ETH from eth.accounts[0] to tokenA 0xebb2634dd3194ba6d75eeb049cd0f73bf9801d95
192 | txIdsA[0]=0x1866bd0caa197389e374d7ab84d36049003a39aa359efd5befca41049d3b7c83
193 | Sending 1000 ETH from eth.accounts[1] to tokenA 0xebb2634dd3194ba6d75eeb049cd0f73bf9801d95
194 | txIdsA[1]=0x089cf0498a63d6a34398e2ff6e8dc642c3e08e2be8d5532cf391f8e3343b290b
195 | Sending 1000 ETH from eth.accounts[2] to tokenA 0xebb2634dd3194ba6d75eeb049cd0f73bf9801d95
196 | txIdsA[2]=0x66ad4bd24712cf4eb7e9ef20428fc40be32b67c4f558ac0f432452d6aa8f9608
197 | undefined
198 | >
199 | >
200 | undefined
201 | >
202 | ...
203 | ...
204 | ...
205 | ...
206 | Sending 1000 ETH from eth.accounts[0] to tokenB 0xe9ba90b474ef72aa062d89a319c3e15b31e8fe65
207 | txIdsB[0]=0xbff06110b773375912df43d6f1bb2e2ccfe27c49564a113733e1add519154a0b
208 | Sending 1000 ETH from eth.accounts[1] to tokenB 0xe9ba90b474ef72aa062d89a319c3e15b31e8fe65
209 | txIdsB[1]=0x042947844d5faaa6ce7099107715ade366688221ccc944cbbb06baf0a61728b9
210 | Sending 1000 ETH from eth.accounts[2] to tokenB 0xe9ba90b474ef72aa062d89a319c3e15b31e8fe65
211 | txIdsB[2]=0x615e8812033c14fe6628dd1a4a66a323cd66462809b69b692c302f5bba3b9740
212 | undefined
213 | >
214 | >
215 | undefined
216 | >
217 | ...
218 | ...
219 | ...
220 | ...
221 | Sending 1000 ETH from eth.accounts[0] to tokenC 0x30da52ef30bdaec61b43317cc045e4f267eaf779
222 | txIdsC[0]=0x8b9a5b3caa4815e271700937d0a42ab67b5f0314a9eb53bd32499203a848618a
223 | Sending 1000 ETH from eth.accounts[1] to tokenC 0x30da52ef30bdaec61b43317cc045e4f267eaf779
224 | txIdsC[1]=0xc9050e7f7c9787a563fb0df437efad8155f476494331e6cbc6f9cc42957ad4f2
225 | Sending 1000 ETH from eth.accounts[2] to tokenC 0x30da52ef30bdaec61b43317cc045e4f267eaf779
226 | txIdsC[2]=0x7d8cb9b937a4f8265590d1a7133359195b571043a1c02255ceead856526182b8
227 | undefined
228 | >
229 | ...
230 | undefined
231 | >
232 | >
233 | ...
234 | ...
235 | RESULT: Sent 1000 ETH from accounts[0] to tokenA 0xebb2634d gas=100000 gasUsed=61318 cost=0.00122636 block=11 txId=0x1866bd0caa197389e374d7ab84d36049003a39aa359efd5befca41049d3b7c83
236 | RESULT: Sent 1000 ETH from accounts[1] to tokenA 0xebb2634d gas=100000 gasUsed=46318 cost=0.00092636 block=11 txId=0x089cf0498a63d6a34398e2ff6e8dc642c3e08e2be8d5532cf391f8e3343b290b
237 | RESULT: Sent 1000 ETH from accounts[2] to tokenA 0xebb2634d gas=100000 gasUsed=46318 cost=0.00092636 block=11 txId=0x66ad4bd24712cf4eb7e9ef20428fc40be32b67c4f558ac0f432452d6aa8f9608
238 | undefined
239 | >
240 | ...
241 | ...
242 | RESULT: Sent 1000 ETH from accounts[0] to tokenB 0xe9ba90b4 gas=100000 gasUsed=61318 cost=0.00122636 block=11 txId=0xbff06110b773375912df43d6f1bb2e2ccfe27c49564a113733e1add519154a0b
243 | RESULT: Sent 1000 ETH from accounts[1] to tokenB 0xe9ba90b4 gas=100000 gasUsed=46318 cost=0.00092636 block=11 txId=0x042947844d5faaa6ce7099107715ade366688221ccc944cbbb06baf0a61728b9
244 | RESULT: Sent 1000 ETH from accounts[2] to tokenB 0xe9ba90b4 gas=100000 gasUsed=46318 cost=0.00092636 block=11 txId=0x615e8812033c14fe6628dd1a4a66a323cd66462809b69b692c302f5bba3b9740
245 | undefined
246 | >
247 | ...
248 | ...
249 | RESULT: Sent 1000 ETH from accounts[0] to tokenC 0x30da52ef gas=100000 gasUsed=61318 cost=0.00122636 block=11 txId=0x8b9a5b3caa4815e271700937d0a42ab67b5f0314a9eb53bd32499203a848618a
250 | RESULT: Sent 1000 ETH from accounts[1] to tokenC 0x30da52ef gas=100000 gasUsed=46318 cost=0.00092636 block=11 txId=0xc9050e7f7c9787a563fb0df437efad8155f476494331e6cbc6f9cc42957ad4f2
251 | RESULT: Sent 1000 ETH from accounts[2] to tokenC 0x30da52ef gas=100000 gasUsed=46318 cost=0.00092636 block=11 txId=0x7d8cb9b937a4f8265590d1a7133359195b571043a1c02255ceead856526182b8
252 | undefined
253 | >
254 | >
255 | RESULT: # Account EtherBalance TokenABalance TokenBBalance TokenCBalance Name
256 | RESULT: 1 0x000d1009bd8f0b1301cc5edc28ed1222a3ce671e 97055.027323125207106619 1000.000000000000000000 1000.000000000000000000 1000.000000000000000000 Account #0
257 | RESULT: 2 0x0014060ff383c9b21c6840a3b14aab06741e5c49 96999.975455954792893381 1000.000000000000000000 1000.000000000000000000 1000.000000000000000000 Account #1
258 | RESULT: 3 0x0020017ba4c67f76c76b1af8c41821ee54f37171 96999.997220920000000000 1000.000000000000000000 1000.000000000000000000 1000.000000000000000000 Account #2
259 | RESULT: 4 0xebb2634dd3194ba6d75eeb049cd0f73bf9801d95 3000.000000000000000000 0.000000000000000000 0.000000000000000000 0.000000000000000000 ERC20A
260 | RESULT: 5 0xe9ba90b474ef72aa062d89a319c3e15b31e8fe65 3000.000000000000000000 0.000000000000000000 0.000000000000000000 0.000000000000000000 ERC20B
261 | RESULT: 6 0x30da52ef30bdaec61b43317cc045e4f267eaf779 3000.000000000000000000 0.000000000000000000 0.000000000000000000 0.000000000000000000 ERC20C
262 | undefined
263 | >
264 | >
265 | RESULT: OK 0xebb2634dd3194ba6d75eeb049cd0f73bf9801d95 has expected balance 3000
266 | undefined
267 | >
268 | RESULT: OK 0xe9ba90b474ef72aa062d89a319c3e15b31e8fe65 has expected balance 3000
269 | undefined
270 | >
271 | RESULT: OK 0x30da52ef30bdaec61b43317cc045e4f267eaf779 has expected balance 3000
272 | undefined
273 | >
274 | >
275 | RESULT: OK 0x000d1009bd8f0b1301cc5edc28ed1222a3ce671e has expected ERC20A token balance 1000
276 | undefined
277 | >
278 | RESULT: OK 0x0014060ff383c9b21c6840a3b14aab06741e5c49 has expected ERC20A token balance 1000
279 | undefined
280 | >
281 | RESULT: OK 0x0020017ba4c67f76c76b1af8c41821ee54f37171 has expected ERC20A token balance 1000
282 | undefined
283 | >
284 | >
285 | RESULT: OK 0x000d1009bd8f0b1301cc5edc28ed1222a3ce671e has expected ERC20B token balance 1000
286 | undefined
287 | >
288 | RESULT: OK 0x0014060ff383c9b21c6840a3b14aab06741e5c49 has expected ERC20B token balance 1000
289 | undefined
290 | >
291 | RESULT: OK 0x0020017ba4c67f76c76b1af8c41821ee54f37171 has expected ERC20B token balance 1000
292 | undefined
293 | >
294 | >
295 | RESULT: OK 0x000d1009bd8f0b1301cc5edc28ed1222a3ce671e has expected ERC20B token balance 1000
296 | undefined
297 | >
298 | RESULT: OK 0x0014060ff383c9b21c6840a3b14aab06741e5c49 has expected ERC20B token balance 1000
299 | undefined
300 | >
301 | RESULT: OK 0x0020017ba4c67f76c76b1af8c41821ee54f37171 has expected ERC20B token balance 1000
302 | undefined
303 | >
304 | >
305 |
--------------------------------------------------------------------------------
/testing/test_20170115_1619/tokenResults.txt:
--------------------------------------------------------------------------------
1 | Creating ERC20 Token @ Sun, 15 Jan 2017 16:15:47 AEDT
2 | tokenAddressA=0xebb2634dd3194ba6d75eeb049cd0f73bf9801d95 gas=400000 gasUsed=350123 cost=0.007402476877574288 block=5 txId=0xe6781102ca54691e5ff695e2b68c1ee251b6da766ae9621f64a14006dbc0f7d2
3 | tokenAddressB=0xe9ba90b474ef72aa062d89a319c3e15b31e8fe65 gas=400000 gasUsed=350123 cost=0.007250624035494476 block=7 txId=0x5bf2b8cdac5673ff30ee38cefb1352cda552df1211268e9443296bcbf1ee8752
4 | tokenAddressC=0x30da52ef30bdaec61b43317cc045e4f267eaf779 gas=400000 gasUsed=350123 cost=0.007111864294037855 block=9 txId=0x8da9f5682581f4c9ee8bd2456353ca29098543b488ff592a660ab6bba087b3c9
5 | Sent 1000 ETH from accounts[0] to tokenA 0xebb2634d gas=100000 gasUsed=61318 cost=0.00122636 block=11 txId=0x1866bd0caa197389e374d7ab84d36049003a39aa359efd5befca41049d3b7c83
6 | Sent 1000 ETH from accounts[1] to tokenA 0xebb2634d gas=100000 gasUsed=46318 cost=0.00092636 block=11 txId=0x089cf0498a63d6a34398e2ff6e8dc642c3e08e2be8d5532cf391f8e3343b290b
7 | Sent 1000 ETH from accounts[2] to tokenA 0xebb2634d gas=100000 gasUsed=46318 cost=0.00092636 block=11 txId=0x66ad4bd24712cf4eb7e9ef20428fc40be32b67c4f558ac0f432452d6aa8f9608
8 | Sent 1000 ETH from accounts[0] to tokenB 0xe9ba90b4 gas=100000 gasUsed=61318 cost=0.00122636 block=11 txId=0xbff06110b773375912df43d6f1bb2e2ccfe27c49564a113733e1add519154a0b
9 | Sent 1000 ETH from accounts[1] to tokenB 0xe9ba90b4 gas=100000 gasUsed=46318 cost=0.00092636 block=11 txId=0x042947844d5faaa6ce7099107715ade366688221ccc944cbbb06baf0a61728b9
10 | Sent 1000 ETH from accounts[2] to tokenB 0xe9ba90b4 gas=100000 gasUsed=46318 cost=0.00092636 block=11 txId=0x615e8812033c14fe6628dd1a4a66a323cd66462809b69b692c302f5bba3b9740
11 | Sent 1000 ETH from accounts[0] to tokenC 0x30da52ef gas=100000 gasUsed=61318 cost=0.00122636 block=11 txId=0x8b9a5b3caa4815e271700937d0a42ab67b5f0314a9eb53bd32499203a848618a
12 | Sent 1000 ETH from accounts[1] to tokenC 0x30da52ef gas=100000 gasUsed=46318 cost=0.00092636 block=11 txId=0xc9050e7f7c9787a563fb0df437efad8155f476494331e6cbc6f9cc42957ad4f2
13 | Sent 1000 ETH from accounts[2] to tokenC 0x30da52ef gas=100000 gasUsed=46318 cost=0.00092636 block=11 txId=0x7d8cb9b937a4f8265590d1a7133359195b571043a1c02255ceead856526182b8
14 | # Account EtherBalance TokenABalance TokenBBalance TokenCBalance Name
15 | 1 0x000d1009bd8f0b1301cc5edc28ed1222a3ce671e 97055.027323125207106619 1000.000000000000000000 1000.000000000000000000 1000.000000000000000000 Account #0
16 | 2 0x0014060ff383c9b21c6840a3b14aab06741e5c49 96999.975455954792893381 1000.000000000000000000 1000.000000000000000000 1000.000000000000000000 Account #1
17 | 3 0x0020017ba4c67f76c76b1af8c41821ee54f37171 96999.997220920000000000 1000.000000000000000000 1000.000000000000000000 1000.000000000000000000 Account #2
18 | 4 0xebb2634dd3194ba6d75eeb049cd0f73bf9801d95 3000.000000000000000000 0.000000000000000000 0.000000000000000000 0.000000000000000000 ERC20A
19 | 5 0xe9ba90b474ef72aa062d89a319c3e15b31e8fe65 3000.000000000000000000 0.000000000000000000 0.000000000000000000 0.000000000000000000 ERC20B
20 | 6 0x30da52ef30bdaec61b43317cc045e4f267eaf779 3000.000000000000000000 0.000000000000000000 0.000000000000000000 0.000000000000000000 ERC20C
21 | OK 0xebb2634dd3194ba6d75eeb049cd0f73bf9801d95 has expected balance 3000
22 | OK 0xe9ba90b474ef72aa062d89a319c3e15b31e8fe65 has expected balance 3000
23 | OK 0x30da52ef30bdaec61b43317cc045e4f267eaf779 has expected balance 3000
24 | OK 0x000d1009bd8f0b1301cc5edc28ed1222a3ce671e has expected ERC20A token balance 1000
25 | OK 0x0014060ff383c9b21c6840a3b14aab06741e5c49 has expected ERC20A token balance 1000
26 | OK 0x0020017ba4c67f76c76b1af8c41821ee54f37171 has expected ERC20A token balance 1000
27 | OK 0x000d1009bd8f0b1301cc5edc28ed1222a3ce671e has expected ERC20B token balance 1000
28 | OK 0x0014060ff383c9b21c6840a3b14aab06741e5c49 has expected ERC20B token balance 1000
29 | OK 0x0020017ba4c67f76c76b1af8c41821ee54f37171 has expected ERC20B token balance 1000
30 | OK 0x000d1009bd8f0b1301cc5edc28ed1222a3ce671e has expected ERC20B token balance 1000
31 | OK 0x0014060ff383c9b21c6840a3b14aab06741e5c49 has expected ERC20B token balance 1000
32 | OK 0x0020017ba4c67f76c76b1af8c41821ee54f37171 has expected ERC20B token balance 1000
33 |
--------------------------------------------------------------------------------
/testing/test_20170125_0829/00_runGeth.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | rm -f ./testchain/geth/chaindata/*
4 |
5 | geth --datadir ./testchain init genesis.json
6 |
7 | geth --datadir ./testchain --unlock 0 --password ./testpassword --rpc --rpccorsdomain '*' --rpcport 8646 --rpcapi "eth,net,web3,debug" --port 32323 --mine --minerthreads 1 --maxpeers 0 console
8 |
9 |
--------------------------------------------------------------------------------
/testing/test_20170125_0829/01_deployERC20Token.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | # --------------------------------------------------------------------
3 | # Testing Contracts At https://github.com/bokkypoobah/TokenTrader
4 | #
5 | # Deploy ERC20 Token
6 | #
7 | # (c) BokkyPooBah 2017. The MIT licence.
8 | # --------------------------------------------------------------------
9 |
10 | GETHATTACHPOINT=`grep IPCFILE settings.txt | sed "s/^.*=//"`
11 | PASSWORD=`grep PASSWORD settings.txt | sed "s/^.*=//"`
12 |
13 | TYPE=`grep TYPE settings.txt | sed "s/^.*=//"`
14 | INITIALETH=`grep INITIALETH settings.txt | sed "s/^.*=//"`
15 |
16 | TEMPINFILE=`grep TEMPINFILE settings.txt | sed "s/^.*=//"`
17 | TOKENOUTPUTFILE=`grep TOKENOUTPUTFILE settings.txt | sed "s/^.*=//"`
18 |
19 | TOKENSOL=`grep TOKENSOL settings.txt | sed "s/^.*=//"`
20 | FLATTENEDSOL=`./stripCrLf $TOKENSOL`
21 | printf "var tokenSource = \"$FLATTENEDSOL\"" > $TEMPINFILE
22 |
23 | TOKENDATAFILE=`grep TOKENDATA settings.txt | sed "s/^.*=//"`
24 | TOKENRESULTFILE=`grep TOKENRESULTFILE settings.txt | sed "s/^.*=//"`
25 |
26 | printf "geth endpoint '$GETHATTACHPOINT'\n" | tee $TOKENOUTPUTFILE
27 |
28 | geth --verbosity 3 attach $GETHATTACHPOINT << EOF | tee -a $TOKENOUTPUTFILE
29 |
30 | var ACCOUNTS = 3;
31 |
32 | function pad(s) {
33 | var o = s.toFixed(18);
34 | while (o.length < 27) {
35 | o = " " + o;
36 | }
37 | return o;
38 | }
39 |
40 | var accounts = [eth.accounts[0], eth.accounts[1], eth.accounts[2]];
41 | var accountName = {};
42 | accountName[eth.accounts[0]] = "Account #0";
43 | accountName[eth.accounts[1]] = "Account #1";
44 | accountName[eth.accounts[2]] = "Account #2";
45 |
46 | function printBalances(accounts) {
47 | var i = 0;
48 | console.log("RESULT: # Account EtherBalance TokenABalance TokenBBalance TokenCBalance Name");
49 | accounts.forEach(function(e) {
50 | i++;
51 | var etherBalance = web3.fromWei(eth.getBalance(e), "ether");
52 | var tokenABalance = web3.fromWei(tokenA.balanceOf(e), "ether");
53 | var tokenBBalance = web3.fromWei(tokenB.balanceOf(e), "ether");
54 | var tokenCBalance = web3.fromWei(tokenC.balanceOf(e), "ether");
55 | console.log("RESULT: " + i + " " + e + " " + pad(etherBalance) + " " + pad(tokenABalance) + " " + pad(tokenBBalance) + " " +
56 | pad(tokenCBalance) + " " + accountName[e]);
57 | });
58 | }
59 |
60 | function printTxData(name, txId) {
61 | var tx = eth.getTransaction(txId);
62 | var txReceipt = eth.getTransactionReceipt(txId);
63 | console.log("RESULT: " + name + " gas=" + tx.gas + " gasUsed=" + txReceipt.gasUsed + " cost=" + tx.gasPrice.mul(txReceipt.gasUsed).div(1e18) +
64 | " block=" + txReceipt.blockNumber + " txId=" + txId);
65 | }
66 |
67 | function assertEtherBalance(account, testBalance) {
68 | var etherBalance = web3.fromWei(eth.getBalance(account), "ether");
69 | if (etherBalance == testBalance) {
70 | console.log("RESULT: OK " + account + " has expected balance " + testBalance);
71 | } else {
72 | console.log("RESULT: FAILURE " + account + " has balance " + etherBalance + " <> expected " + testBalance);
73 | }
74 | }
75 |
76 | function assertTokenBalance(account, token, testBalance) {
77 | var tokenBalance = token.balanceOf(account).div(1e18);
78 | if (tokenBalance == testBalance) {
79 | console.log("RESULT: OK " + account + " has expected " + accountName[token.address] + " token balance " + testBalance);
80 | } else {
81 | console.log("RESULT: FAILURE " + account + " has " + accountName[token.address] + " token balance " + tokenBalance + " <> expected " + testBalance);
82 | }
83 | }
84 |
85 | console.log("RESULT: Creating ERC20 Token @ " + new Date());
86 |
87 | for (var i = 0; i < ACCOUNTS; i++) {
88 | personal.unlockAccount(eth.accounts[i], "$PASSWORD", 100000);
89 | }
90 |
91 | loadScript("$TEMPINFILE");
92 |
93 | var tokenCompiled = web3.eth.compile.solidity(tokenSource);
94 | console.log("DATA: tokenABI=" + JSON.stringify(tokenCompiled.TestERC20Token.info.abiDefinition));
95 | var tokenContract = web3.eth.contract(tokenCompiled.TestERC20Token.info.abiDefinition);
96 |
97 | // TokenA
98 | var tokenAddressA = null;
99 | var tokenTxA = null;
100 | var tokenA = tokenContract.new("TokenA", "ERC20A", 16, {from: eth.accounts[1], data: tokenCompiled.TestERC20Token.code, gas: 800000},
101 | function(e, contract) {
102 | if (!e) {
103 | if (!contract.address) {
104 | tokenTxA = contract.transactionHash;
105 | console.log("tokenTxA=" + tokenTxA);
106 | } else {
107 | tokenAddressA = contract.address;
108 | accountName[tokenAddressA] = "ERC20A";
109 | console.log("DATA: tokenAddressA=" + tokenAddressA);
110 | printTxData("tokenAddressA=" + tokenAddressA, tokenTxA);
111 | }
112 | }
113 | }
114 | );
115 | while (txpool.status.pending > 0) {
116 | }
117 |
118 | // TokenB
119 | var tokenAddressB = null;
120 | var tokenTxB = null;
121 | var tokenB = tokenContract.new("TokenB", "ERC20B", 18, {from: eth.accounts[1], data: tokenCompiled.TestERC20Token.code, gas: 600000},
122 | function(e, contract) {
123 | if (!e) {
124 | if (!contract.address) {
125 | tokenTxB = contract.transactionHash;
126 | console.log("tokenTxB=" + tokenTxB);
127 | } else {
128 | tokenAddressB = contract.address;
129 | accountName[tokenAddressB] = "ERC20B";
130 | console.log("DATA: tokenAddressB=" + tokenAddressB);
131 | printTxData("tokenAddressB=" + tokenAddressB, tokenTxB);
132 | }
133 | }
134 | }
135 | );
136 | while (txpool.status.pending > 0) {
137 | }
138 |
139 | // TokenC
140 | var tokenAddressC = null;
141 | var tokenTxC = null;
142 | var tokenC = tokenContract.new("TokenC", "ERC20C", 18, {from: eth.accounts[1], data: tokenCompiled.TestERC20Token.code, gas: 600000},
143 | function(e, contract) {
144 | if (!e) {
145 | if (!contract.address) {
146 | tokenTxC = contract.transactionHash;
147 | console.log("tokenTxC=" + tokenTxC);
148 | } else {
149 | tokenAddressC = contract.address;
150 | accountName[tokenAddressC] = "ERC20C";
151 | console.log("DATA: tokenAddressC=" + tokenAddressC);
152 | printTxData("tokenAddressC=" + tokenAddressC, tokenTxC);
153 | }
154 | }
155 | }
156 | );
157 | while (txpool.status.pending > 0) {
158 | }
159 |
160 | var txIdsA = [];
161 | for (var i = 0; i < ACCOUNTS; i++) {
162 | console.log("Sending $INITIALETH ETH from eth.accounts[" + i + "] to tokenA " + tokenAddressA);
163 | txIdsA[i] = eth.sendTransaction({from: eth.accounts[i], to: tokenAddressA, value: web3.toWei("$INITIALETH", "ether"), gas: 100000});
164 | console.log("txIdsA[" + i + "]=" + txIdsA[i]);
165 | }
166 |
167 | var txIdsB = [];
168 | for (var i = 0; i < ACCOUNTS; i++) {
169 | console.log("Sending $INITIALETH ETH from eth.accounts[" + i + "] to tokenB " + tokenAddressB);
170 | txIdsB[i] = eth.sendTransaction({from: eth.accounts[i], to: tokenAddressB, value: web3.toWei("$INITIALETH", "ether"), gas: 100000});
171 | console.log("txIdsB[" + i + "]=" + txIdsB[i]);
172 | }
173 |
174 | var txIdsC = [];
175 | for (var i = 0; i < ACCOUNTS; i++) {
176 | console.log("Sending $INITIALETH ETH from eth.accounts[" + i + "] to tokenC " + tokenAddressC);
177 | txIdsC[i] = eth.sendTransaction({from: eth.accounts[i], to: tokenAddressC, value: web3.toWei("$INITIALETH", "ether"), gas: 100000});
178 | console.log("txIdsC[" + i + "]=" + txIdsC[i]);
179 | }
180 | while (txpool.status.pending > 0) {
181 | }
182 |
183 | for (var i = 0; i < ACCOUNTS; i++) {
184 | printTxData("Sent $INITIALETH ETH from accounts[" + i + "] to tokenA " + tokenAddressA.substring(0, 10), txIdsA[i]);
185 | }
186 | for (var i = 0; i < ACCOUNTS; i++) {
187 | printTxData("Sent $INITIALETH ETH from accounts[" + i + "] to tokenB " + tokenAddressB.substring(0, 10), txIdsB[i]);
188 | }
189 | for (var i = 0; i < ACCOUNTS; i++) {
190 | printTxData("Sent $INITIALETH ETH from accounts[" + i + "] to tokenC " + tokenAddressC.substring(0, 10), txIdsC[i]);
191 | }
192 |
193 | printBalances([eth.accounts[0], eth.accounts[1], eth.accounts[2], tokenAddressA, tokenAddressB, tokenAddressC]);
194 |
195 | assertEtherBalance(tokenAddressA, 3000);
196 | assertEtherBalance(tokenAddressB, 3000);
197 | assertEtherBalance(tokenAddressC, 3000);
198 |
199 | assertTokenBalance(eth.accounts[0], tokenA, 1000);
200 | assertTokenBalance(eth.accounts[1], tokenA, 1000);
201 | assertTokenBalance(eth.accounts[2], tokenA, 1000);
202 |
203 | assertTokenBalance(eth.accounts[0], tokenB, 1000);
204 | assertTokenBalance(eth.accounts[1], tokenB, 1000);
205 | assertTokenBalance(eth.accounts[2], tokenB, 1000);
206 |
207 | assertTokenBalance(eth.accounts[0], tokenB, 1000);
208 | assertTokenBalance(eth.accounts[1], tokenB, 1000);
209 | assertTokenBalance(eth.accounts[2], tokenB, 1000);
210 |
211 | EOF
212 |
213 | grep "DATA: " $TOKENOUTPUTFILE | sed "s/DATA: //" > $TOKENDATAFILE
214 | grep "RESULT: " $TOKENOUTPUTFILE | sed "s/RESULT: //" > $TOKENRESULTFILE
215 | cat $TOKENRESULTFILE
216 |
--------------------------------------------------------------------------------
/testing/test_20170125_0829/05_checkEvents.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # --------------------------------------------------------------------
3 | # Testing Contracts At https://github.com/bokkypoobah/TokenTrader
4 | # for https://cryptoderivatives.market/
5 | #
6 | # Checking Generated Events
7 | #
8 | # (c) BokkyPooBah 2017. The MIT licence.
9 | # --------------------------------------------------------------------
10 |
11 | GETHATTACHPOINT=`grep IPCFILE settings.txt | sed "s/^.*=//"`
12 | PASSWORD=`grep PASSWORD settings.txt | sed "s/^.*=//"`
13 |
14 | TEMPINFILE=`grep TEMPINFILE settings.txt | sed "s/^.*=//"`
15 | TEMPOUTFILE=`grep TEMPOUTFILE settings.txt | sed "s/^.*=//"`
16 | EVENTRESULTFILE=`grep EVENTRESULTFILE settings.txt | sed "s/^.*=//"`
17 |
18 | TOKENDATAFILE=`grep TOKENDATA settings.txt | sed "s/^.*=//"`
19 | TOKENADDRESSA=`grep tokenAddressA $TOKENDATAFILE | tail -n 1 | sed "s/^.*=//"`
20 | TOKENADDRESSB=`grep tokenAddressB $TOKENDATAFILE | tail -n 1 | sed "s/^.*=//"`
21 | TOKENADDRESSC=`grep tokenAddressC $TOKENDATAFILE | tail -n 1 | sed "s/^.*=//"`
22 | TOKENABI=`grep tokenABI $TOKENDATAFILE | tail -n 1 | sed "s/^.*=//"`
23 |
24 | FACTORYDATAFILE=`grep FACTORYDATAFILE settings.txt | sed "s/^.*=//"`
25 | TOKENTRADERFACTORYADDRESS=`grep ^tokenTraderFactoryAddress $FACTORYDATAFILE | tail -n 1 | sed "s/^.*=//"`
26 | TOKENTRADERFACTORYABI=`grep ^tokenTraderFactoryABI $FACTORYDATAFILE | tail -n 1 | sed "s/^.*=//"`
27 | TOKENTRADERADDRESS=`grep ^tokenTraderAddress $FACTORYDATAFILE | tail -n 1 | sed "s/^.*=//"`
28 | TOKENTRADERABI=`grep ^tokenTraderABI $FACTORYDATAFILE | tail -n 1 | sed "s/^.*=//"`
29 | TOKENSELLERFACTORYADDRESS=`grep tokenSellerFactoryAddress $FACTORYDATAFILE | tail -n 1 | sed "s/^.*=//"`
30 | TOKENSELLERFACTORYABI=`grep tokenSellerFactoryABI $FACTORYDATAFILE | tail -n 1 | sed "s/^.*=//"`
31 | TOKENSELLERADDRESS=`grep tokenSellerAddress $FACTORYDATAFILE | tail -n 1 | sed "s/^.*=//"`
32 | TOKENSELLERABI=`grep tokenSellerABI $FACTORYDATAFILE | tail -n 1 | sed "s/^.*=//"`
33 | GNTTOKENTRADERFACTORYADDRESS=`grep gntTokenTraderFactoryAddress $FACTORYDATAFILE | tail -n 1 | sed "s/^.*=//"`
34 | GNTTOKENTRADERFACTORYABI=`grep gntTokenTraderFactoryABI $FACTORYDATAFILE | tail -n 1 | sed "s/^.*=//"`
35 | GNTTOKENTRADERADDRESS=`grep gntTokenTraderAddress $FACTORYDATAFILE | tail -n 1 | sed "s/^.*=//"`
36 | GNTTOKENTRADERABI=`grep gntTokenTraderABI $FACTORYDATAFILE | tail -n 1 | sed "s/^.*=//"`
37 |
38 | printf "Connecting to geth on endpoint '$GETHATTACHPOINT'\n" | tee $TEMPOUTFILE
39 | printf "TokenA address '$TOKENADDRESSA'\n" | tee -a $TEMPOUTFILE
40 | printf "TokenB address '$TOKENADDRESSB'\n" | tee -a $TEMPOUTFILE
41 | printf "TokenC address '$TOKENADDRESSC'\n" | tee -a $TEMPOUTFILE
42 | printf "Token ABI '$TOKENABI'\n" | tee -a $TEMPOUTFILE
43 | printf "TokenTraderFactory address '$TOKENTRADERFACTORYADDRESS'\n" | tee -a $TEMPOUTFILE
44 | printf "TokenTraderFactory ABI '$TOKENTRADERFACTORYABI'\n" | tee -a $TEMPOUTFILE
45 | printf "TokenTrader address '$TOKENTRADERADDRESS'\n" | tee -a $TEMPOUTFILE
46 | printf "TokenTrader ABI '$TOKENTRADERABI'\n" | tee -a $TEMPOUTFILE
47 | printf "var tokenTraderABI = $TOKENTRADERABI;\n" > $TEMPINFILE
48 | printf "TokenSellerFactory address '$TOKENSELLERFACTORYADDRESS'\n" | tee -a $TEMPOUTFILE
49 | printf "TokenSellerFactory ABI '$TOKENSELLERFACTORYABI'\n" | tee -a $TEMPOUTFILE
50 | printf "TokenSeller address '$TOKENSELLERADDRESS'\n" | tee -a $TEMPOUTFILE
51 | printf "TokenSeller ABI '$TOKENSELLERABI'\n" | tee -a $TEMPOUTFILE
52 | printf "var tokenSellerABI = $TOKENSELLERABI;\n" >> $TEMPINFILE
53 | printf "GNTTokenTraderFactory address '$GNTTOKENTRADERFACTORYADDRESS'\n" | tee -a $TEMPOUTFILE
54 | printf "GNTTokenTraderFactory ABI '$GNTTOKENTRADERFACTORYABI'\n" | tee -a $TEMPOUTFILE
55 | printf "GNTTokenTrader address '$GNTTOKENTRADERADDRESS'\n" | tee -a $TEMPOUTFILE
56 | printf "GNTTokenTrader ABI '$GNTTOKENTRADERABI'\n" | tee -a $TEMPOUTFILE
57 | printf "EventResult '$EVENTRESULTFILE'\n" | tee -a $TEMPOUTFILE
58 |
59 | geth --verbosity 3 attach $GETHATTACHPOINT << EOF | tee -a $TEMPOUTFILE
60 |
61 | loadScript("$TEMPINFILE");
62 |
63 | var token = web3.eth.contract($TOKENABI).at("$TOKENADDRESS");
64 | var tokenTraderFactory = web3.eth.contract($TOKENTRADERFACTORYABI).at("$TOKENTRADERFACTORYADDRESS");
65 | var tokenTrader = web3.eth.contract(tokenTraderABI).at("$TOKENTRADERADDRESS");
66 | var tokenSellerFactory = web3.eth.contract($TOKENSELLERFACTORYABI).at("$TOKENSELLERFACTORYADDRESS");
67 | var tokenSeller = web3.eth.contract(tokenSellerABI).at("$TOKENSELLERADDRESS");
68 | var gntTokenTraderFactory = web3.eth.contract($GNTTOKENTRADERFACTORYABI).at("$GNTTOKENTRADERFACTORYADDRESS");
69 | var gntTokenTrader = web3.eth.contract($GNTTOKENTRADERABI).at("$GNTTOKENTRADERADDRESS");
70 |
71 | function pad(s) {
72 | var o = s.toFixed(18);
73 | while (o.length < 27) {
74 | o = " " + o;
75 | }
76 | return o;
77 | }
78 |
79 | var accounts = [eth.accounts[0], eth.accounts[1], "$TOKENADDRESSA", "$TOKENADDRESSB", "$TOKENADDRESSC", "$TOKENTRADERADDRESS", "$TOKENSELLERADDRESS", "$GNTTOKENTRADERADDRESS"];
80 | var accountName = {};
81 | accountName[eth.accounts[0]] = "Account #0";
82 | accountName[eth.accounts[1]] = "Account #1";
83 | accountName["$TOKENADDRESSA"] = "ERC20A";
84 | accountName["$TOKENADDRESSB"] = "ERC20B";
85 | accountName["$TOKENADDRESSC"] = "ERC20C";
86 | accountName["$TOKENTRADERFACTORYADDRESS"] = "TokenTraderFactory";
87 | accountName["$TOKENTRADERADDRESS"] = "TokenTrader b1.1,s1.2";
88 | accountName["$TOKENSELLERFACTORYADDRESS"] = "TokenSellerFactory";
89 | accountName["$TOKENSELLERADDRESS"] = "TokenSeller s1.2";
90 | accountName["$GNTTOKENTRADERFACTORYADDRESS"] = "GNTTokenTraderFactory";
91 | accountName["$GNTTOKENTRADERADDRESS"] = "GNTTokenTrader s1.3";
92 |
93 | function printBalances(accounts) {
94 | var i = 0;
95 | console.log("RESULT: # Account EtherBalance TokenABalance TokenBBalance TokenCBalance Name");
96 | accounts.forEach(function(e) {
97 | var etherBalance = web3.fromWei(eth.getBalance(e), "ether");
98 | var tokenABalance = web3.fromWei(tokenA.balanceOf(e), "ether");
99 | var tokenBBalance = web3.fromWei(tokenB.balanceOf(e), "ether");
100 | var tokenCBalance = web3.fromWei(tokenC.balanceOf(e), "ether");
101 | console.log("RESULT: " + i + " " + e + " " + pad(etherBalance) + " " + pad(tokenABalance) + " " + pad(tokenBBalance) + " " + pad(tokenCBalance) + " " + accountName[e]);
102 | i++;
103 | });
104 | }
105 |
106 | function printTxData(name, txId) {
107 | var tx = eth.getTransaction(txId);
108 | var txReceipt = eth.getTransactionReceipt(txId);
109 | console.log("RESULT: " + name + " gas=" + tx.gas + " gasUsed=" + txReceipt.gasUsed + " cost=" + tx.gasPrice.mulß(txReceipt.gasUsed).div(1e18) +
110 | " block=" + txReceipt.blockNumber + " txId=" + txId);
111 | }
112 |
113 | printBalances(accounts);
114 |
115 | console.log("RESULT: Factory Events");
116 | var filter = web3.eth.filter({ address: ["$TOKENTRADERFACTORYADDRESS", "$TOKENSELLERFACTORYADDRESS", "$GNTTOKENTRADERFACTORYADDRESS", "$TOKENTRADERADDRESS", "$TOKENSELLERADDRESS", "$GNTTOKENTRADERADDRESS"], fromBlock: 0, toBlock: "latest" });
117 | var i = 0;
118 | filter.watch(function (error, result) {
119 | console.log("RESULT: Filter " + i++ + ": " + JSON.stringify(result));
120 | });
121 | filter.stopWatching();
122 |
123 | // Check TokenTrader Events
124 | console.log("RESULT: TokenTrader ActivatedEvent");
125 | var tokenTraderActivatedEvent = tokenTrader.ActivatedEvent({}, { fromBlock: 0, toBlock: "latest" });
126 | var i = 0;
127 | tokenTraderActivatedEvent.watch(function (error, result) {
128 | console.log("RESULT: tokenTraderActivatedEvent " + i++ + ": " + JSON.stringify(result));
129 | });
130 | tokenTraderActivatedEvent.stopWatching();
131 |
132 | console.log("RESULT: TokenTrader MakerDepositedEther");
133 | var tokenTraderMakerDepositedEther = tokenTrader.MakerDepositedEther({}, { fromBlock: 0, toBlock: "latest" });
134 | var i = 0;
135 | tokenTraderMakerDepositedEther.watch(function (error, result) {
136 | console.log("RESULT: tokenTraderMakerDepositedEther " + i++ + ": " + JSON.stringify(result));
137 | });
138 | tokenTraderMakerDepositedEther.stopWatching();
139 |
140 | console.log("RESULT: TokenTrader MakerWithdrewAsset");
141 | var tokenTraderMakerWithdrewAsset = tokenTrader.MakerWithdrewAsset({}, { fromBlock: 0, toBlock: "latest" });
142 | var i = 0;
143 | tokenTraderMakerWithdrewAsset.watch(function (error, result) {
144 | console.log("RESULT: tokenTraderMakerWithdrewAsset " + i++ + ": " + JSON.stringify(result));
145 | });
146 | tokenTraderMakerWithdrewAsset.stopWatching();
147 |
148 | console.log("RESULT: TokenTrader MakerWithdrewEther");
149 | var tokenTraderMakerWithdrewEther = tokenTrader.MakerWithdrewEther({}, { fromBlock: 0, toBlock: "latest" });
150 | var i = 0;
151 | tokenTraderMakerWithdrewEther.watch(function (error, result) {
152 | console.log("RESULT: tokenTraderMakerWithdrewEther " + i++ + ": " + JSON.stringify(result));
153 | });
154 | tokenTraderMakerWithdrewEther.stopWatching();
155 |
156 | console.log("RESULT: TokenTrader TakerBoughtAsset");
157 | var tokenTraderTakerBoughtAsset = tokenTrader.TakerBoughtAsset({}, { fromBlock: 0, toBlock: "latest" });
158 | var i = 0;
159 | tokenTraderTakerBoughtAsset.watch(function (error, result) {
160 | console.log("RESULT: tokenTraderTakerBoughtAsset " + i++ + ": " + JSON.stringify(result));
161 | });
162 | tokenTraderTakerBoughtAsset.stopWatching();
163 |
164 | console.log("RESULT: TokenTrader TakerSoldAsset");
165 | var tokenTraderTakerSoldAsset = tokenTrader.TakerSoldAsset({}, { fromBlock: 0, toBlock: "latest" });
166 | var i = 0;
167 | tokenTraderTakerSoldAsset.watch(function (error, result) {
168 | console.log("RESULT: tokenTraderTakerSoldAsset " + i++ + ": " + JSON.stringify(result));
169 | });
170 | tokenTraderTakerSoldAsset.stopWatching();
171 |
172 | // Check TokenSeller Events
173 | console.log("RESULT: TokenSeller ActivatedEvent");
174 | var tokenSellerActivatedEvent = tokenTrader.ActivatedEvent({}, { fromBlock: 0, toBlock: "latest" });
175 | var i = 0;
176 | tokenSellerActivatedEvent.watch(function (error, result) {
177 | console.log("RESULT: tokenSellerActivatedEvent " + i++ + ": " + JSON.stringify(result));
178 | });
179 | tokenSellerActivatedEvent.stopWatching();
180 |
181 | console.log("RESULT: TokenSeller MakerWithdrewAsset");
182 | var tokenSellerMakerWithdrewAsset = tokenTrader.MakerWithdrewAsset({}, { fromBlock: 0, toBlock: "latest" });
183 | var i = 0;
184 | tokenSellerMakerWithdrewAsset.watch(function (error, result) {
185 | console.log("RESULT: tokenSellerMakerWithdrewAsset " + i++ + ": " + JSON.stringify(result));
186 | });
187 | tokenSellerMakerWithdrewAsset.stopWatching();
188 |
189 | console.log("RESULT: TokenSeller MakerWithdrewEther");
190 | var tokenSellerMakerWithdrewEther = tokenTrader.MakerWithdrewEther({}, { fromBlock: 0, toBlock: "latest" });
191 | var i = 0;
192 | tokenSellerMakerWithdrewEther.watch(function (error, result) {
193 | console.log("RESULT: tokenSellerMakerWithdrewEther " + i++ + ": " + JSON.stringify(result));
194 | });
195 | tokenSellerMakerWithdrewEther.stopWatching();
196 |
197 | console.log("RESULT: TokenSeller TakerBoughtAsset");
198 | var tokenSellerTakerBoughtAsset = tokenTrader.TakerBoughtAsset({}, { fromBlock: 0, toBlock: "latest" });
199 | var i = 0;
200 | tokenSellerTakerBoughtAsset.watch(function (error, result) {
201 | console.log("RESULT: tokenSellerTakerBoughtAsset " + i++ + ": " + JSON.stringify(result));
202 | });
203 | tokenSellerMakerWithdrewEther.stopWatching();
204 |
205 | exit;
206 |
207 | EOF
208 |
209 | grep "RESULT: " $TEMPOUTFILE | sed "s/RESULT: //" > $EVENTRESULTFILE
210 | cat $EVENTRESULTFILE
211 |
--------------------------------------------------------------------------------
/testing/test_20170125_0829/GNTTokenTraderFactory.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.4.0;
2 |
3 | //https://github.com/nexusdev/erc20/blob/master/contracts/erc20.sol
4 |
5 | contract ERC20Constant {
6 | function balanceOf( address who ) constant returns (uint value);
7 | }
8 | contract ERC20Stateful {
9 | function transfer( address to, uint value) returns (bool ok);
10 | }
11 | contract ERC20Events {
12 | event Transfer(address indexed from, address indexed to, uint value);
13 | }
14 | contract ERC20 is ERC20Constant, ERC20Stateful, ERC20Events {}
15 |
16 | contract owned {
17 | address public owner;
18 |
19 | function owned() {
20 | owner = msg.sender;
21 | }
22 |
23 | modifier onlyOwner {
24 | if (msg.sender != owner) throw;
25 | _;
26 | }
27 |
28 | function transferOwnership(address newOwner) onlyOwner {
29 | owner = newOwner;
30 | }
31 | }
32 |
33 | // contract can sell tokens for ETH
34 | // prices are in amount of wei per batch of token units
35 |
36 | contract TokenTrader is owned {
37 |
38 | address public asset; // address of token
39 | uint256 public sellPrice; // contract sells lots of tokens at this price
40 | uint256 public units; // lot size (token-wei)
41 |
42 | bool public sellsTokens; // is contract selling
43 |
44 | event ActivatedEvent(bool sells);
45 | event UpdateEvent();
46 |
47 | function TokenTrader (
48 | address _asset,
49 | uint256 _sellPrice,
50 | uint256 _units,
51 | bool _sellsTokens
52 | )
53 | {
54 | asset = _asset;
55 | sellPrice = _sellPrice;
56 | units = _units;
57 | sellsTokens = _sellsTokens;
58 |
59 | ActivatedEvent(sellsTokens);
60 | }
61 |
62 | // modify trading behavior
63 | function activate (
64 | bool _sellsTokens
65 | ) onlyOwner
66 | {
67 | sellsTokens = _sellsTokens;
68 |
69 | ActivatedEvent(sellsTokens);
70 | }
71 |
72 | // allow owner to remove trade token
73 | function withdrawAsset(uint256 _value) onlyOwner returns (bool ok)
74 | {
75 | return ERC20(asset).transfer(owner,_value);
76 | UpdateEvent();
77 | }
78 |
79 | // allow owner to remove arbitrary tokens
80 | // included just in case contract receives wrong token
81 | function withdrawToken(address _token, uint256 _value) onlyOwner returns (bool ok)
82 | {
83 | return ERC20(_token).transfer(owner,_value);
84 | UpdateEvent();
85 | }
86 |
87 | // allow owner to remove ETH
88 | function withdraw(uint256 _value) onlyOwner returns (bool ok)
89 | {
90 | if(this.balance >= _value) {
91 | return owner.send(_value);
92 | }
93 | UpdateEvent();
94 | }
95 |
96 | //user buys token with ETH
97 | function buy() payable {
98 | if(sellsTokens || msg.sender == owner)
99 | {
100 | uint order = msg.value / sellPrice;
101 | uint can_sell = ERC20(asset).balanceOf(address(this)) / units;
102 |
103 | if(order > can_sell)
104 | {
105 | uint256 change = msg.value - (can_sell * sellPrice);
106 | order = can_sell;
107 | if(!msg.sender.send(change)) throw;
108 | }
109 |
110 | if(order > 0) {
111 | if(!ERC20(asset).transfer(msg.sender,order * units)) throw;
112 | }
113 | UpdateEvent();
114 | }
115 | else if(!msg.sender.send(msg.value)) throw; // return user funds if the contract is not selling
116 | }
117 |
118 | // sending ETH to contract sells GNT to user
119 | function () payable {
120 | buy();
121 | }
122 | }
123 |
124 | // This contract deploys TokenTrader contracts and logs the event
125 | // trade pairs are identified with sha3(asset,units)
126 |
127 | contract TokenTraderFactory {
128 |
129 | event TradeListing(bytes32 bookid, address owner, address addr);
130 | event NewBook(bytes32 bookid, address asset, uint256 units);
131 |
132 | mapping( address => bool ) _verify;
133 | mapping( bytes32 => bool ) pairExits;
134 |
135 | function verify(address tradeContract) constant returns (
136 | bool valid,
137 | address asset,
138 | uint256 sellPrice,
139 | uint256 units,
140 | bool sellsTokens
141 | ) {
142 |
143 | valid = _verify[tradeContract];
144 |
145 | if(valid) {
146 | TokenTrader t = TokenTrader(tradeContract);
147 |
148 | asset = t.asset();
149 | sellPrice = t.sellPrice();
150 | units = t.units();
151 | sellsTokens = t.sellsTokens();
152 | }
153 |
154 | }
155 |
156 | function createTradeContract(
157 | address _asset,
158 | uint256 _sellPrice,
159 | uint256 _units,
160 | bool _sellsTokens
161 | ) returns (address)
162 | {
163 | if(_units == 0) throw; // can't sell zero units
164 |
165 | address trader = new TokenTrader (
166 | _asset,
167 | _sellPrice,
168 | _units,
169 | _sellsTokens);
170 |
171 | var bookid = sha3(_asset,_units);
172 |
173 | _verify[trader] = true; // record that this factory created the trader
174 |
175 | TokenTrader(trader).transferOwnership(msg.sender); // set the owner to whoever called the function
176 |
177 | if(pairExits[bookid] == false) {
178 | pairExits[bookid] = true;
179 | NewBook(bookid, _asset, _units);
180 | }
181 |
182 | TradeListing(bookid,msg.sender,trader);
183 | }
184 |
185 | function () {
186 | throw; // Prevents accidental sending of ether to the factory
187 | }
188 | }
--------------------------------------------------------------------------------
/testing/test_20170125_0829/README.md:
--------------------------------------------------------------------------------
1 | The testing results are described in [Testing Results ‐ Jan 25 2017 08:29](https://github.com/bokkypoobah/TokenTrader/wiki/Testing-Results-%E2%80%90-Jan-25-2017-08:29).
2 |
--------------------------------------------------------------------------------
/testing/test_20170125_0829/TestERC20Token.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.4.2;
2 |
3 | // ----------------------------------------------------------------------------------------------
4 | // Basic ERC20 Token Contract For **TESTING ONLY** on Testnet or Dev blockchain.
5 | //
6 | // Enjoy. (c) Bok Consulting Pty Ltd 2016. The MIT Licence.
7 | // ----------------------------------------------------------------------------------------------
8 |
9 | // ERC Token Standard #20 Interface
10 | // https://github.com/ethereum/EIPs/issues/20
11 | contract ERC20Interface {
12 |
13 | // Get the total token supply
14 | function totalSupply() constant returns (uint256 totalSupply);
15 |
16 | // Get the account balance of another account with address _owner
17 | function balanceOf(address _owner) constant returns (uint256 balance);
18 |
19 | // Send _value amount of tokens to address _to
20 | function transfer(address _to, uint256 _value) returns (bool success);
21 |
22 | // Send _value amount of tokens from address _from to address _to
23 | // The transferFrom method is used for a withdraw workflow, allowing contracts to send
24 | // tokens on your behalf, for example to "deposit" to a contract address and/or to charge
25 | // fees in sub-currencies; the command should fail unless the _from account has
26 | // deliberately authorized the sender of the message via some mechanism; we propose
27 | // these standardized APIs for approval:
28 | function transferFrom(address _from, address _to, uint256 _value) returns (bool success);
29 |
30 | // Allow _spender to withdraw from your account, multiple times, up to the _value amount.
31 | // If this function is called again it overwrites the current allowance with _value.
32 | function approve(address _spender, uint256 _value) returns (bool success);
33 |
34 | // Returns the amount which _spender is still allowed to withdraw from _owner
35 | function allowance(address _owner, address _spender) constant returns (uint256 remaining);
36 |
37 | // Triggered when tokens are transferred.
38 | event Transfer(address indexed _from, address indexed _to, uint256 _value);
39 |
40 | // Triggered whenever approve(address _spender, uint256 _value) is called.
41 | event Approval(address indexed _owner, address indexed _spender, uint256 _value);
42 | }
43 |
44 | contract TestERC20Token is ERC20Interface {
45 |
46 | string public name;
47 | string public symbol;
48 | uint8 public decimals;
49 |
50 | // Owner of this contract
51 | address public owner;
52 |
53 | // Balances for each account
54 | mapping(address => uint256) balances;
55 |
56 | // Owner of account approves the transfer of an amount to another account
57 | mapping(address => mapping (address => uint256)) allowed;
58 |
59 | // Total supply
60 | uint256 _totalSupply;
61 |
62 | // Functions with this modifier can only be executed by the owner
63 | modifier onlyOwner() {
64 | if (msg.sender != owner) {
65 | throw;
66 | }
67 | _;
68 | }
69 |
70 | // Constructor
71 | function TestERC20Token(string _name, string _symbol, uint8 _decimals) {
72 | name = _name;
73 | symbol = _symbol;
74 | decimals = _decimals;
75 | owner = msg.sender;
76 | }
77 |
78 | function totalSupply() constant returns (uint256 totalSupply) {
79 | totalSupply = _totalSupply;
80 | }
81 |
82 | // What is the balance of a particular account?
83 | function balanceOf(address _owner) constant returns (uint256 balance) {
84 | return balances[_owner];
85 | }
86 |
87 | // Transfer the balance from owner's account to another account
88 | function transfer(address _to, uint256 _amount) returns (bool success) {
89 | if (balances[msg.sender] >= _amount && _amount > 0) {
90 | balances[msg.sender] -= _amount;
91 | balances[_to] += _amount;
92 | Transfer(msg.sender, _to, _amount);
93 | return true;
94 | } else {
95 | return false;
96 | }
97 | }
98 |
99 | // Send _value amount of tokens from address _from to address _to
100 | // The transferFrom method is used for a withdraw workflow, allowing contracts to send
101 | // tokens on your behalf, for example to "deposit" to a contract address and/or to charge
102 | // fees in sub-currencies; the command should fail unless the _from account has
103 | // deliberately authorized the sender of the message via some mechanism; we propose
104 | // these standardized APIs for approval:
105 | function transferFrom(
106 | address _from,
107 | address _to,
108 | uint256 _amount
109 | ) returns (bool success) {
110 |
111 | if (balances[_from] >= _amount
112 | && allowed[_from][msg.sender] >= _amount
113 | && _amount > 0) {
114 |
115 | balances[_to] += _amount;
116 | balances[_from] -= _amount;
117 | allowed[_from][msg.sender] -= _amount;
118 | Transfer(_from, _to, _amount);
119 | return true;
120 | } else {
121 | return false;
122 | }
123 | }
124 |
125 | // Allow _spender to withdraw from your account, multiple times, up to the _value amount.
126 | // If this function is called again it overwrites the current allowance with _value.
127 | function approve(address _spender, uint256 _amount) returns (bool success) {
128 | allowed[msg.sender][_spender] = _amount;
129 | Approval(msg.sender, _spender, _amount);
130 | return true;
131 | }
132 |
133 | function allowance(address _owner, address _spender) constant returns (uint256 remaining) {
134 | return allowed[_owner][_spender];
135 | }
136 |
137 | function () payable {
138 | if (msg.value > 0) {
139 | _totalSupply += msg.value;
140 | balances[msg.sender] += msg.value;
141 | }
142 | }
143 |
144 | function withdrawEthers(uint256 ethers) onlyOwner returns (bool ok) {
145 | if (this.balance >= ethers) {
146 | return owner.send(ethers);
147 | }
148 | }
149 |
150 | // Triggered when fiat currency is converted to tokens
151 | event TokensCreated(address indexed _owner, uint256 _amount);
152 | }
153 |
--------------------------------------------------------------------------------
/testing/test_20170125_0829/factoryResults.txt:
--------------------------------------------------------------------------------
1 | traderFactoryAddress=0x03d47b0d78f8dee3089037dffd5c9a1f7e7282af gas=3000000 gasUsed=1500184 cost=0.03000368 block=22 txId=0xea06f7e132c918a6d14ac8bdea288f9757454ccc1e2f5fa69c62025b5050823e
2 | sellerFactoryAddress=0xcc643e6c5639d64ca3c0c484a6c0f23d11b87477 gas=3000000 gasUsed=1101676 cost=0.02203352 block=22 txId=0x56125f594e05e9785b6b164b9885a3af3ca493e18306fab0aa9b78586d638819
3 | gntTraderFactoryAddress=0xbd7780c8773a6c99163ea9c1fa870450bc216aa6 gas=3000000 gasUsed=781907 cost=0.01563814 block=22 txId=0x44429c2525301f1a7fe8898178f33f36d3a2dfb7d19a5981806e3d4f603c9783
4 | createTradeContractTxId gas=1000000 gasUsed=884075 cost=0.0176815 block=25 txId=0x80063789b223a5fc547685f5f7d60725d2e49e2e860321f2bf5f69e8bc63465d
5 | createSaleContractTxId gas=1000000 gasUsed=622173 cost=0.01244346 block=25 txId=0x61618e1462eca8536bdbccaba342aa8704784a17708aa9a8328b6767a8164110
6 | createGNTTradeContractTxId gas=1000000 gasUsed=503624 cost=0.01007248 block=25 txId=0x8bb17904d53cc59ecc61a452c264c71b29bb77b61acc438362569f1180d239eb
7 | traderVerifyResults [true,"0x0014060ff383c9b21c6840a3b14aab06741e5c49","0xebb2634dd3194ba6d75eeb049cd0f73bf9801d95","110000","120000","100000",true,true]
8 | sellerVerifyResults [true,"0x0014060ff383c9b21c6840a3b14aab06741e5c49","0xebb2634dd3194ba6d75eeb049cd0f73bf9801d95","120000","100000",true]
9 | gntTraderVerifyResults [true,"0xebb2634dd3194ba6d75eeb049cd0f73bf9801d95","130000","100000",true]
10 | # Account EtherBalance TokenABalance TokenBBalance TokenCBalance Name
11 | 0 0x000d1009bd8f0b1301cc5edc28ed1222a3ce671e 97130.145579840000000000 1000.000000000000000000 1000.000000000000000000 1000.000000000000000000 Account #0
12 | 1 0x0014060ff383c9b21c6840a3b14aab06741e5c49 96999.857199240000000000 1000.000000000000000000 1000.000000000000000000 1000.000000000000000000 Account #1
13 | 2 0x0020017ba4c67f76c76b1af8c41821ee54f37171 96999.997220920000000000 1000.000000000000000000 1000.000000000000000000 1000.000000000000000000 Account #2
14 | 3 0xebb2634dd3194ba6d75eeb049cd0f73bf9801d95 3000.000000000000000000 0.000000000000000000 0.000000000000000000 0.000000000000000000 ERC20A
15 | 4 0xe9ba90b474ef72aa062d89a319c3e15b31e8fe65 3000.000000000000000000 0.000000000000000000 0.000000000000000000 0.000000000000000000 ERC20B
16 | 5 0x30da52ef30bdaec61b43317cc045e4f267eaf779 3000.000000000000000000 0.000000000000000000 0.000000000000000000 0.000000000000000000 ERC20C
17 | 6 0x03d47b0d78f8dee3089037dffd5c9a1f7e7282af 0.000000000000000000 0.000000000000000000 0.000000000000000000 0.000000000000000000 TokenTraderFactory
18 | 7 0xcc643e6c5639d64ca3c0c484a6c0f23d11b87477 0.000000000000000000 0.000000000000000000 0.000000000000000000 0.000000000000000000 TokenSellerFactory
19 | 8 0xbd7780c8773a6c99163ea9c1fa870450bc216aa6 0.000000000000000000 0.000000000000000000 0.000000000000000000 0.000000000000000000 GNTTokenTraderFactory
20 | 9 0xfb6ae08258f553335fd33b71081228e53794f8eb 0.000000000000000000 0.000000000000000000 0.000000000000000000 0.000000000000000000 TokenTrader
21 | 10 0x85e7378cb6a2ecbcaf5c178775764615f5046a9d 0.000000000000000000 0.000000000000000000 0.000000000000000000 0.000000000000000000 TokenSeller
22 | 11 0x7afc189b25beba65c5a2dec4804ea77b40f8c9a5 0.000000000000000000 0.000000000000000000 0.000000000000000000 0.000000000000000000 GNTTokenTrader
23 | Depositing 100 ETH to tokenTrader 0xfb6ae08258f553335fd33b71081228e53794f8eb
24 | Transferring 100 tokenAs to tokenTrader 0xfb6ae08258f553335fd33b71081228e53794f8eb
25 | Transferring 100 tokenAs to tokenSeller 0x85e7378cb6a2ecbcaf5c178775764615f5046a9d
26 | Transferring 100 tokenAs to gntTokenTrader 0x7afc189b25beba65c5a2dec4804ea77b40f8c9a5
27 | traderDepositEtherTxId gas=100000 gasUsed=22735 cost=0.0004547 block=30 txId=0xd6c461ad3a8566754e2d6c22a1bb48f2d4dff2853a589323bc147d3ed024bdff
28 | traderTransferTokenTxId gas=100000 gasUsed=50987 cost=0.00101974 block=30 txId=0x797baead2890d9a51303569e615467b83b2d97a66eb95a653a97a7a9e9750628
29 | sellerTransferTokenTxId gas=100000 gasUsed=50987 cost=0.00101974 block=30 txId=0x0d503132987efd9d85591b2a8e19603c7ccf1f18264ca8b875c1cfc63efb40c5
30 | gntTraderTransferTokenTxId gas=100000 gasUsed=50987 cost=0.00101974 block=30 txId=0x285e6fdb9508729f0ab10910779e20726b78d8953ab486c93ade4eaf2550d538
31 | OK 0xebb2634dd3194ba6d75eeb049cd0f73bf9801d95 has expected balance 3000
32 | Expecting 100 TokenABalance and 100 ETH in tokenTrader 0xfb6ae08258f553335fd33b71081228e53794f8eb
33 | Expecting 100 TokenABalance in tokenSeller 0x85e7378cb6a2ecbcaf5c178775764615f5046a9d
34 | Expecting 100 TokenABalance in gntTokenTrader 0x7afc189b25beba65c5a2dec4804ea77b40f8c9a5
35 | # Account EtherBalance TokenABalance TokenBBalance TokenCBalance Name
36 | 0 0x000d1009bd8f0b1301cc5edc28ed1222a3ce671e 97150.149093760000000000 1000.000000000000000000 1000.000000000000000000 1000.000000000000000000 Account #0
37 | 1 0x0014060ff383c9b21c6840a3b14aab06741e5c49 96899.853685320000000000 700.000000000000000000 1000.000000000000000000 1000.000000000000000000 Account #1
38 | 2 0x0020017ba4c67f76c76b1af8c41821ee54f37171 96999.997220920000000000 1000.000000000000000000 1000.000000000000000000 1000.000000000000000000 Account #2
39 | 3 0xebb2634dd3194ba6d75eeb049cd0f73bf9801d95 3000.000000000000000000 0.000000000000000000 0.000000000000000000 0.000000000000000000 ERC20A
40 | 4 0xe9ba90b474ef72aa062d89a319c3e15b31e8fe65 3000.000000000000000000 0.000000000000000000 0.000000000000000000 0.000000000000000000 ERC20B
41 | 5 0x30da52ef30bdaec61b43317cc045e4f267eaf779 3000.000000000000000000 0.000000000000000000 0.000000000000000000 0.000000000000000000 ERC20C
42 | 6 0x03d47b0d78f8dee3089037dffd5c9a1f7e7282af 0.000000000000000000 0.000000000000000000 0.000000000000000000 0.000000000000000000 TokenTraderFactory
43 | 7 0xcc643e6c5639d64ca3c0c484a6c0f23d11b87477 0.000000000000000000 0.000000000000000000 0.000000000000000000 0.000000000000000000 TokenSellerFactory
44 | 8 0xbd7780c8773a6c99163ea9c1fa870450bc216aa6 0.000000000000000000 0.000000000000000000 0.000000000000000000 0.000000000000000000 GNTTokenTraderFactory
45 | 9 0xfb6ae08258f553335fd33b71081228e53794f8eb 100.000000000000000000 100.000000000000000000 0.000000000000000000 0.000000000000000000 TokenTrader
46 | 10 0x85e7378cb6a2ecbcaf5c178775764615f5046a9d 0.000000000000000000 100.000000000000000000 0.000000000000000000 0.000000000000000000 TokenSeller
47 | 11 0x7afc189b25beba65c5a2dec4804ea77b40f8c9a5 0.000000000000000000 100.000000000000000000 0.000000000000000000 0.000000000000000000 GNTTokenTrader
48 | OK 0x03d47b0d78f8dee3089037dffd5c9a1f7e7282af has expected balance 0
49 | OK 0x03d47b0d78f8dee3089037dffd5c9a1f7e7282af has expected ERC20A token balance 0
50 | OK 0xcc643e6c5639d64ca3c0c484a6c0f23d11b87477 has expected balance 0
51 | OK 0xcc643e6c5639d64ca3c0c484a6c0f23d11b87477 has expected ERC20A token balance 0
52 | OK 0xbd7780c8773a6c99163ea9c1fa870450bc216aa6 has expected balance 0
53 | OK 0xbd7780c8773a6c99163ea9c1fa870450bc216aa6 has expected ERC20A token balance 0
54 | OK 0xfb6ae08258f553335fd33b71081228e53794f8eb has expected balance 100
55 | OK 0xfb6ae08258f553335fd33b71081228e53794f8eb has expected ERC20A token balance 100
56 | OK 0x85e7378cb6a2ecbcaf5c178775764615f5046a9d has expected balance 0
57 | OK 0x85e7378cb6a2ecbcaf5c178775764615f5046a9d has expected ERC20A token balance 100
58 | OK 0x7afc189b25beba65c5a2dec4804ea77b40f8c9a5 has expected balance 0
59 | OK 0x7afc189b25beba65c5a2dec4804ea77b40f8c9a5 has expected ERC20A token balance 100
60 |
--------------------------------------------------------------------------------
/testing/test_20170125_0829/genesis.json:
--------------------------------------------------------------------------------
1 | {
2 | "config": {
3 | "homesteadBlock": 1
4 | },
5 | "nonce": "0",
6 | "difficulty": "0x400",
7 | "mixhash": "0x00000000000000000000000000000000000000647572616c65787365646c6578",
8 | "coinbase": "0x0000000000000000000000000000000000000000",
9 | "timestamp": "0x00",
10 | "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
11 | "extraData": "0x",
12 | "gasLimit": "0x3B4A1B44",
13 | "alloc": {
14 | "0x000d1009bd8f0b1301cc5edc28ed1222a3ce671e": {
15 | "balance": "100000000000000000000000"
16 | },
17 | "0x0014060ff383c9b21c6840a3b14aab06741e5c49": {
18 | "balance": "100000000000000000000000"
19 | },
20 | "0x0020017ba4c67f76c76b1af8c41821ee54f37171": {
21 | "balance": "100000000000000000000000"
22 | },
23 | "0x0036f6addb6d64684390f55a92f0f4988266901b": {
24 | "balance": "100000000000000000000000"
25 | },
26 | "0x004e64833635cd1056b948b57286b7c91e62731c": {
27 | "balance": "100000000000000000000000"
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/testing/test_20170125_0829/settings.txt:
--------------------------------------------------------------------------------
1 | IxPCFILE=ipc://Users/bok/ESE/gethgenesis/geth.ipc
2 |
3 | IPCFILE=ipc:./testchain/geth.ipc
4 | PASSWORD=testtest
5 |
6 | TYPE=Trader
7 | INITIALETH=1000
8 |
9 | TOKENSOL=TestERC20Token.sol
10 | TOKENTRADERFACTORYSOL=TokenTraderFactory.sol
11 | TOKENSELLERFACTORYSOL=TokenSellerFactory.sol
12 | GNTTOKENTRADERFACTORYSOL=GNTTokenTraderFactory.sol
13 |
14 | TEMPINFILE=zzinput.tmp
15 | TEMPOUTFILE=zzoutput.tmp
16 |
17 | TOKENOUTPUTFILE=tokenOutput.txt
18 | TOKENDATAFILE=tokenData.txt
19 | TOKENRESULTFILE=tokenResults.txt
20 |
21 | FACTORYOUTPUTFILE=factoryOutput.txt
22 | FACTORYDATAFILE=factoryData.txt
23 | FACTORYRESULTFILE=factoryResults.txt
24 |
25 | EXECUTIONOUTPUTFILE=executionOutput.txt
26 | EXECUTIONRESULTFILE=executionResults.txt
27 |
28 | OTHEROUTPUTFILE=otherOutput.txt
29 | OTHERRESULTFILE=otherResults.txt
30 |
31 | EVENTRESULTFILE=eventResults.txt
32 |
--------------------------------------------------------------------------------
/testing/test_20170125_0829/stripCrLf:
--------------------------------------------------------------------------------
1 | #!/usr/bin/perl
2 | while (<>) {
3 | chomp; # Remove newline
4 | s#/\*.*?\*/##sg; # Remove multiline comments
5 | s/\/\/.*$//go; # Remove // comments
6 | s/\s+/ /go; # Collapse space
7 | print;
8 | }
9 | print "\n";
10 |
--------------------------------------------------------------------------------
/testing/test_20170125_0829/testchain/keystore/UTC--2016-12-16T01-36-05.134620242Z--000d1009bd8f0b1301cc5edc28ed1222a3ce671e:
--------------------------------------------------------------------------------
1 | {"address":"000d1009bd8f0b1301cc5edc28ed1222a3ce671e","crypto":{"cipher":"aes-128-ctr","ciphertext":"d59bbf7979a49434bb5b9fd62deee6bade6d3863d51007ac5a68075493dc025c","cipherparams":{"iv":"4ea160bd84819089c721da4721094f1c"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":262144,"p":1,"r":8,"salt":"f3916dcd671250a149a2fa5dd1b9049e6f66f856460c0d156f6ca8d8804d1337"},"mac":"74e459f91acf536cd90182031043a1832f2c52d1e914b5c6fa9068e599a71b7c"},"id":"59f697eb-7fd7-4c97-bb7f-642f0efc875d","version":3}
--------------------------------------------------------------------------------
/testing/test_20170125_0829/testchain/keystore/UTC--2016-12-16T01-36-45.681050789Z--0014060ff383c9b21c6840a3b14aab06741e5c49:
--------------------------------------------------------------------------------
1 | {"address":"0014060ff383c9b21c6840a3b14aab06741e5c49","crypto":{"cipher":"aes-128-ctr","ciphertext":"05d4f6408ff59ef400fd251fdac2c05e634d6fb56abb2aafbb34c1960f4da43e","cipherparams":{"iv":"bdd2aa67855754664ca87b7d8f355730"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":262144,"p":1,"r":8,"salt":"13a9ee72e426c421fef154b1ae468d79e2cef70c7c04c44a7de5ff85211dcf9a"},"mac":"dde360e4b44ef71e71172edcf9869d481a099fa655e6f5ca481b5d30887e21f7"},"id":"163e5bfa-c75d-426b-95f9-68715ae38ed4","version":3}
--------------------------------------------------------------------------------
/testing/test_20170125_0829/testchain/keystore/UTC--2016-12-16T01-37-12.717455318Z--0020017ba4c67f76c76b1af8c41821ee54f37171:
--------------------------------------------------------------------------------
1 | {"address":"0020017ba4c67f76c76b1af8c41821ee54f37171","crypto":{"cipher":"aes-128-ctr","ciphertext":"56598c7aef98104a2e29731ea2e5962e74b09bf7b3dd4d5d97c78292977752df","cipherparams":{"iv":"0d696d5d1e2680d7a04f0be8062f4ed3"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":262144,"p":1,"r":8,"salt":"3b601ed2bdf111bdc11dee3f5a9b85ca5b566f521fd4444596c197ed35e87e1a"},"mac":"90664c391a208a2779c931a98ac7c27424d81ec6ede00bc132ae6ba566ad2a96"},"id":"78fe49c7-fd71-4c64-b78d-bf461cb3e71c","version":3}
--------------------------------------------------------------------------------
/testing/test_20170125_0829/testchain/keystore/UTC--2016-12-16T01-37-37.923741925Z--0036f6addb6d64684390f55a92f0f4988266901b:
--------------------------------------------------------------------------------
1 | {"address":"0036f6addb6d64684390f55a92f0f4988266901b","crypto":{"cipher":"aes-128-ctr","ciphertext":"f8d7c3bb1d2142dd3d45426a39c32ce21668647c4cbaa86b0b8021378c825fb5","cipherparams":{"iv":"e94709dc5f877f678e444a16bfd0dcad"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":262144,"p":1,"r":8,"salt":"1fbba771a9e7a34184fcbb03a8b30e1f0c6a6034a46f090a78242ed590ebc1af"},"mac":"977971908c8061c81756fd378337bc11f786146783a5a7089b6a5efa16822ed0"},"id":"ebc305b9-3e9f-4d6b-82a4-4d6c59a6807f","version":3}
--------------------------------------------------------------------------------
/testing/test_20170125_0829/testpassword:
--------------------------------------------------------------------------------
1 | testtest
2 |
--------------------------------------------------------------------------------
/testing/test_20170125_0829/tokenData.txt:
--------------------------------------------------------------------------------
1 | tokenABI=[{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_amount","type":"uint256"}],"name":"approve","outputs":[{"name":"success","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"totalSupply","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_amount","type":"uint256"}],"name":"transferFrom","outputs":[{"name":"success","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"name":"","type":"uint8"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"}],"name":"balanceOf","outputs":[{"name":"balance","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"","type":"string"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_amount","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"},{"constant":false,"inputs":[{"name":"ethers","type":"uint256"}],"name":"withdrawEthers","outputs":[{"name":"ok","type":"bool"}],"payable":false,"type":"function"},{"inputs":[{"name":"_name","type":"string"},{"name":"_symbol","type":"string"},{"name":"_decimals","type":"uint8"}],"type":"constructor"},{"payable":true,"type":"fallback"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_owner","type":"address"},{"indexed":false,"name":"_amount","type":"uint256"}],"name":"TokensCreated","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"}]
2 | tokenAddressA=0xebb2634dd3194ba6d75eeb049cd0f73bf9801d95
3 | tokenAddressB=0xe9ba90b474ef72aa062d89a319c3e15b31e8fe65
4 | tokenAddressC=0x30da52ef30bdaec61b43317cc045e4f267eaf779
5 |
--------------------------------------------------------------------------------
/testing/test_20170125_0829/tokenResults.txt:
--------------------------------------------------------------------------------
1 | Creating ERC20 Token @ Wed, 25 Jan 2017 08:24:40 AEDT
2 | tokenAddressA=0xebb2634dd3194ba6d75eeb049cd0f73bf9801d95 gas=800000 gasUsed=535815 cost=0.0107163 block=11 txId=0xfe457acff1388bbf5b2d2c3d1ede52306e81deeecfeb72e8441f7d5896b55686
3 | tokenAddressB=0xe9ba90b474ef72aa062d89a319c3e15b31e8fe65 gas=600000 gasUsed=535815 cost=0.0107163 block=13 txId=0x57b6ddbd252b0ed5d56ebb0846bac0fa6d96bcf5deb56f5c6452c240d56902b7
4 | tokenAddressC=0x30da52ef30bdaec61b43317cc045e4f267eaf779 gas=600000 gasUsed=535815 cost=0.0107163 block=15 txId=0x36a75b106f624a3d241f1945768918da17e526486559bf6220dfff84fa320143
5 | Sent 1000 ETH from accounts[0] to tokenA 0xebb2634d gas=100000 gasUsed=61318 cost=0.00122636 block=17 txId=0xed9aabfcab12a1f77e4cd62f3f51677b2bbbb9f07ed1449351b09c914cfab90c
6 | Sent 1000 ETH from accounts[1] to tokenA 0xebb2634d gas=100000 gasUsed=46318 cost=0.00092636 block=17 txId=0x4f9bd18032b8a03a848ee4f8dc629fa1e759d98dbbe733c35a99971eff6881d1
7 | Sent 1000 ETH from accounts[2] to tokenA 0xebb2634d gas=100000 gasUsed=46318 cost=0.00092636 block=17 txId=0x1c68b17b3cab97589f3acb79eba4d81087828db9f550883ba56816508f66b93c
8 | Sent 1000 ETH from accounts[0] to tokenB 0xe9ba90b4 gas=100000 gasUsed=61318 cost=0.00122636 block=17 txId=0x6adce7f54415e895e038bbb726b3c8ece93dd44b5e639221ad69c85f30560273
9 | Sent 1000 ETH from accounts[1] to tokenB 0xe9ba90b4 gas=100000 gasUsed=46318 cost=0.00092636 block=17 txId=0xe22cbd15ba5b84d1b37275fbcd0e47f4236ad7550426f7a594bafdbf14650cd4
10 | Sent 1000 ETH from accounts[2] to tokenB 0xe9ba90b4 gas=100000 gasUsed=46318 cost=0.00092636 block=17 txId=0xead8ade46a2e3c4d835b3e3fa255ff5230eed2657a8eb1ed35fecc9780a120da
11 | Sent 1000 ETH from accounts[0] to tokenC 0x30da52ef gas=100000 gasUsed=61318 cost=0.00122636 block=17 txId=0xeb55f19e44a3863d1ee796f6377b00a829d076192437cb9e85becfbf1d173f7f
12 | Sent 1000 ETH from accounts[1] to tokenC 0x30da52ef gas=100000 gasUsed=46318 cost=0.00092636 block=17 txId=0x7042aa9dee146a6d96db870b50bb20c1fdfdc071dde3b3a456eb5686942b8369
13 | Sent 1000 ETH from accounts[2] to tokenC 0x30da52ef gas=100000 gasUsed=46318 cost=0.00092636 block=17 txId=0xebf1e694548ef45a3ae388fab06e6614d97d96ab614c9e3b3f7f57e634190170
14 | # Account EtherBalance TokenABalance TokenBBalance TokenCBalance Name
15 | 1 0x000d1009bd8f0b1301cc5edc28ed1222a3ce671e 97085.037707060000000000 1000.000000000000000000 1000.000000000000000000 1000.000000000000000000 Account #0
16 | 2 0x0014060ff383c9b21c6840a3b14aab06741e5c49 96999.965072020000000000 1000.000000000000000000 1000.000000000000000000 1000.000000000000000000 Account #1
17 | 3 0x0020017ba4c67f76c76b1af8c41821ee54f37171 96999.997220920000000000 1000.000000000000000000 1000.000000000000000000 1000.000000000000000000 Account #2
18 | 4 0xebb2634dd3194ba6d75eeb049cd0f73bf9801d95 3000.000000000000000000 0.000000000000000000 0.000000000000000000 0.000000000000000000 ERC20A
19 | 5 0xe9ba90b474ef72aa062d89a319c3e15b31e8fe65 3000.000000000000000000 0.000000000000000000 0.000000000000000000 0.000000000000000000 ERC20B
20 | 6 0x30da52ef30bdaec61b43317cc045e4f267eaf779 3000.000000000000000000 0.000000000000000000 0.000000000000000000 0.000000000000000000 ERC20C
21 | OK 0xebb2634dd3194ba6d75eeb049cd0f73bf9801d95 has expected balance 3000
22 | OK 0xe9ba90b474ef72aa062d89a319c3e15b31e8fe65 has expected balance 3000
23 | OK 0x30da52ef30bdaec61b43317cc045e4f267eaf779 has expected balance 3000
24 | OK 0x000d1009bd8f0b1301cc5edc28ed1222a3ce671e has expected ERC20A token balance 1000
25 | OK 0x0014060ff383c9b21c6840a3b14aab06741e5c49 has expected ERC20A token balance 1000
26 | OK 0x0020017ba4c67f76c76b1af8c41821ee54f37171 has expected ERC20A token balance 1000
27 | OK 0x000d1009bd8f0b1301cc5edc28ed1222a3ce671e has expected ERC20B token balance 1000
28 | OK 0x0014060ff383c9b21c6840a3b14aab06741e5c49 has expected ERC20B token balance 1000
29 | OK 0x0020017ba4c67f76c76b1af8c41821ee54f37171 has expected ERC20B token balance 1000
30 | OK 0x000d1009bd8f0b1301cc5edc28ed1222a3ce671e has expected ERC20B token balance 1000
31 | OK 0x0014060ff383c9b21c6840a3b14aab06741e5c49 has expected ERC20B token balance 1000
32 | OK 0x0020017ba4c67f76c76b1af8c41821ee54f37171 has expected ERC20B token balance 1000
33 |
--------------------------------------------------------------------------------
/testing/test_20170205_1849/00_runGeth.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | rm -f ./testchain/geth/chaindata/*
4 |
5 | geth --datadir ./testchain init genesis.json
6 |
7 | geth --datadir ./testchain --unlock 0 --password ./testpassword --rpc --rpccorsdomain '*' --rpcport 8646 --rpcapi "eth,net,web3,debug" --port 32323 --mine --minerthreads 1 --maxpeers 0 console
8 |
9 |
--------------------------------------------------------------------------------
/testing/test_20170205_1849/01_deployERC20Token.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | # --------------------------------------------------------------------
3 | # Testing Contracts At https://github.com/bokkypoobah/TokenTrader
4 | #
5 | # Deploy ERC20 Token
6 | #
7 | # (c) BokkyPooBah 2017. The MIT licence.
8 | # --------------------------------------------------------------------
9 |
10 | GETHATTACHPOINT=`grep IPCFILE settings.txt | sed "s/^.*=//"`
11 | PASSWORD=`grep PASSWORD settings.txt | sed "s/^.*=//"`
12 |
13 | TYPE=`grep TYPE settings.txt | sed "s/^.*=//"`
14 | INITIALETH=`grep INITIALETH settings.txt | sed "s/^.*=//"`
15 |
16 | TEMPINFILE=`grep TEMPINFILE settings.txt | sed "s/^.*=//"`
17 | TOKENOUTPUTFILE=`grep TOKENOUTPUTFILE settings.txt | sed "s/^.*=//"`
18 |
19 | TOKENSOL=`grep TOKENSOL settings.txt | sed "s/^.*=//"`
20 | FLATTENEDSOL=`./stripCrLf $TOKENSOL`
21 | printf "var tokenSource = \"$FLATTENEDSOL\"" > $TEMPINFILE
22 |
23 | TOKENDATAFILE=`grep TOKENDATA settings.txt | sed "s/^.*=//"`
24 | TOKENRESULTFILE=`grep TOKENRESULTFILE settings.txt | sed "s/^.*=//"`
25 |
26 | printf "geth endpoint '$GETHATTACHPOINT'\n" | tee $TOKENOUTPUTFILE
27 |
28 | geth --verbosity 3 attach $GETHATTACHPOINT << EOF | tee -a $TOKENOUTPUTFILE
29 |
30 | var ACCOUNTS = 3;
31 |
32 | function pad(s) {
33 | var o = s.toFixed(18);
34 | while (o.length < 27) {
35 | o = " " + o;
36 | }
37 | return o;
38 | }
39 |
40 | var accounts = [eth.accounts[0], eth.accounts[1], eth.accounts[2]];
41 | var accountName = {};
42 | accountName[eth.accounts[0]] = "Account #0";
43 | accountName[eth.accounts[1]] = "Account #1";
44 | accountName[eth.accounts[2]] = "Account #2";
45 |
46 | function printBalances(accounts) {
47 | var i = 0;
48 | console.log("RESULT: # Account EtherBalance TokenABalance TokenBBalance TokenCBalance Name");
49 | accounts.forEach(function(e) {
50 | i++;
51 | var etherBalance = web3.fromWei(eth.getBalance(e), "ether");
52 | var tokenABalance = web3.fromWei(tokenA.balanceOf(e), "ether");
53 | var tokenBBalance = web3.fromWei(tokenB.balanceOf(e), "ether");
54 | var tokenCBalance = web3.fromWei(tokenC.balanceOf(e), "ether");
55 | console.log("RESULT: " + i + " " + e + " " + pad(etherBalance) + " " + pad(tokenABalance) + " " + pad(tokenBBalance) + " " +
56 | pad(tokenCBalance) + " " + accountName[e]);
57 | });
58 | }
59 |
60 | function printTxData(name, txId) {
61 | var tx = eth.getTransaction(txId);
62 | var txReceipt = eth.getTransactionReceipt(txId);
63 | console.log("RESULT: " + name + " gas=" + tx.gas + " gasUsed=" + txReceipt.gasUsed + " cost=" + tx.gasPrice.mul(txReceipt.gasUsed).div(1e18) +
64 | " block=" + txReceipt.blockNumber + " txId=" + txId);
65 | }
66 |
67 | function assertEtherBalance(account, testBalance) {
68 | var etherBalance = web3.fromWei(eth.getBalance(account), "ether");
69 | if (etherBalance == testBalance) {
70 | console.log("RESULT: OK " + account + " has expected balance " + testBalance);
71 | } else {
72 | console.log("RESULT: FAILURE " + account + " has balance " + etherBalance + " <> expected " + testBalance);
73 | }
74 | }
75 |
76 | function assertTokenBalance(account, token, testBalance) {
77 | var tokenBalance = token.balanceOf(account).div(1e18);
78 | if (tokenBalance == testBalance) {
79 | console.log("RESULT: OK " + account + " has expected " + accountName[token.address] + " token balance " + testBalance);
80 | } else {
81 | console.log("RESULT: FAILURE " + account + " has " + accountName[token.address] + " token balance " + tokenBalance + " <> expected " + testBalance);
82 | }
83 | }
84 |
85 | console.log("RESULT: Creating ERC20 Token @ " + new Date());
86 |
87 | for (var i = 0; i < ACCOUNTS; i++) {
88 | personal.unlockAccount(eth.accounts[i], "$PASSWORD", 100000);
89 | }
90 |
91 | loadScript("$TEMPINFILE");
92 |
93 | var tokenCompiled = web3.eth.compile.solidity(tokenSource);
94 | console.log("DATA: tokenABI=" + JSON.stringify(tokenCompiled[":TestERC20Token"].info.abiDefinition));
95 | var tokenContract = web3.eth.contract(tokenCompiled[":TestERC20Token"].info.abiDefinition);
96 |
97 | // TokenA
98 | var tokenAddressA = null;
99 | var tokenTxA = null;
100 | var tokenA = tokenContract.new("TokenA", "ERC20A", 16, {from: eth.accounts[1], data: tokenCompiled[":TestERC20Token"].code, gas: 800000},
101 | function(e, contract) {
102 | if (!e) {
103 | if (!contract.address) {
104 | tokenTxA = contract.transactionHash;
105 | console.log("tokenTxA=" + tokenTxA);
106 | } else {
107 | tokenAddressA = contract.address;
108 | accountName[tokenAddressA] = "ERC20A";
109 | console.log("DATA: tokenAddressA=" + tokenAddressA);
110 | printTxData("tokenAddressA=" + tokenAddressA, tokenTxA);
111 | }
112 | }
113 | }
114 | );
115 | while (txpool.status.pending > 0) {
116 | }
117 |
118 | // TokenB
119 | var tokenAddressB = null;
120 | var tokenTxB = null;
121 | var tokenB = tokenContract.new("TokenB", "ERC20B", 18, {from: eth.accounts[1], data: tokenCompiled[":TestERC20Token"].code, gas: 800000},
122 | function(e, contract) {
123 | if (!e) {
124 | if (!contract.address) {
125 | tokenTxB = contract.transactionHash;
126 | console.log("tokenTxB=" + tokenTxB);
127 | } else {
128 | tokenAddressB = contract.address;
129 | accountName[tokenAddressB] = "ERC20B";
130 | console.log("DATA: tokenAddressB=" + tokenAddressB);
131 | printTxData("tokenAddressB=" + tokenAddressB, tokenTxB);
132 | }
133 | }
134 | }
135 | );
136 | while (txpool.status.pending > 0) {
137 | }
138 |
139 | // TokenC
140 | var tokenAddressC = null;
141 | var tokenTxC = null;
142 | var tokenC = tokenContract.new("TokenC", "ERC20C", 18, {from: eth.accounts[1], data: tokenCompiled[":TestERC20Token"].code, gas: 800000},
143 | function(e, contract) {
144 | if (!e) {
145 | if (!contract.address) {
146 | tokenTxC = contract.transactionHash;
147 | console.log("tokenTxC=" + tokenTxC);
148 | } else {
149 | tokenAddressC = contract.address;
150 | accountName[tokenAddressC] = "ERC20C";
151 | console.log("DATA: tokenAddressC=" + tokenAddressC);
152 | printTxData("tokenAddressC=" + tokenAddressC, tokenTxC);
153 | }
154 | }
155 | }
156 | );
157 | while (txpool.status.pending > 0) {
158 | }
159 |
160 | var txIdsA = [];
161 | for (var i = 0; i < ACCOUNTS; i++) {
162 | console.log("Sending $INITIALETH ETH from eth.accounts[" + i + "] to tokenA " + tokenAddressA);
163 | txIdsA[i] = eth.sendTransaction({from: eth.accounts[i], to: tokenAddressA, value: web3.toWei("$INITIALETH", "ether"), gas: 100000});
164 | console.log("txIdsA[" + i + "]=" + txIdsA[i]);
165 | }
166 |
167 | var txIdsB = [];
168 | for (var i = 0; i < ACCOUNTS; i++) {
169 | console.log("Sending $INITIALETH ETH from eth.accounts[" + i + "] to tokenB " + tokenAddressB);
170 | txIdsB[i] = eth.sendTransaction({from: eth.accounts[i], to: tokenAddressB, value: web3.toWei("$INITIALETH", "ether"), gas: 100000});
171 | console.log("txIdsB[" + i + "]=" + txIdsB[i]);
172 | }
173 |
174 | var txIdsC = [];
175 | for (var i = 0; i < ACCOUNTS; i++) {
176 | console.log("Sending $INITIALETH ETH from eth.accounts[" + i + "] to tokenC " + tokenAddressC);
177 | txIdsC[i] = eth.sendTransaction({from: eth.accounts[i], to: tokenAddressC, value: web3.toWei("$INITIALETH", "ether"), gas: 100000});
178 | console.log("txIdsC[" + i + "]=" + txIdsC[i]);
179 | }
180 | while (txpool.status.pending > 0) {
181 | }
182 |
183 | for (var i = 0; i < ACCOUNTS; i++) {
184 | printTxData("Sent $INITIALETH ETH from accounts[" + i + "] to tokenA " + tokenAddressA.substring(0, 10), txIdsA[i]);
185 | }
186 | for (var i = 0; i < ACCOUNTS; i++) {
187 | printTxData("Sent $INITIALETH ETH from accounts[" + i + "] to tokenB " + tokenAddressB.substring(0, 10), txIdsB[i]);
188 | }
189 | for (var i = 0; i < ACCOUNTS; i++) {
190 | printTxData("Sent $INITIALETH ETH from accounts[" + i + "] to tokenC " + tokenAddressC.substring(0, 10), txIdsC[i]);
191 | }
192 |
193 | printBalances([eth.accounts[0], eth.accounts[1], eth.accounts[2], tokenAddressA, tokenAddressB, tokenAddressC]);
194 |
195 | assertEtherBalance(tokenAddressA, 3000);
196 | assertEtherBalance(tokenAddressB, 3000);
197 | assertEtherBalance(tokenAddressC, 3000);
198 |
199 | assertTokenBalance(eth.accounts[0], tokenA, 1000);
200 | assertTokenBalance(eth.accounts[1], tokenA, 1000);
201 | assertTokenBalance(eth.accounts[2], tokenA, 1000);
202 |
203 | assertTokenBalance(eth.accounts[0], tokenB, 1000);
204 | assertTokenBalance(eth.accounts[1], tokenB, 1000);
205 | assertTokenBalance(eth.accounts[2], tokenB, 1000);
206 |
207 | assertTokenBalance(eth.accounts[0], tokenB, 1000);
208 | assertTokenBalance(eth.accounts[1], tokenB, 1000);
209 | assertTokenBalance(eth.accounts[2], tokenB, 1000);
210 |
211 | EOF
212 |
213 | grep "DATA: " $TOKENOUTPUTFILE | sed "s/DATA: //" > $TOKENDATAFILE
214 | grep "RESULT: " $TOKENOUTPUTFILE | sed "s/RESULT: //" > $TOKENRESULTFILE
215 | cat $TOKENRESULTFILE
216 |
--------------------------------------------------------------------------------
/testing/test_20170205_1849/06_checkEvents.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # --------------------------------------------------------------------
3 | # Testing Contracts At https://github.com/bokkypoobah/TokenTrader
4 | # for https://cryptoderivatives.market/
5 | #
6 | # Checking Generated Events
7 | #
8 | # (c) BokkyPooBah 2017. The MIT licence.
9 | # --------------------------------------------------------------------
10 |
11 | GETHATTACHPOINT=`grep IPCFILE settings.txt | sed "s/^.*=//"`
12 | PASSWORD=`grep PASSWORD settings.txt | sed "s/^.*=//"`
13 |
14 | TEMPINFILE=`grep TEMPINFILE settings.txt | sed "s/^.*=//"`
15 | TEMPOUTFILE=`grep TEMPOUTFILE settings.txt | sed "s/^.*=//"`
16 | EVENTRESULTFILE=`grep EVENTRESULTFILE settings.txt | sed "s/^.*=//"`
17 |
18 | TOKENDATAFILE=`grep TOKENDATA settings.txt | sed "s/^.*=//"`
19 | TOKENADDRESSA=`grep tokenAddressA $TOKENDATAFILE | tail -n 1 | sed "s/^.*=//"`
20 | TOKENADDRESSB=`grep tokenAddressB $TOKENDATAFILE | tail -n 1 | sed "s/^.*=//"`
21 | TOKENADDRESSC=`grep tokenAddressC $TOKENDATAFILE | tail -n 1 | sed "s/^.*=//"`
22 | TOKENABI=`grep tokenABI $TOKENDATAFILE | tail -n 1 | sed "s/^.*=//"`
23 |
24 | FACTORYDATAFILE=`grep FACTORYDATAFILE settings.txt | sed "s/^.*=//"`
25 | TOKENTRADERFACTORYADDRESS=`grep ^tokenTraderFactoryAddress $FACTORYDATAFILE | tail -n 1 | sed "s/^.*=//"`
26 | TOKENTRADERFACTORYABI=`grep ^tokenTraderFactoryABI $FACTORYDATAFILE | tail -n 1 | sed "s/^.*=//"`
27 | TOKENTRADERADDRESS=`grep ^tokenTraderAddress $FACTORYDATAFILE | tail -n 1 | sed "s/^.*=//"`
28 | TOKENTRADERABI=`grep ^tokenTraderABI $FACTORYDATAFILE | tail -n 1 | sed "s/^.*=//"`
29 | TOKENSELLERFACTORYADDRESS=`grep tokenSellerFactoryAddress $FACTORYDATAFILE | tail -n 1 | sed "s/^.*=//"`
30 | TOKENSELLERFACTORYABI=`grep tokenSellerFactoryABI $FACTORYDATAFILE | tail -n 1 | sed "s/^.*=//"`
31 | TOKENSELLERADDRESS=`grep tokenSellerAddress $FACTORYDATAFILE | tail -n 1 | sed "s/^.*=//"`
32 | TOKENSELLERABI=`grep tokenSellerABI $FACTORYDATAFILE | tail -n 1 | sed "s/^.*=//"`
33 | GNTTOKENTRADERFACTORYADDRESS=`grep gntTokenTraderFactoryAddress $FACTORYDATAFILE | tail -n 1 | sed "s/^.*=//"`
34 | GNTTOKENTRADERFACTORYABI=`grep gntTokenTraderFactoryABI $FACTORYDATAFILE | tail -n 1 | sed "s/^.*=//"`
35 | GNTTOKENTRADERADDRESS=`grep gntTokenTraderAddress $FACTORYDATAFILE | tail -n 1 | sed "s/^.*=//"`
36 | GNTTOKENTRADERABI=`grep gntTokenTraderABI $FACTORYDATAFILE | tail -n 1 | sed "s/^.*=//"`
37 |
38 | printf "Connecting to geth on endpoint '$GETHATTACHPOINT'\n" | tee $TEMPOUTFILE
39 | printf "TokenA address '$TOKENADDRESSA'\n" | tee -a $TEMPOUTFILE
40 | printf "TokenB address '$TOKENADDRESSB'\n" | tee -a $TEMPOUTFILE
41 | printf "TokenC address '$TOKENADDRESSC'\n" | tee -a $TEMPOUTFILE
42 | printf "Token ABI '$TOKENABI'\n" | tee -a $TEMPOUTFILE
43 | printf "TokenTraderFactory address '$TOKENTRADERFACTORYADDRESS'\n" | tee -a $TEMPOUTFILE
44 | printf "TokenTraderFactory ABI '$TOKENTRADERFACTORYABI'\n" | tee -a $TEMPOUTFILE
45 | printf "TokenTrader address '$TOKENTRADERADDRESS'\n" | tee -a $TEMPOUTFILE
46 | printf "TokenTrader ABI '$TOKENTRADERABI'\n" | tee -a $TEMPOUTFILE
47 | printf "var tokenTraderABI = $TOKENTRADERABI;\n" > $TEMPINFILE
48 | printf "TokenSellerFactory address '$TOKENSELLERFACTORYADDRESS'\n" | tee -a $TEMPOUTFILE
49 | printf "TokenSellerFactory ABI '$TOKENSELLERFACTORYABI'\n" | tee -a $TEMPOUTFILE
50 | printf "TokenSeller address '$TOKENSELLERADDRESS'\n" | tee -a $TEMPOUTFILE
51 | printf "TokenSeller ABI '$TOKENSELLERABI'\n" | tee -a $TEMPOUTFILE
52 | printf "var tokenSellerABI = $TOKENSELLERABI;\n" >> $TEMPINFILE
53 | printf "GNTTokenTraderFactory address '$GNTTOKENTRADERFACTORYADDRESS'\n" | tee -a $TEMPOUTFILE
54 | printf "GNTTokenTraderFactory ABI '$GNTTOKENTRADERFACTORYABI'\n" | tee -a $TEMPOUTFILE
55 | printf "GNTTokenTrader address '$GNTTOKENTRADERADDRESS'\n" | tee -a $TEMPOUTFILE
56 | printf "GNTTokenTrader ABI '$GNTTOKENTRADERABI'\n" | tee -a $TEMPOUTFILE
57 | printf "EventResult '$EVENTRESULTFILE'\n" | tee -a $TEMPOUTFILE
58 |
59 | geth --verbosity 3 attach $GETHATTACHPOINT << EOF | tee -a $TEMPOUTFILE
60 |
61 | loadScript("$TEMPINFILE");
62 |
63 | var tokenA = web3.eth.contract($TOKENABI).at("$TOKENADDRESSA");
64 | var tokenB = web3.eth.contract($TOKENABI).at("$TOKENADDRESSB");
65 | var tokenC = web3.eth.contract($TOKENABI).at("$TOKENADDRESSC");
66 | var tokenTraderFactory = web3.eth.contract($TOKENTRADERFACTORYABI).at("$TOKENTRADERFACTORYADDRESS");
67 | var tokenTrader = web3.eth.contract(tokenTraderABI).at("$TOKENTRADERADDRESS");
68 | var tokenSellerFactory = web3.eth.contract($TOKENSELLERFACTORYABI).at("$TOKENSELLERFACTORYADDRESS");
69 | var tokenSeller = web3.eth.contract(tokenSellerABI).at("$TOKENSELLERADDRESS");
70 | var gntTokenTraderFactory = web3.eth.contract($GNTTOKENTRADERFACTORYABI).at("$GNTTOKENTRADERFACTORYADDRESS");
71 | var gntTokenTrader = web3.eth.contract($GNTTOKENTRADERABI).at("$GNTTOKENTRADERADDRESS");
72 |
73 | function pad(s) {
74 | var o = s.toFixed(18);
75 | while (o.length < 27) {
76 | o = " " + o;
77 | }
78 | return o;
79 | }
80 |
81 | var accounts = [eth.accounts[0], eth.accounts[1], "$TOKENADDRESSA", "$TOKENADDRESSB", "$TOKENADDRESSC", "$TOKENTRADERADDRESS", "$TOKENSELLERADDRESS", "$GNTTOKENTRADERADDRESS"];
82 | var accountName = {};
83 | accountName[eth.accounts[0]] = "Account #0";
84 | accountName[eth.accounts[1]] = "Account #1";
85 | accountName["$TOKENADDRESSA"] = "ERC20A";
86 | accountName["$TOKENADDRESSB"] = "ERC20B";
87 | accountName["$TOKENADDRESSC"] = "ERC20C";
88 | accountName["$TOKENTRADERFACTORYADDRESS"] = "TokenTraderFactory";
89 | accountName["$TOKENTRADERADDRESS"] = "TokenTrader b1.1,s1.2";
90 | accountName["$TOKENSELLERFACTORYADDRESS"] = "TokenSellerFactory";
91 | accountName["$TOKENSELLERADDRESS"] = "TokenSeller s1.2";
92 | accountName["$GNTTOKENTRADERFACTORYADDRESS"] = "GNTTokenTraderFactory";
93 | accountName["$GNTTOKENTRADERADDRESS"] = "GNTTokenTrader s1.3";
94 |
95 | function printBalances(accounts) {
96 | var i = 0;
97 | console.log("RESULT: # Account EtherBalance TokenABalance TokenBBalance TokenCBalance Name");
98 | accounts.forEach(function(e) {
99 | var etherBalance = web3.fromWei(eth.getBalance(e), "ether");
100 | var tokenABalance = web3.fromWei(tokenA.balanceOf(e), "ether");
101 | var tokenBBalance = web3.fromWei(tokenB.balanceOf(e), "ether");
102 | var tokenCBalance = web3.fromWei(tokenC.balanceOf(e), "ether");
103 | console.log("RESULT: " + i + " " + e + " " + pad(etherBalance) + " " + pad(tokenABalance) + " " + pad(tokenBBalance) + " " + pad(tokenCBalance) + " " + accountName[e]);
104 | i++;
105 | });
106 | }
107 |
108 | function printTxData(name, txId) {
109 | var tx = eth.getTransaction(txId);
110 | var txReceipt = eth.getTransactionReceipt(txId);
111 | console.log("RESULT: " + name + " gas=" + tx.gas + " gasUsed=" + txReceipt.gasUsed + " cost=" + tx.gasPrice.mulß(txReceipt.gasUsed).div(1e18) +
112 | " block=" + txReceipt.blockNumber + " txId=" + txId);
113 | }
114 |
115 | printBalances(accounts);
116 |
117 | console.log("RESULT: Factory Events");
118 | var filter = web3.eth.filter({ address: ["$TOKENTRADERFACTORYADDRESS", "$TOKENSELLERFACTORYADDRESS", "$GNTTOKENTRADERFACTORYADDRESS", "$TOKENTRADERADDRESS", "$TOKENSELLERADDRESS", "$GNTTOKENTRADERADDRESS"], fromBlock: 0, toBlock: "latest" });
119 | var i = 0;
120 | filter.watch(function (error, result) {
121 | console.log("RESULT: Filter " + i++ + ": " + JSON.stringify(result));
122 | });
123 | filter.stopWatching();
124 |
125 | // Check TokenTrader Events
126 | console.log("RESULT: TokenTrader ActivatedEvent");
127 | var tokenTraderActivatedEvent = tokenTrader.ActivatedEvent({}, { fromBlock: 0, toBlock: "latest" });
128 | var i = 0;
129 | tokenTraderActivatedEvent.watch(function (error, result) {
130 | console.log("RESULT: tokenTraderActivatedEvent " + i++ + ": " + JSON.stringify(result));
131 | });
132 | tokenTraderActivatedEvent.stopWatching();
133 |
134 | console.log("RESULT: TokenTrader MakerDepositedEther");
135 | var tokenTraderMakerDepositedEther = tokenTrader.MakerDepositedEther({}, { fromBlock: 0, toBlock: "latest" });
136 | var i = 0;
137 | tokenTraderMakerDepositedEther.watch(function (error, result) {
138 | console.log("RESULT: tokenTraderMakerDepositedEther " + i++ + ": " + JSON.stringify(result));
139 | });
140 | tokenTraderMakerDepositedEther.stopWatching();
141 |
142 | console.log("RESULT: TokenTrader MakerWithdrewAsset");
143 | var tokenTraderMakerWithdrewAsset = tokenTrader.MakerWithdrewAsset({}, { fromBlock: 0, toBlock: "latest" });
144 | var i = 0;
145 | tokenTraderMakerWithdrewAsset.watch(function (error, result) {
146 | console.log("RESULT: tokenTraderMakerWithdrewAsset " + i++ + ": " + JSON.stringify(result));
147 | });
148 | tokenTraderMakerWithdrewAsset.stopWatching();
149 |
150 | console.log("RESULT: TokenTrader MakerWithdrewEther");
151 | var tokenTraderMakerWithdrewEther = tokenTrader.MakerWithdrewEther({}, { fromBlock: 0, toBlock: "latest" });
152 | var i = 0;
153 | tokenTraderMakerWithdrewEther.watch(function (error, result) {
154 | console.log("RESULT: tokenTraderMakerWithdrewEther " + i++ + ": " + JSON.stringify(result));
155 | });
156 | tokenTraderMakerWithdrewEther.stopWatching();
157 |
158 | console.log("RESULT: TokenTrader TakerBoughtAsset");
159 | var tokenTraderTakerBoughtAsset = tokenTrader.TakerBoughtAsset({}, { fromBlock: 0, toBlock: "latest" });
160 | var i = 0;
161 | tokenTraderTakerBoughtAsset.watch(function (error, result) {
162 | console.log("RESULT: tokenTraderTakerBoughtAsset " + i++ + ": " + JSON.stringify(result));
163 | });
164 | tokenTraderTakerBoughtAsset.stopWatching();
165 |
166 | console.log("RESULT: TokenTrader TakerSoldAsset");
167 | var tokenTraderTakerSoldAsset = tokenTrader.TakerSoldAsset({}, { fromBlock: 0, toBlock: "latest" });
168 | var i = 0;
169 | tokenTraderTakerSoldAsset.watch(function (error, result) {
170 | console.log("RESULT: tokenTraderTakerSoldAsset " + i++ + ": " + JSON.stringify(result));
171 | });
172 | tokenTraderTakerSoldAsset.stopWatching();
173 |
174 | // Check TokenSeller Events
175 | console.log("RESULT: TokenSeller ActivatedEvent");
176 | var tokenSellerActivatedEvent = tokenTrader.ActivatedEvent({}, { fromBlock: 0, toBlock: "latest" });
177 | var i = 0;
178 | tokenSellerActivatedEvent.watch(function (error, result) {
179 | console.log("RESULT: tokenSellerActivatedEvent " + i++ + ": " + JSON.stringify(result));
180 | });
181 | tokenSellerActivatedEvent.stopWatching();
182 |
183 | console.log("RESULT: TokenSeller MakerWithdrewAsset");
184 | var tokenSellerMakerWithdrewAsset = tokenTrader.MakerWithdrewAsset({}, { fromBlock: 0, toBlock: "latest" });
185 | var i = 0;
186 | tokenSellerMakerWithdrewAsset.watch(function (error, result) {
187 | console.log("RESULT: tokenSellerMakerWithdrewAsset " + i++ + ": " + JSON.stringify(result));
188 | });
189 | tokenSellerMakerWithdrewAsset.stopWatching();
190 |
191 | console.log("RESULT: TokenSeller MakerWithdrewEther");
192 | var tokenSellerMakerWithdrewEther = tokenTrader.MakerWithdrewEther({}, { fromBlock: 0, toBlock: "latest" });
193 | var i = 0;
194 | tokenSellerMakerWithdrewEther.watch(function (error, result) {
195 | console.log("RESULT: tokenSellerMakerWithdrewEther " + i++ + ": " + JSON.stringify(result));
196 | });
197 | tokenSellerMakerWithdrewEther.stopWatching();
198 |
199 | console.log("RESULT: TokenSeller TakerBoughtAsset");
200 | var tokenSellerTakerBoughtAsset = tokenTrader.TakerBoughtAsset({}, { fromBlock: 0, toBlock: "latest" });
201 | var i = 0;
202 | tokenSellerTakerBoughtAsset.watch(function (error, result) {
203 | console.log("RESULT: tokenSellerTakerBoughtAsset " + i++ + ": " + JSON.stringify(result));
204 | });
205 | tokenSellerMakerWithdrewEther.stopWatching();
206 |
207 | // Approval Events
208 | console.log("RESULT: TokenA Approval");
209 | var tokenAApproval = tokenA.Approval({}, { fromBlock: 0, toBlock: "latest" });
210 | var i = 0;
211 | tokenAApproval.watch(function (error, result) {
212 | console.log("RESULT: tokenAApproval " + i++ + ": " + JSON.stringify(result));
213 | });
214 | tokenAApproval.stopWatching();
215 |
216 | exit;
217 |
218 | EOF
219 |
220 | grep "RESULT: " $TEMPOUTFILE | sed "s/RESULT: //" > $EVENTRESULTFILE
221 | cat $EVENTRESULTFILE
222 |
--------------------------------------------------------------------------------
/testing/test_20170205_1849/GNTTokenTraderFactory.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.4.0;
2 |
3 | //https://github.com/nexusdev/erc20/blob/master/contracts/erc20.sol
4 |
5 | contract ERC20Constant {
6 | function balanceOf( address who ) constant returns (uint value);
7 | }
8 | contract ERC20Stateful {
9 | function transfer( address to, uint value) returns (bool ok);
10 | }
11 | contract ERC20Events {
12 | event Transfer(address indexed from, address indexed to, uint value);
13 | }
14 | contract ERC20 is ERC20Constant, ERC20Stateful, ERC20Events {}
15 |
16 | contract owned {
17 | address public owner;
18 |
19 | function owned() {
20 | owner = msg.sender;
21 | }
22 |
23 | modifier onlyOwner {
24 | if (msg.sender != owner) throw;
25 | _;
26 | }
27 |
28 | function transferOwnership(address newOwner) onlyOwner {
29 | owner = newOwner;
30 | }
31 | }
32 |
33 | // contract can sell tokens for ETH
34 | // prices are in amount of wei per batch of token units
35 |
36 | contract TokenTrader is owned {
37 |
38 | address public asset; // address of token
39 | uint256 public sellPrice; // contract sells lots of tokens at this price
40 | uint256 public units; // lot size (token-wei)
41 |
42 | bool public sellsTokens; // is contract selling
43 |
44 | event ActivatedEvent(bool sells);
45 | event UpdateEvent();
46 |
47 | function TokenTrader (
48 | address _asset,
49 | uint256 _sellPrice,
50 | uint256 _units,
51 | bool _sellsTokens
52 | )
53 | {
54 | asset = _asset;
55 | sellPrice = _sellPrice;
56 | units = _units;
57 | sellsTokens = _sellsTokens;
58 |
59 | ActivatedEvent(sellsTokens);
60 | }
61 |
62 | // modify trading behavior
63 | function activate (
64 | bool _sellsTokens
65 | ) onlyOwner
66 | {
67 | sellsTokens = _sellsTokens;
68 |
69 | ActivatedEvent(sellsTokens);
70 | }
71 |
72 | // allow owner to remove trade token
73 | function withdrawAsset(uint256 _value) onlyOwner returns (bool ok)
74 | {
75 | return ERC20(asset).transfer(owner,_value);
76 | UpdateEvent();
77 | }
78 |
79 | // allow owner to remove arbitrary tokens
80 | // included just in case contract receives wrong token
81 | function withdrawToken(address _token, uint256 _value) onlyOwner returns (bool ok)
82 | {
83 | return ERC20(_token).transfer(owner,_value);
84 | UpdateEvent();
85 | }
86 |
87 | // allow owner to remove ETH
88 | function withdraw(uint256 _value) onlyOwner returns (bool ok)
89 | {
90 | if(this.balance >= _value) {
91 | return owner.send(_value);
92 | }
93 | UpdateEvent();
94 | }
95 |
96 | //user buys token with ETH
97 | function buy() payable {
98 | if(sellsTokens || msg.sender == owner)
99 | {
100 | uint order = msg.value / sellPrice;
101 | uint can_sell = ERC20(asset).balanceOf(address(this)) / units;
102 |
103 | if(order > can_sell)
104 | {
105 | uint256 change = msg.value - (can_sell * sellPrice);
106 | order = can_sell;
107 | if(!msg.sender.send(change)) throw;
108 | }
109 |
110 | if(order > 0) {
111 | if(!ERC20(asset).transfer(msg.sender,order * units)) throw;
112 | }
113 | UpdateEvent();
114 | }
115 | else if(!msg.sender.send(msg.value)) throw; // return user funds if the contract is not selling
116 | }
117 |
118 | // sending ETH to contract sells GNT to user
119 | function () payable {
120 | buy();
121 | }
122 | }
123 |
124 | // This contract deploys TokenTrader contracts and logs the event
125 | // trade pairs are identified with sha3(asset,units)
126 |
127 | contract TokenTraderFactory {
128 |
129 | event TradeListing(bytes32 bookid, address owner, address addr);
130 | event NewBook(bytes32 bookid, address asset, uint256 units);
131 |
132 | mapping( address => bool ) _verify;
133 | mapping( bytes32 => bool ) pairExits;
134 |
135 | function verify(address tradeContract) constant returns (
136 | bool valid,
137 | address asset,
138 | uint256 sellPrice,
139 | uint256 units,
140 | bool sellsTokens
141 | ) {
142 |
143 | valid = _verify[tradeContract];
144 |
145 | if(valid) {
146 | TokenTrader t = TokenTrader(tradeContract);
147 |
148 | asset = t.asset();
149 | sellPrice = t.sellPrice();
150 | units = t.units();
151 | sellsTokens = t.sellsTokens();
152 | }
153 |
154 | }
155 |
156 | function createTradeContract(
157 | address _asset,
158 | uint256 _sellPrice,
159 | uint256 _units,
160 | bool _sellsTokens
161 | ) returns (address)
162 | {
163 | if(_units == 0) throw; // can't sell zero units
164 |
165 | address trader = new TokenTrader (
166 | _asset,
167 | _sellPrice,
168 | _units,
169 | _sellsTokens);
170 |
171 | var bookid = sha3(_asset,_units);
172 |
173 | _verify[trader] = true; // record that this factory created the trader
174 |
175 | TokenTrader(trader).transferOwnership(msg.sender); // set the owner to whoever called the function
176 |
177 | if(pairExits[bookid] == false) {
178 | pairExits[bookid] = true;
179 | NewBook(bookid, _asset, _units);
180 | }
181 |
182 | TradeListing(bookid,msg.sender,trader);
183 | }
184 |
185 | function () {
186 | throw; // Prevents accidental sending of ether to the factory
187 | }
188 | }
--------------------------------------------------------------------------------
/testing/test_20170205_1849/README.md:
--------------------------------------------------------------------------------
1 | The testing results are described in [Testing Results ‐ Feb 05 2017 18:49](https://github.com/bokkypoobah/TokenTrader/wiki/Testing-Results-%E2%80%90-Feb-05-2017-18:49).
2 |
--------------------------------------------------------------------------------
/testing/test_20170205_1849/TestERC20Token.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.4.2;
2 |
3 | // ----------------------------------------------------------------------------------------------
4 | // Basic ERC20 Token Contract For **TESTING ONLY** on Testnet or Dev blockchain.
5 | //
6 | // Enjoy. (c) Bok Consulting Pty Ltd 2016. The MIT Licence.
7 | // ----------------------------------------------------------------------------------------------
8 |
9 | // ERC Token Standard #20 Interface
10 | // https://github.com/ethereum/EIPs/issues/20
11 | contract ERC20Interface {
12 |
13 | // Get the total token supply
14 | function totalSupply() constant returns (uint256 totalSupply);
15 |
16 | // Get the account balance of another account with address _owner
17 | function balanceOf(address _owner) constant returns (uint256 balance);
18 |
19 | // Send _value amount of tokens to address _to
20 | function transfer(address _to, uint256 _value) returns (bool success);
21 |
22 | // Send _value amount of tokens from address _from to address _to
23 | // The transferFrom method is used for a withdraw workflow, allowing contracts to send
24 | // tokens on your behalf, for example to "deposit" to a contract address and/or to charge
25 | // fees in sub-currencies; the command should fail unless the _from account has
26 | // deliberately authorized the sender of the message via some mechanism; we propose
27 | // these standardized APIs for approval:
28 | function transferFrom(address _from, address _to, uint256 _value) returns (bool success);
29 |
30 | // Allow _spender to withdraw from your account, multiple times, up to the _value amount.
31 | // If this function is called again it overwrites the current allowance with _value.
32 | function approve(address _spender, uint256 _value) returns (bool success);
33 |
34 | // Returns the amount which _spender is still allowed to withdraw from _owner
35 | function allowance(address _owner, address _spender) constant returns (uint256 remaining);
36 |
37 | // Triggered when tokens are transferred.
38 | event Transfer(address indexed _from, address indexed _to, uint256 _value);
39 |
40 | // Triggered whenever approve(address _spender, uint256 _value) is called.
41 | event Approval(address indexed _owner, address indexed _spender, uint256 _value);
42 | }
43 |
44 | contract TestERC20Token is ERC20Interface {
45 |
46 | string public name;
47 | string public symbol;
48 | uint8 public decimals;
49 |
50 | // Owner of this contract
51 | address public owner;
52 |
53 | // Balances for each account
54 | mapping(address => uint256) balances;
55 |
56 | // Owner of account approves the transfer of an amount to another account
57 | mapping(address => mapping (address => uint256)) allowed;
58 |
59 | // Total supply
60 | uint256 _totalSupply;
61 |
62 | // Functions with this modifier can only be executed by the owner
63 | modifier onlyOwner() {
64 | if (msg.sender != owner) {
65 | throw;
66 | }
67 | _;
68 | }
69 |
70 | // Constructor
71 | function TestERC20Token(string _name, string _symbol, uint8 _decimals) {
72 | name = _name;
73 | symbol = _symbol;
74 | decimals = _decimals;
75 | owner = msg.sender;
76 | }
77 |
78 | function totalSupply() constant returns (uint256 totalSupply) {
79 | totalSupply = _totalSupply;
80 | }
81 |
82 | // What is the balance of a particular account?
83 | function balanceOf(address _owner) constant returns (uint256 balance) {
84 | return balances[_owner];
85 | }
86 |
87 | // Transfer the balance from owner's account to another account
88 | function transfer(address _to, uint256 _amount) returns (bool success) {
89 | if (balances[msg.sender] >= _amount && _amount > 0) {
90 | balances[msg.sender] -= _amount;
91 | balances[_to] += _amount;
92 | Transfer(msg.sender, _to, _amount);
93 | return true;
94 | } else {
95 | return false;
96 | }
97 | }
98 |
99 | // Send _value amount of tokens from address _from to address _to
100 | // The transferFrom method is used for a withdraw workflow, allowing contracts to send
101 | // tokens on your behalf, for example to "deposit" to a contract address and/or to charge
102 | // fees in sub-currencies; the command should fail unless the _from account has
103 | // deliberately authorized the sender of the message via some mechanism; we propose
104 | // these standardized APIs for approval:
105 | function transferFrom(
106 | address _from,
107 | address _to,
108 | uint256 _amount
109 | ) returns (bool success) {
110 |
111 | if (balances[_from] >= _amount
112 | && allowed[_from][msg.sender] >= _amount
113 | && _amount > 0) {
114 |
115 | balances[_to] += _amount;
116 | balances[_from] -= _amount;
117 | allowed[_from][msg.sender] -= _amount;
118 | Transfer(_from, _to, _amount);
119 | return true;
120 | } else {
121 | return false;
122 | }
123 | }
124 |
125 | // Allow _spender to withdraw from your account, multiple times, up to the _value amount.
126 | // If this function is called again it overwrites the current allowance with _value.
127 | function approve(address _spender, uint256 _amount) returns (bool success) {
128 | allowed[msg.sender][_spender] = _amount;
129 | Approval(msg.sender, _spender, _amount);
130 | return true;
131 | }
132 |
133 | function allowance(address _owner, address _spender) constant returns (uint256 remaining) {
134 | return allowed[_owner][_spender];
135 | }
136 |
137 | function () payable {
138 | if (msg.value > 0) {
139 | _totalSupply += msg.value;
140 | balances[msg.sender] += msg.value;
141 | }
142 | }
143 |
144 | function withdrawEthers(uint256 ethers) onlyOwner returns (bool ok) {
145 | if (this.balance >= ethers) {
146 | return owner.send(ethers);
147 | }
148 | }
149 |
150 | // Triggered when fiat currency is converted to tokens
151 | event TokensCreated(address indexed _owner, uint256 _amount);
152 | }
153 |
--------------------------------------------------------------------------------
/testing/test_20170205_1849/factoryResults.txt:
--------------------------------------------------------------------------------
1 | traderFactoryAddress=0x03d47b0d78f8dee3089037dffd5c9a1f7e7282af gas=3000000 gasUsed=1713217 cost=0.03426434 block=18 txId=0x91a7afb11ba45077491f220867bf9d78dada1d1c9ca7b5978782ec6a1bac86a6
2 | sellerFactoryAddress=0xcc643e6c5639d64ca3c0c484a6c0f23d11b87477 gas=3000000 gasUsed=1260509 cost=0.02521018 block=18 txId=0x460cd673e2c6f74dcba3074023849d5948e79de27abf602fdb1db9ee197b812b
3 | gntTraderFactoryAddress=0xbd7780c8773a6c99163ea9c1fa870450bc216aa6 gas=3000000 gasUsed=900698 cost=0.01801396 block=18 txId=0xd10067024be0d416f15d9c45588946d17a2d8d9a41976feb4e8db31bdf2fade5
4 | createTradeContractTxId gas=1000000 gasUsed=995364 cost=0.01990728 block=20 txId=0xeff173756f132afbb5e1271a8c952d2169f93437df6c44e2f674bb25bf84c8d5
5 | createSaleContractTxId gas=1000000 gasUsed=697768 cost=0.01395536 block=20 txId=0xe332bac2c19348c3ceab7d5093e1c5b462d56992f4a2e2a0661ef594272404b6
6 | createGNTTradeContractTxId gas=1000000 gasUsed=566186 cost=0.01132372 block=20 txId=0x1a66b864d33446659b7490468151ac5ee8342c5f5d6b7e12ac590509ca8a9f28
7 | traderVerifyResults [true,"0x0014060ff383c9b21c6840a3b14aab06741e5c49","0xebb2634dd3194ba6d75eeb049cd0f73bf9801d95","110000","120000","100000",true,true]
8 | sellerVerifyResults [true,"0x0014060ff383c9b21c6840a3b14aab06741e5c49","0xebb2634dd3194ba6d75eeb049cd0f73bf9801d95","120000","100000",true]
9 | gntTraderVerifyResults [true,"0xebb2634dd3194ba6d75eeb049cd0f73bf9801d95","130000","100000",true]
10 | # Account EtherBalance TokenABalance TokenBBalance TokenCBalance Name
11 | 0 0x000d1009bd8f0b1301cc5edc28ed1222a3ce671e 97105.169613733782040757 1000.000000000000000000 1000.000000000000000000 1000.000000000000000000 Account #0
12 | 1 0x0014060ff383c9b21c6840a3b14aab06741e5c49 96999.833165466217959243 1000.000000000000000000 1000.000000000000000000 1000.000000000000000000 Account #1
13 | 2 0x0020017ba4c67f76c76b1af8c41821ee54f37171 96999.997220800000000000 1000.000000000000000000 1000.000000000000000000 1000.000000000000000000 Account #2
14 | 3 0xebb2634dd3194ba6d75eeb049cd0f73bf9801d95 3000.000000000000000000 0.000000000000000000 0.000000000000000000 0.000000000000000000 ERC20A
15 | 4 0xe9ba90b474ef72aa062d89a319c3e15b31e8fe65 3000.000000000000000000 0.000000000000000000 0.000000000000000000 0.000000000000000000 ERC20B
16 | 5 0x30da52ef30bdaec61b43317cc045e4f267eaf779 3000.000000000000000000 0.000000000000000000 0.000000000000000000 0.000000000000000000 ERC20C
17 | 6 0x03d47b0d78f8dee3089037dffd5c9a1f7e7282af 0.000000000000000000 0.000000000000000000 0.000000000000000000 0.000000000000000000 TokenTraderFactory
18 | 7 0xcc643e6c5639d64ca3c0c484a6c0f23d11b87477 0.000000000000000000 0.000000000000000000 0.000000000000000000 0.000000000000000000 TokenSellerFactory
19 | 8 0xbd7780c8773a6c99163ea9c1fa870450bc216aa6 0.000000000000000000 0.000000000000000000 0.000000000000000000 0.000000000000000000 GNTTokenTraderFactory
20 | 9 0xfb6ae08258f553335fd33b71081228e53794f8eb 0.000000000000000000 0.000000000000000000 0.000000000000000000 0.000000000000000000 TokenTrader
21 | 10 0x85e7378cb6a2ecbcaf5c178775764615f5046a9d 0.000000000000000000 0.000000000000000000 0.000000000000000000 0.000000000000000000 TokenSeller
22 | 11 0x7afc189b25beba65c5a2dec4804ea77b40f8c9a5 0.000000000000000000 0.000000000000000000 0.000000000000000000 0.000000000000000000 GNTTokenTrader
23 | Depositing 100 ETH to tokenTrader 0xfb6ae08258f553335fd33b71081228e53794f8eb
24 | Transferring 100 tokenAs to tokenTrader 0xfb6ae08258f553335fd33b71081228e53794f8eb
25 | Transferring 100 tokenAs to tokenSeller 0x85e7378cb6a2ecbcaf5c178775764615f5046a9d
26 | Transferring 100 tokenAs to gntTokenTrader 0x7afc189b25beba65c5a2dec4804ea77b40f8c9a5
27 | traderDepositEtherTxId gas=100000 gasUsed=22755 cost=0.0004551 block=25 txId=0xfe8442277af908d3bec93bc9604843ac30d131453135e1bb57b8ed6942ec5668
28 | traderTransferTokenTxId gas=100000 gasUsed=51044 cost=0.00102088 block=25 txId=0x0749e05a01029c1bb5b9df7e403e788be9d75d3e698c90a43ef4e5fd27b346f8
29 | sellerTransferTokenTxId gas=100000 gasUsed=51044 cost=0.00102088 block=25 txId=0xa02e5121710cddbfcbd2ca849ebf4471fb4f5feed6da37ae201c9a56e261f333
30 | gntTraderTransferTokenTxId gas=100000 gasUsed=51044 cost=0.00102088 block=25 txId=0xd87225d8a89e88e91c67a51f22d846d795bb881d17682f5f2c8e0b4c5e764792
31 | OK 0xebb2634dd3194ba6d75eeb049cd0f73bf9801d95 has expected balance 3000
32 | Expecting 100 TokenABalance and 100 ETH in tokenTrader 0xfb6ae08258f553335fd33b71081228e53794f8eb
33 | Expecting 100 TokenABalance in tokenSeller 0x85e7378cb6a2ecbcaf5c178775764615f5046a9d
34 | Expecting 100 TokenABalance in gntTokenTrader 0x7afc189b25beba65c5a2dec4804ea77b40f8c9a5
35 | # Account EtherBalance TokenABalance TokenBBalance TokenCBalance Name
36 | 0 0x000d1009bd8f0b1301cc5edc28ed1222a3ce671e 97125.173131473782040757 1000.000000000000000000 1000.000000000000000000 1000.000000000000000000 Account #0
37 | 1 0x0014060ff383c9b21c6840a3b14aab06741e5c49 96899.829647726217959243 700.000000000000000000 1000.000000000000000000 1000.000000000000000000 Account #1
38 | 2 0x0020017ba4c67f76c76b1af8c41821ee54f37171 96999.997220800000000000 1000.000000000000000000 1000.000000000000000000 1000.000000000000000000 Account #2
39 | 3 0xebb2634dd3194ba6d75eeb049cd0f73bf9801d95 3000.000000000000000000 0.000000000000000000 0.000000000000000000 0.000000000000000000 ERC20A
40 | 4 0xe9ba90b474ef72aa062d89a319c3e15b31e8fe65 3000.000000000000000000 0.000000000000000000 0.000000000000000000 0.000000000000000000 ERC20B
41 | 5 0x30da52ef30bdaec61b43317cc045e4f267eaf779 3000.000000000000000000 0.000000000000000000 0.000000000000000000 0.000000000000000000 ERC20C
42 | 6 0x03d47b0d78f8dee3089037dffd5c9a1f7e7282af 0.000000000000000000 0.000000000000000000 0.000000000000000000 0.000000000000000000 TokenTraderFactory
43 | 7 0xcc643e6c5639d64ca3c0c484a6c0f23d11b87477 0.000000000000000000 0.000000000000000000 0.000000000000000000 0.000000000000000000 TokenSellerFactory
44 | 8 0xbd7780c8773a6c99163ea9c1fa870450bc216aa6 0.000000000000000000 0.000000000000000000 0.000000000000000000 0.000000000000000000 GNTTokenTraderFactory
45 | 9 0xfb6ae08258f553335fd33b71081228e53794f8eb 100.000000000000000000 100.000000000000000000 0.000000000000000000 0.000000000000000000 TokenTrader
46 | 10 0x85e7378cb6a2ecbcaf5c178775764615f5046a9d 0.000000000000000000 100.000000000000000000 0.000000000000000000 0.000000000000000000 TokenSeller
47 | 11 0x7afc189b25beba65c5a2dec4804ea77b40f8c9a5 0.000000000000000000 100.000000000000000000 0.000000000000000000 0.000000000000000000 GNTTokenTrader
48 | OK 0x03d47b0d78f8dee3089037dffd5c9a1f7e7282af has expected balance 0
49 | OK 0x03d47b0d78f8dee3089037dffd5c9a1f7e7282af has expected ERC20A token balance 0
50 | OK 0xcc643e6c5639d64ca3c0c484a6c0f23d11b87477 has expected balance 0
51 | OK 0xcc643e6c5639d64ca3c0c484a6c0f23d11b87477 has expected ERC20A token balance 0
52 | OK 0xbd7780c8773a6c99163ea9c1fa870450bc216aa6 has expected balance 0
53 | OK 0xbd7780c8773a6c99163ea9c1fa870450bc216aa6 has expected ERC20A token balance 0
54 | OK 0xfb6ae08258f553335fd33b71081228e53794f8eb has expected balance 100
55 | OK 0xfb6ae08258f553335fd33b71081228e53794f8eb has expected ERC20A token balance 100
56 | OK 0x85e7378cb6a2ecbcaf5c178775764615f5046a9d has expected balance 0
57 | OK 0x85e7378cb6a2ecbcaf5c178775764615f5046a9d has expected ERC20A token balance 100
58 | OK 0x7afc189b25beba65c5a2dec4804ea77b40f8c9a5 has expected balance 0
59 | OK 0x7afc189b25beba65c5a2dec4804ea77b40f8c9a5 has expected ERC20A token balance 100
60 |
--------------------------------------------------------------------------------
/testing/test_20170205_1849/genesis.json:
--------------------------------------------------------------------------------
1 | {
2 | "config": {
3 | "homesteadBlock": 1
4 | },
5 | "nonce": "0",
6 | "difficulty": "0x400",
7 | "mixhash": "0x00000000000000000000000000000000000000647572616c65787365646c6578",
8 | "coinbase": "0x0000000000000000000000000000000000000000",
9 | "timestamp": "0x00",
10 | "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
11 | "extraData": "0x",
12 | "gasLimit": "0x3B4A1B44",
13 | "alloc": {
14 | "0x000d1009bd8f0b1301cc5edc28ed1222a3ce671e": {
15 | "balance": "100000000000000000000000"
16 | },
17 | "0x0014060ff383c9b21c6840a3b14aab06741e5c49": {
18 | "balance": "100000000000000000000000"
19 | },
20 | "0x0020017ba4c67f76c76b1af8c41821ee54f37171": {
21 | "balance": "100000000000000000000000"
22 | },
23 | "0x0036f6addb6d64684390f55a92f0f4988266901b": {
24 | "balance": "100000000000000000000000"
25 | },
26 | "0x004e64833635cd1056b948b57286b7c91e62731c": {
27 | "balance": "100000000000000000000000"
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/testing/test_20170205_1849/settings.txt:
--------------------------------------------------------------------------------
1 | IxPCFILE=ipc://Users/bok/ESE/gethgenesis/geth.ipc
2 |
3 | IPCFILE=ipc:./testchain/geth.ipc
4 | PASSWORD=testtest
5 |
6 | TYPE=Trader
7 | INITIALETH=1000
8 |
9 | TOKENSOL=TestERC20Token.sol
10 | TOKENTRADERFACTORYSOL=TokenTraderFactory.sol
11 | TOKENSELLERFACTORYSOL=TokenSellerFactory.sol
12 | GNTTOKENTRADERFACTORYSOL=GNTTokenTraderFactory.sol
13 |
14 | TEMPINFILE=zzinput.tmp
15 | TEMPOUTFILE=zzoutput.tmp
16 |
17 | TOKENOUTPUTFILE=tokenOutput.txt
18 | TOKENDATAFILE=tokenData.txt
19 | TOKENRESULTFILE=tokenResults.txt
20 |
21 | FACTORYOUTPUTFILE=factoryOutput.txt
22 | FACTORYDATAFILE=factoryData.txt
23 | FACTORYRESULTFILE=factoryResults.txt
24 |
25 | EXECUTIONOUTPUTFILE=executionOutput.txt
26 | EXECUTIONRESULTFILE=executionResults.txt
27 |
28 | OTHEROUTPUTFILE=otherOutput.txt
29 | OTHERRESULTFILE=otherResults.txt
30 |
31 | BUGOUTPUTFILE=bugOutput.txt
32 | BUGRESULTFILE=bugResults.txt
33 |
34 | EVENTRESULTFILE=eventResults.txt
35 |
--------------------------------------------------------------------------------
/testing/test_20170205_1849/stripCrLf:
--------------------------------------------------------------------------------
1 | #!/usr/bin/perl
2 | while (<>) {
3 | chomp; # Remove newline
4 | s#/\*.*?\*/##sg; # Remove multiline comments
5 | s/\/\/.*$//go; # Remove // comments
6 | s/\s+/ /go; # Collapse space
7 | print;
8 | }
9 | print "\n";
10 |
--------------------------------------------------------------------------------
/testing/test_20170205_1849/testchain/keystore/UTC--2016-12-16T01-36-05.134620242Z--000d1009bd8f0b1301cc5edc28ed1222a3ce671e:
--------------------------------------------------------------------------------
1 | {"address":"000d1009bd8f0b1301cc5edc28ed1222a3ce671e","crypto":{"cipher":"aes-128-ctr","ciphertext":"d59bbf7979a49434bb5b9fd62deee6bade6d3863d51007ac5a68075493dc025c","cipherparams":{"iv":"4ea160bd84819089c721da4721094f1c"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":262144,"p":1,"r":8,"salt":"f3916dcd671250a149a2fa5dd1b9049e6f66f856460c0d156f6ca8d8804d1337"},"mac":"74e459f91acf536cd90182031043a1832f2c52d1e914b5c6fa9068e599a71b7c"},"id":"59f697eb-7fd7-4c97-bb7f-642f0efc875d","version":3}
--------------------------------------------------------------------------------
/testing/test_20170205_1849/testchain/keystore/UTC--2016-12-16T01-36-45.681050789Z--0014060ff383c9b21c6840a3b14aab06741e5c49:
--------------------------------------------------------------------------------
1 | {"address":"0014060ff383c9b21c6840a3b14aab06741e5c49","crypto":{"cipher":"aes-128-ctr","ciphertext":"05d4f6408ff59ef400fd251fdac2c05e634d6fb56abb2aafbb34c1960f4da43e","cipherparams":{"iv":"bdd2aa67855754664ca87b7d8f355730"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":262144,"p":1,"r":8,"salt":"13a9ee72e426c421fef154b1ae468d79e2cef70c7c04c44a7de5ff85211dcf9a"},"mac":"dde360e4b44ef71e71172edcf9869d481a099fa655e6f5ca481b5d30887e21f7"},"id":"163e5bfa-c75d-426b-95f9-68715ae38ed4","version":3}
--------------------------------------------------------------------------------
/testing/test_20170205_1849/testchain/keystore/UTC--2016-12-16T01-37-12.717455318Z--0020017ba4c67f76c76b1af8c41821ee54f37171:
--------------------------------------------------------------------------------
1 | {"address":"0020017ba4c67f76c76b1af8c41821ee54f37171","crypto":{"cipher":"aes-128-ctr","ciphertext":"56598c7aef98104a2e29731ea2e5962e74b09bf7b3dd4d5d97c78292977752df","cipherparams":{"iv":"0d696d5d1e2680d7a04f0be8062f4ed3"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":262144,"p":1,"r":8,"salt":"3b601ed2bdf111bdc11dee3f5a9b85ca5b566f521fd4444596c197ed35e87e1a"},"mac":"90664c391a208a2779c931a98ac7c27424d81ec6ede00bc132ae6ba566ad2a96"},"id":"78fe49c7-fd71-4c64-b78d-bf461cb3e71c","version":3}
--------------------------------------------------------------------------------
/testing/test_20170205_1849/testchain/keystore/UTC--2016-12-16T01-37-37.923741925Z--0036f6addb6d64684390f55a92f0f4988266901b:
--------------------------------------------------------------------------------
1 | {"address":"0036f6addb6d64684390f55a92f0f4988266901b","crypto":{"cipher":"aes-128-ctr","ciphertext":"f8d7c3bb1d2142dd3d45426a39c32ce21668647c4cbaa86b0b8021378c825fb5","cipherparams":{"iv":"e94709dc5f877f678e444a16bfd0dcad"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":262144,"p":1,"r":8,"salt":"1fbba771a9e7a34184fcbb03a8b30e1f0c6a6034a46f090a78242ed590ebc1af"},"mac":"977971908c8061c81756fd378337bc11f786146783a5a7089b6a5efa16822ed0"},"id":"ebc305b9-3e9f-4d6b-82a4-4d6c59a6807f","version":3}
--------------------------------------------------------------------------------
/testing/test_20170205_1849/testpassword:
--------------------------------------------------------------------------------
1 | testtest
2 |
--------------------------------------------------------------------------------
/testing/test_20170205_1849/tokenData.txt:
--------------------------------------------------------------------------------
1 | tokenABI=[{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_amount","type":"uint256"}],"name":"approve","outputs":[{"name":"success","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"totalSupply","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_amount","type":"uint256"}],"name":"transferFrom","outputs":[{"name":"success","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"name":"","type":"uint8"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"}],"name":"balanceOf","outputs":[{"name":"balance","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"","type":"string"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_amount","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"},{"constant":false,"inputs":[{"name":"ethers","type":"uint256"}],"name":"withdrawEthers","outputs":[{"name":"ok","type":"bool"}],"payable":false,"type":"function"},{"inputs":[{"name":"_name","type":"string"},{"name":"_symbol","type":"string"},{"name":"_decimals","type":"uint8"}],"payable":false,"type":"constructor"},{"payable":true,"type":"fallback"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_owner","type":"address"},{"indexed":false,"name":"_amount","type":"uint256"}],"name":"TokensCreated","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"}]
2 | tokenAddressA=0xebb2634dd3194ba6d75eeb049cd0f73bf9801d95
3 | tokenAddressB=0xe9ba90b474ef72aa062d89a319c3e15b31e8fe65
4 | tokenAddressC=0x30da52ef30bdaec61b43317cc045e4f267eaf779
5 |
--------------------------------------------------------------------------------
/testing/test_20170205_1849/tokenResults.txt:
--------------------------------------------------------------------------------
1 | Creating ERC20 Token @ Sun, 05 Feb 2017 18:45:23 AEDT
2 | tokenAddressA=0xebb2634dd3194ba6d75eeb049cd0f73bf9801d95 gas=800000 gasUsed=665669 cost=0.014073909399319664 block=5 txId=0x33e344fd1d4b30e915794f8768207809730366ebced4ac6d1d1f9cc8a3273581
3 | tokenAddressB=0xe9ba90b474ef72aa062d89a319c3e15b31e8fe65 gas=800000 gasUsed=665669 cost=0.013785200204167028 block=7 txId=0x7c4c3d462828c445248c8db74d95acff0b2cf89617bc975ee48326d21373d79c
4 | tokenAddressC=0x30da52ef30bdaec61b43317cc045e4f267eaf779 gas=800000 gasUsed=665669 cost=0.013521384178554065 block=9 txId=0x8c821b14ba3d360696c137036457394c0901a4a44ac2aac90e9013f8af37d2ec
5 | Sent 1000 ETH from accounts[0] to tokenA 0xebb2634d gas=100000 gasUsed=61320 cost=0.0012264 block=11 txId=0xf17f240e51a07bce3ce4d7b13aa3b68e233f1e2346b9540501644e6afed28935
6 | Sent 1000 ETH from accounts[1] to tokenA 0xebb2634d gas=100000 gasUsed=46320 cost=0.0009264 block=11 txId=0x169b56c985b7b9deeab33aba19bd3261a81e8e9344e16e79d8aaef2913503c19
7 | Sent 1000 ETH from accounts[2] to tokenA 0xebb2634d gas=100000 gasUsed=46320 cost=0.0009264 block=11 txId=0xcb53ce18531589dd017f6ae353df60be7b49e8e8493ebdcbb07d018d4bf472d2
8 | Sent 1000 ETH from accounts[0] to tokenB 0xe9ba90b4 gas=100000 gasUsed=61320 cost=0.0012264 block=11 txId=0x5dff20995f731d9d3ab9782c79768fab305dd230485d8e825222343c0aae18ea
9 | Sent 1000 ETH from accounts[1] to tokenB 0xe9ba90b4 gas=100000 gasUsed=46320 cost=0.0009264 block=11 txId=0xb8a6901cb056b9156829aed79047f3de0a8e181b50072737dbff8ff89292bc81
10 | Sent 1000 ETH from accounts[2] to tokenB 0xe9ba90b4 gas=100000 gasUsed=46320 cost=0.0009264 block=11 txId=0x471ff4a46d5d2940b57e1530ad05cebbc2f5b0cb45d2445462ba22b0f4a7b1fe
11 | Sent 1000 ETH from accounts[0] to tokenC 0x30da52ef gas=100000 gasUsed=61320 cost=0.0012264 block=11 txId=0x047abb69dbb9d45f018cc166076c2b065a0f6e882ff626e0503f53e7543d8be4
12 | Sent 1000 ETH from accounts[1] to tokenC 0x30da52ef gas=100000 gasUsed=46320 cost=0.0009264 block=11 txId=0x36540384493f93abb7b9e73f477cdad3a03a2756a4c9b2da0cc572cc8a11ce7f
13 | Sent 1000 ETH from accounts[2] to tokenC 0x30da52ef gas=100000 gasUsed=46320 cost=0.0009264 block=11 txId=0x753cbfd69f6b2da0d6ebcd5d2d3c959049c8216c3360d65b4801a09d39b6aa3a
14 | # Account EtherBalance TokenABalance TokenBBalance TokenCBalance Name
15 | 1 0x000d1009bd8f0b1301cc5edc28ed1222a3ce671e 97060.046938893782040757 1000.000000000000000000 1000.000000000000000000 1000.000000000000000000 Account #0
16 | 2 0x0014060ff383c9b21c6840a3b14aab06741e5c49 96999.955840306217959243 1000.000000000000000000 1000.000000000000000000 1000.000000000000000000 Account #1
17 | 3 0x0020017ba4c67f76c76b1af8c41821ee54f37171 96999.997220800000000000 1000.000000000000000000 1000.000000000000000000 1000.000000000000000000 Account #2
18 | 4 0xebb2634dd3194ba6d75eeb049cd0f73bf9801d95 3000.000000000000000000 0.000000000000000000 0.000000000000000000 0.000000000000000000 ERC20A
19 | 5 0xe9ba90b474ef72aa062d89a319c3e15b31e8fe65 3000.000000000000000000 0.000000000000000000 0.000000000000000000 0.000000000000000000 ERC20B
20 | 6 0x30da52ef30bdaec61b43317cc045e4f267eaf779 3000.000000000000000000 0.000000000000000000 0.000000000000000000 0.000000000000000000 ERC20C
21 | OK 0xebb2634dd3194ba6d75eeb049cd0f73bf9801d95 has expected balance 3000
22 | OK 0xe9ba90b474ef72aa062d89a319c3e15b31e8fe65 has expected balance 3000
23 | OK 0x30da52ef30bdaec61b43317cc045e4f267eaf779 has expected balance 3000
24 | OK 0x000d1009bd8f0b1301cc5edc28ed1222a3ce671e has expected ERC20A token balance 1000
25 | OK 0x0014060ff383c9b21c6840a3b14aab06741e5c49 has expected ERC20A token balance 1000
26 | OK 0x0020017ba4c67f76c76b1af8c41821ee54f37171 has expected ERC20A token balance 1000
27 | OK 0x000d1009bd8f0b1301cc5edc28ed1222a3ce671e has expected ERC20B token balance 1000
28 | OK 0x0014060ff383c9b21c6840a3b14aab06741e5c49 has expected ERC20B token balance 1000
29 | OK 0x0020017ba4c67f76c76b1af8c41821ee54f37171 has expected ERC20B token balance 1000
30 | OK 0x000d1009bd8f0b1301cc5edc28ed1222a3ce671e has expected ERC20B token balance 1000
31 | OK 0x0014060ff383c9b21c6840a3b14aab06741e5c49 has expected ERC20B token balance 1000
32 | OK 0x0020017ba4c67f76c76b1af8c41821ee54f37171 has expected ERC20B token balance 1000
33 |
--------------------------------------------------------------------------------