diff --git a/build/contracts/CapCoin.json b/build/contracts/CapCoin.json index 9d7298d4..3376311a 100644 --- a/build/contracts/CapCoin.json +++ b/build/contracts/CapCoin.json @@ -15,6 +15,20 @@ "stateMutability": "view", "type": "function" }, + { + "constant": false, + "inputs": [ + { + "name": "amount", + "type": "uint256" + } + ], + "name": "buyTokens", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, { "constant": true, "inputs": [ @@ -106,20 +120,32 @@ ], "name": "NewUser", "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "name": "coinBalance", + "type": "uint256" + } + ], + "name": "BoughtTokens", + "type": "event" } ], - "bytecode": "0x6060604052620f42406000556000600155341561001b57600080fd5b60016002819055506107c0806100326000396000f30060606040526004361061006c576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168062ce8e3e14610071578063365b98b2146100db578063507ffba51461013e578063832880e71461019b578063edf5388614610230575b600080fd5b341561007c57600080fd5b610084610306565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b838110156100c75780820151818401526020810190506100ac565b505050509050019250505060405180910390f35b34156100e657600080fd5b6100fc600480803590602001909190505061039a565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561014957600080fd5b610199600480803590602001908201803590602001908080601f016020809104026020016040519081016040528093929190818152602001838380828437820191505050505050919050506103d9565b005b34156101a657600080fd5b6101ae610545565b6040518080602001838152602001828103825284818151815260200191508051906020019080838360005b838110156101f45780820151818401526020810190506101d9565b50505050905090810190601f1680156102215780820380516001836020036101000a031916815260200191505b50935050505060405180910390f35b341561023b57600080fd5b610267600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610678565b60405180806020018381526020018281038252848181546001816001161561010002031660029004815260200191508054600181600116156101000203166002900480156102f65780601f106102cb576101008083540402835291602001916102f6565b820191906000526020600020905b8154815290600101906020018083116102d957829003601f168201915b5050935050505060405180910390f35b61030e61069b565b600480548060200260200160405190810160405280929190818152602001828054801561039057602002820191906000526020600020905b8160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019060010190808311610346575b5050505050905090565b6004818154811015156103a957fe5b90600052602060002090016000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000209050818160000190805190602001906104349291906106af565b5060008160010181905550600160048054806001018281610455919061072f565b9160005260206000209001600033909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050507f66ab3fea2083d9ba15d99b595186fe7fc18e6eba393c0fc056f420e96c3caa44826040518080602001828103825283818151815260200191508051906020019080838360005b838110156105075780820151818401526020810190506104ec565b50505050905090810190601f1680156105345780820380516001836020036101000a031916815260200191505b509250505060405180910390a15050565b61054d61075b565b6000600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600001600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060010154818054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156106695780601f1061063e57610100808354040283529160200191610669565b820191906000526020600020905b81548152906001019060200180831161064c57829003601f168201915b50505050509150915091509091565b600360205280600052604060002060009150905080600001908060010154905082565b602060405190810160405280600081525090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106106f057805160ff191683800117855561071e565b8280016001018555821561071e579182015b8281111561071d578251825591602001919060010190610702565b5b50905061072b919061076f565b5090565b81548183558181151161075657818360005260206000209182019101610755919061076f565b5b505050565b602060405190810160405280600081525090565b61079191905b8082111561078d576000816000905550600101610775565b5090565b905600a165627a7a72305820750e2e996e715d109a9dcaca5bd495e8a5b79862d30471d45c4bc9a1d504383a0029", - "deployedBytecode": "0x60606040526004361061006c576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168062ce8e3e14610071578063365b98b2146100db578063507ffba51461013e578063832880e71461019b578063edf5388614610230575b600080fd5b341561007c57600080fd5b610084610306565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b838110156100c75780820151818401526020810190506100ac565b505050509050019250505060405180910390f35b34156100e657600080fd5b6100fc600480803590602001909190505061039a565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561014957600080fd5b610199600480803590602001908201803590602001908080601f016020809104026020016040519081016040528093929190818152602001838380828437820191505050505050919050506103d9565b005b34156101a657600080fd5b6101ae610545565b6040518080602001838152602001828103825284818151815260200191508051906020019080838360005b838110156101f45780820151818401526020810190506101d9565b50505050905090810190601f1680156102215780820380516001836020036101000a031916815260200191505b50935050505060405180910390f35b341561023b57600080fd5b610267600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610678565b60405180806020018381526020018281038252848181546001816001161561010002031660029004815260200191508054600181600116156101000203166002900480156102f65780601f106102cb576101008083540402835291602001916102f6565b820191906000526020600020905b8154815290600101906020018083116102d957829003601f168201915b5050935050505060405180910390f35b61030e61069b565b600480548060200260200160405190810160405280929190818152602001828054801561039057602002820191906000526020600020905b8160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019060010190808311610346575b5050505050905090565b6004818154811015156103a957fe5b90600052602060002090016000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000209050818160000190805190602001906104349291906106af565b5060008160010181905550600160048054806001018281610455919061072f565b9160005260206000209001600033909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050507f66ab3fea2083d9ba15d99b595186fe7fc18e6eba393c0fc056f420e96c3caa44826040518080602001828103825283818151815260200191508051906020019080838360005b838110156105075780820151818401526020810190506104ec565b50505050905090810190601f1680156105345780820380516001836020036101000a031916815260200191505b509250505060405180910390a15050565b61054d61075b565b6000600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600001600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060010154818054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156106695780601f1061063e57610100808354040283529160200191610669565b820191906000526020600020905b81548152906001019060200180831161064c57829003601f168201915b50505050509150915091509091565b600360205280600052604060002060009150905080600001908060010154905082565b602060405190810160405280600081525090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106106f057805160ff191683800117855561071e565b8280016001018555821561071e579182015b8281111561071d578251825591602001919060010190610702565b5b50905061072b919061076f565b5090565b81548183558181151161075657818360005260206000209182019101610755919061076f565b5b505050565b602060405190810160405280600081525090565b61079191905b8082111561078d576000816000905550600101610775565b5090565b905600a165627a7a72305820750e2e996e715d109a9dcaca5bd495e8a5b79862d30471d45c4bc9a1d504383a0029", - "sourceMap": "26:729:0:-;;;97:7;79:25;;127:1;108:20;;153:46;;;;;;;;193:1;179:11;:15;;;;26:729;;;;;;", - "deployedSourceMap": "26:729:0:-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;531:75;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;8:100;33:3;30:1;27:2;8:100;;;99:1;94:3;90;84:5;80:1;75:3;71;64:6;52:2;49:1;45:3;40:15;;8:100;;;12:14;3:109;;;;;;;;;;;;;;;;;313:22:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;340:187;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;610:143;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;8:100;33:3;30:1;27:2;8:100;;;99:1;94:3;90;84:5;80:1;75:3;71;64:6;52:2;49:1;45:3;40:15;;8:100;;;12:14;3:109;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;263:46:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;531:75;572:9;;:::i;:::-;596:5;589:12;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;531:75;:::o;313:22::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;340:187::-;386:8;397:13;:25;411:10;397:25;;;;;;;;;;;;;;;386:36;;441:4;429;:9;;:16;;;;;;;;;;;;:::i;:::-;;470:1;451:4;:16;;:20;;;;502:1;478:5;:22;;;;;;;;;;;:::i;:::-;;;;;;;;;;489:10;478:22;;;;;;;;;;;;;;;;;;;;;;:25;;509:13;517:4;509:13;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;8:100;33:3;30:1;27:2;8:100;;;99:1;94:3;90;84:5;80:1;75:3;71;64:6;52:2;49:1;45:3;40:15;;8:100;;;12:14;3:109;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;340:187:0;;:::o;610:143::-;650:6;;:::i;:::-;658:4;678:13;:25;692:10;678:25;;;;;;;;;;;;;;;:30;;710:13;:25;724:10;710:25;;;;;;;;;;;;;;;:37;;;670:78;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;610:143;;:::o;263:46::-;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;26:729::-;;;;;;;;;;;;;;;:::o;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;:::o;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;:::o;:::-;;;;;;;;;;;;;;;:::o;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o", - "source": "pragma solidity ^0.4.18;\n\ncontract CapCoin {\n\n event NewUser(string name);\n\n uint coinSupply = 1000000;\n uint coinsBought = 0;\n uint contractNum;\n\n function CapCoin () {\n contractNum = 1;\n }\n\n struct User {\n string name;\n uint coinBalance;\n }\n\n mapping (address => User) public addressToUser;\n address[] public users;\n\n function createUser(string name) public {\n var user = addressToUser[msg.sender];\n\n user.name = name;\n user.coinBalance = 0;\n\n users.push(msg.sender) -1;\n NewUser(name);\n }\n\n function getUsers() public view returns (address[]) {\n return users;\n }\n\n function getUser() public view returns (string, uint) {\n return (addressToUser[msg.sender].name, addressToUser[msg.sender].coinBalance);\n }\n}\n", + "bytecode": "0x6060604052620f42406000556000600155341561001b57600080fd5b60016002819055506108d9806100326000396000f300606060405260043610610077576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168062ce8e3e1461007c5780633610724e146100e6578063365b98b214610109578063507ffba51461016c578063832880e7146101c9578063edf538861461025e575b600080fd5b341561008757600080fd5b61008f610334565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b838110156100d25780820151818401526020810190506100b7565b505050509050019250505060405180910390f35b34156100f157600080fd5b61010760048080359060200190919050506103c8565b005b341561011457600080fd5b61012a60048080359060200190919050506104b3565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561017757600080fd5b6101c7600480803590602001908201803590602001908080601f016020809104026020016040519081016040528093929190818152602001838380828437820191505050505050919050506104f2565b005b34156101d457600080fd5b6101dc61065e565b6040518080602001838152602001828103825284818151815260200191508051906020019080838360005b83811015610222578082015181840152602081019050610207565b50505050905090810190601f16801561024f5780820380516001836020036101000a031916815260200191505b50935050505060405180910390f35b341561026957600080fd5b610295600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610791565b60405180806020018381526020018281038252848181546001816001161561010002031660029004815260200191508054600181600116156101000203166002900480156103245780601f106102f957610100808354040283529160200191610324565b820191906000526020600020905b81548152906001019060200180831161030757829003601f168201915b5050935050505060405180910390f35b61033c6107b4565b60048054806020026020016040519081016040528092919081815260200182805480156103be57602002820191906000526020600020905b8160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019060010190808311610374575b5050505050905090565b80600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060010160008282540192505081905550806001600082825401925050819055508060008082825403925050819055507ffe1367e498701f2dfab80a3d41740d46fd7cba533430e611917f0f3df823279a600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600101546040518082815260200191505060405180910390a150565b6004818154811015156104c257fe5b90600052602060002090016000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002090508181600001908051906020019061054d9291906107c8565b506000816001018190555060016004805480600101828161056e9190610848565b9160005260206000209001600033909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050507f66ab3fea2083d9ba15d99b595186fe7fc18e6eba393c0fc056f420e96c3caa44826040518080602001828103825283818151815260200191508051906020019080838360005b83811015610620578082015181840152602081019050610605565b50505050905090810190601f16801561064d5780820380516001836020036101000a031916815260200191505b509250505060405180910390a15050565b610666610874565b6000600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600001600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060010154818054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156107825780601f1061075757610100808354040283529160200191610782565b820191906000526020600020905b81548152906001019060200180831161076557829003601f168201915b50505050509150915091509091565b600360205280600052604060002060009150905080600001908060010154905082565b602060405190810160405280600081525090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061080957805160ff1916838001178555610837565b82800160010185558215610837579182015b8281111561083657825182559160200191906001019061081b565b5b5090506108449190610888565b5090565b81548183558181151161086f5781836000526020600020918201910161086e9190610888565b5b505050565b602060405190810160405280600081525090565b6108aa91905b808211156108a657600081600090555060010161088e565b5090565b905600a165627a7a723058209531aa55e21d60a82232c0b2963be0625f15d1c3fee53d5c2f257a76292a6ed70029", + "deployedBytecode": "0x606060405260043610610077576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168062ce8e3e1461007c5780633610724e146100e6578063365b98b214610109578063507ffba51461016c578063832880e7146101c9578063edf538861461025e575b600080fd5b341561008757600080fd5b61008f610334565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b838110156100d25780820151818401526020810190506100b7565b505050509050019250505060405180910390f35b34156100f157600080fd5b61010760048080359060200190919050506103c8565b005b341561011457600080fd5b61012a60048080359060200190919050506104b3565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561017757600080fd5b6101c7600480803590602001908201803590602001908080601f016020809104026020016040519081016040528093929190818152602001838380828437820191505050505050919050506104f2565b005b34156101d457600080fd5b6101dc61065e565b6040518080602001838152602001828103825284818151815260200191508051906020019080838360005b83811015610222578082015181840152602081019050610207565b50505050905090810190601f16801561024f5780820380516001836020036101000a031916815260200191505b50935050505060405180910390f35b341561026957600080fd5b610295600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610791565b60405180806020018381526020018281038252848181546001816001161561010002031660029004815260200191508054600181600116156101000203166002900480156103245780601f106102f957610100808354040283529160200191610324565b820191906000526020600020905b81548152906001019060200180831161030757829003601f168201915b5050935050505060405180910390f35b61033c6107b4565b60048054806020026020016040519081016040528092919081815260200182805480156103be57602002820191906000526020600020905b8160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019060010190808311610374575b5050505050905090565b80600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060010160008282540192505081905550806001600082825401925050819055508060008082825403925050819055507ffe1367e498701f2dfab80a3d41740d46fd7cba533430e611917f0f3df823279a600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600101546040518082815260200191505060405180910390a150565b6004818154811015156104c257fe5b90600052602060002090016000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002090508181600001908051906020019061054d9291906107c8565b506000816001018190555060016004805480600101828161056e9190610848565b9160005260206000209001600033909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050507f66ab3fea2083d9ba15d99b595186fe7fc18e6eba393c0fc056f420e96c3caa44826040518080602001828103825283818151815260200191508051906020019080838360005b83811015610620578082015181840152602081019050610605565b50505050905090810190601f16801561064d5780820380516001836020036101000a031916815260200191505b509250505060405180910390a15050565b610666610874565b6000600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600001600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060010154818054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156107825780601f1061075757610100808354040283529160200191610782565b820191906000526020600020905b81548152906001019060200180831161076557829003601f168201915b50505050509150915091509091565b600360205280600052604060002060009150905080600001908060010154905082565b602060405190810160405280600081525090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061080957805160ff1916838001178555610837565b82800160010185558215610837579182015b8281111561083657825182559160200191906001019061081b565b5b5090506108449190610888565b5090565b81548183558181151161086f5781836000526020600020918201910161086e9190610888565b5b505050565b602060405190810160405280600081525090565b6108aa91905b808211156108a657600081600090555060010161088e565b5090565b905600a165627a7a723058209531aa55e21d60a82232c0b2963be0625f15d1c3fee53d5c2f257a76292a6ed70029", + "sourceMap": "26:980:0:-;;;137:7;119:25;;167:1;148:20;;193:46;;;;;;;;233:1;219:11;:15;;;;26:980;;;;;;", + "deployedSourceMap": "26:980:0:-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;571:75;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;8:100;33:3;30:1;27:2;8:100;;;99:1;94:3;90;84:5;80:1;75:3;71;64:6;52:2;49:1;45:3;40:15;;8:100;;;12:14;3:109;;;;;;;;;;;;;;;;;797:207:0;;;;;;;;;;;;;;;;;;;;;;;;;;353:22;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;380:187;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;650:143;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;8:100;33:3;30:1;27:2;8:100;;;99:1;94:3;90;84:5;80:1;75:3;71;64:6;52:2;49:1;45:3;40:15;;8:100;;;12:14;3:109;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;303:46:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;571:75;612:9;;:::i;:::-;636:5;629:12;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;571:75;:::o;797:207::-;883:6;842:13;:25;856:10;842:25;;;;;;;;;;;;;;;:37;;;:47;;;;;;;;;;;910:6;895:11;;:21;;;;;;;;;;;936:6;922:10;;:20;;;;;;;;;;;948:51;961:13;:25;975:10;961:25;;;;;;;;;;;;;;;:37;;;948:51;;;;;;;;;;;;;;;;;;797:207;:::o;353:22::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;380:187::-;426:8;437:13;:25;451:10;437:25;;;;;;;;;;;;;;;426:36;;481:4;469;:9;;:16;;;;;;;;;;;;:::i;:::-;;510:1;491:4;:16;;:20;;;;542:1;518:5;:22;;;;;;;;;;;:::i;:::-;;;;;;;;;;529:10;518:22;;;;;;;;;;;;;;;;;;;;;;:25;;549:13;557:4;549:13;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;8:100;33:3;30:1;27:2;8:100;;;99:1;94:3;90;84:5;80:1;75:3;71;64:6;52:2;49:1;45:3;40:15;;8:100;;;12:14;3:109;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;380:187:0;;:::o;650:143::-;690:6;;:::i;:::-;698:4;718:13;:25;732:10;718:25;;;;;;;;;;;;;;;:30;;750:13;:25;764:10;750:25;;;;;;;;;;;;;;;:37;;;710:78;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;650:143;;:::o;303:46::-;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;26:980::-;;;;;;;;;;;;;;;:::o;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;:::o;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;:::o;:::-;;;;;;;;;;;;;;;:::o;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o", + "source": "pragma solidity ^0.4.18;\n\ncontract CapCoin {\n\n event NewUser(string name);\n event BoughtTokens(uint coinBalance);\n\n uint coinSupply = 1000000;\n uint coinsBought = 0;\n uint contractNum;\n\n function CapCoin () {\n contractNum = 1;\n }\n\n struct User {\n string name;\n uint coinBalance;\n }\n\n mapping (address => User) public addressToUser;\n address[] public users;\n\n function createUser(string name) public {\n var user = addressToUser[msg.sender];\n\n user.name = name;\n user.coinBalance = 0;\n\n users.push(msg.sender) -1;\n NewUser(name);\n }\n\n function getUsers() public view returns (address[]) {\n return users;\n }\n\n function getUser() public view returns (string, uint) {\n return (addressToUser[msg.sender].name, addressToUser[msg.sender].coinBalance);\n }\n\n function buyTokens(uint amount) public {\n addressToUser[msg.sender].coinBalance += amount;\n coinsBought += amount;\n coinSupply -= amount;\n BoughtTokens(addressToUser[msg.sender].coinBalance);\n }\n}\n", "sourcePath": "/Users/schwartzz8990/Dropbox/fullstack/capCoin/contracts/CapCoin.sol", "ast": { "attributes": { "absolutePath": "/Users/schwartzz8990/Dropbox/fullstack/capCoin/contracts/CapCoin.sol", "exportedSymbols": { "CapCoin": [ - 100 + 134 ] } }, @@ -149,10 +175,10 @@ "documentation": null, "fullyImplemented": true, "linearizedBaseContracts": [ - 100 + 134 ], "name": "CapCoin", - "scope": 101 + "scope": 135 }, "children": [ { @@ -200,11 +226,56 @@ "name": "EventDefinition", "src": "48:27:0" }, + { + "attributes": { + "anonymous": false, + "name": "BoughtTokens" + }, + "children": [ + { + "children": [ + { + "attributes": { + "constant": false, + "indexed": false, + "name": "coinBalance", + "scope": 9, + "stateVariable": false, + "storageLocation": "default", + "type": "uint256", + "value": null, + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "uint", + "type": "uint256" + }, + "id": 6, + "name": "ElementaryTypeName", + "src": "97:4:0" + } + ], + "id": 7, + "name": "VariableDeclaration", + "src": "97:16:0" + } + ], + "id": 8, + "name": "ParameterList", + "src": "96:18:0" + } + ], + "id": 9, + "name": "EventDefinition", + "src": "78:37:0" + }, { "attributes": { "constant": false, "name": "coinSupply", - "scope": 100, + "scope": 134, "stateVariable": true, "storageLocation": "default", "type": "uint256", @@ -216,9 +287,9 @@ "name": "uint", "type": "uint256" }, - "id": 6, + "id": 10, "name": "ElementaryTypeName", - "src": "79:4:0" + "src": "119:4:0" }, { "attributes": { @@ -233,20 +304,20 @@ "type": "int_const 1000000", "value": "1000000" }, - "id": 7, + "id": 11, "name": "Literal", - "src": "97:7:0" + "src": "137:7:0" } ], - "id": 8, + "id": 12, "name": "VariableDeclaration", - "src": "79:25:0" + "src": "119:25:0" }, { "attributes": { "constant": false, "name": "coinsBought", - "scope": 100, + "scope": 134, "stateVariable": true, "storageLocation": "default", "type": "uint256", @@ -258,9 +329,9 @@ "name": "uint", "type": "uint256" }, - "id": 9, + "id": 13, "name": "ElementaryTypeName", - "src": "108:4:0" + "src": "148:4:0" }, { "attributes": { @@ -275,20 +346,20 @@ "type": "int_const 0", "value": "0" }, - "id": 10, + "id": 14, "name": "Literal", - "src": "127:1:0" + "src": "167:1:0" } ], - "id": 11, + "id": 15, "name": "VariableDeclaration", - "src": "108:20:0" + "src": "148:20:0" }, { "attributes": { "constant": false, "name": "contractNum", - "scope": 100, + "scope": 134, "stateVariable": true, "storageLocation": "default", "type": "uint256", @@ -301,14 +372,14 @@ "name": "uint", "type": "uint256" }, - "id": 12, + "id": 16, "name": "ElementaryTypeName", - "src": "132:4:0" + "src": "172:4:0" } ], - "id": 13, + "id": 17, "name": "VariableDeclaration", - "src": "132:16:0" + "src": "172:16:0" }, { "attributes": { @@ -320,7 +391,7 @@ ], "name": "CapCoin", "payable": false, - "scope": 100, + "scope": 134, "stateMutability": "nonpayable", "superFunction": null, "visibility": "public" @@ -333,9 +404,9 @@ ] }, "children": [], - "id": 14, + "id": 18, "name": "ParameterList", - "src": "170:2:0" + "src": "210:2:0" }, { "attributes": { @@ -344,9 +415,9 @@ ] }, "children": [], - "id": 15, + "id": 19, "name": "ParameterList", - "src": "173:0:0" + "src": "213:0:0" }, { "children": [ @@ -369,13 +440,13 @@ "overloadedDeclarations": [ null ], - "referencedDeclaration": 13, + "referencedDeclaration": 17, "type": "uint256", "value": "contractNum" }, - "id": 16, + "id": 20, "name": "Identifier", - "src": "179:11:0" + "src": "219:11:0" }, { "attributes": { @@ -390,35 +461,35 @@ "type": "int_const 1", "value": "1" }, - "id": 17, + "id": 21, "name": "Literal", - "src": "193:1:0" + "src": "233:1:0" } ], - "id": 18, + "id": 22, "name": "Assignment", - "src": "179:15:0" + "src": "219:15:0" } ], - "id": 19, + "id": 23, "name": "ExpressionStatement", - "src": "179:15:0" + "src": "219:15:0" } ], - "id": 20, + "id": 24, "name": "Block", - "src": "173:26:0" + "src": "213:26:0" } ], - "id": 21, + "id": 25, "name": "FunctionDefinition", - "src": "153:46:0" + "src": "193:46:0" }, { "attributes": { "canonicalName": "CapCoin.User", "name": "User", - "scope": 100, + "scope": 134, "visibility": "public" }, "children": [ @@ -426,7 +497,7 @@ "attributes": { "constant": false, "name": "name", - "scope": 26, + "scope": 30, "stateVariable": false, "storageLocation": "default", "type": "string storage pointer", @@ -439,20 +510,20 @@ "name": "string", "type": "string storage pointer" }, - "id": 22, + "id": 26, "name": "ElementaryTypeName", - "src": "221:6:0" + "src": "261:6:0" } ], - "id": 23, + "id": 27, "name": "VariableDeclaration", - "src": "221:11:0" + "src": "261:11:0" }, { "attributes": { "constant": false, "name": "coinBalance", - "scope": 26, + "scope": 30, "stateVariable": false, "storageLocation": "default", "type": "uint256", @@ -465,25 +536,25 @@ "name": "uint", "type": "uint256" }, - "id": 24, + "id": 28, "name": "ElementaryTypeName", - "src": "238:4:0" + "src": "278:4:0" } ], - "id": 25, + "id": 29, "name": "VariableDeclaration", - "src": "238:16:0" + "src": "278:16:0" } ], - "id": 26, + "id": 30, "name": "StructDefinition", - "src": "203:56:0" + "src": "243:56:0" }, { "attributes": { "constant": false, "name": "addressToUser", - "scope": 100, + "scope": 134, "stateVariable": true, "storageLocation": "default", "type": "mapping(address => struct CapCoin.User storage ref)", @@ -501,36 +572,36 @@ "name": "address", "type": "address" }, - "id": 27, + "id": 31, "name": "ElementaryTypeName", - "src": "272:7:0" + "src": "312:7:0" }, { "attributes": { "contractScope": null, "name": "User", - "referencedDeclaration": 26, + "referencedDeclaration": 30, "type": "struct CapCoin.User storage pointer" }, - "id": 28, + "id": 32, "name": "UserDefinedTypeName", - "src": "283:4:0" + "src": "323:4:0" } ], - "id": 29, + "id": 33, "name": "Mapping", - "src": "263:25:0" + "src": "303:25:0" } ], - "id": 30, + "id": 34, "name": "VariableDeclaration", - "src": "263:46:0" + "src": "303:46:0" }, { "attributes": { "constant": false, "name": "users", - "scope": 100, + "scope": 134, "stateVariable": true, "storageLocation": "default", "type": "address[] storage ref", @@ -549,19 +620,19 @@ "name": "address", "type": "address" }, - "id": 31, + "id": 35, "name": "ElementaryTypeName", - "src": "313:7:0" + "src": "353:7:0" } ], - "id": 32, + "id": 36, "name": "ArrayTypeName", - "src": "313:9:0" + "src": "353:9:0" } ], - "id": 33, + "id": 37, "name": "VariableDeclaration", - "src": "313:22:0" + "src": "353:22:0" }, { "attributes": { @@ -573,7 +644,7 @@ ], "name": "createUser", "payable": false, - "scope": 100, + "scope": 134, "stateMutability": "nonpayable", "superFunction": null, "visibility": "public" @@ -585,7 +656,7 @@ "attributes": { "constant": false, "name": "name", - "scope": 70, + "scope": 74, "stateVariable": false, "storageLocation": "default", "type": "string memory", @@ -598,19 +669,19 @@ "name": "string", "type": "string storage pointer" }, - "id": 34, + "id": 38, "name": "ElementaryTypeName", - "src": "360:6:0" + "src": "400:6:0" } ], - "id": 35, + "id": 39, "name": "VariableDeclaration", - "src": "360:11:0" + "src": "400:11:0" } ], - "id": 36, + "id": 40, "name": "ParameterList", - "src": "359:13:0" + "src": "399:13:0" }, { "attributes": { @@ -619,16 +690,16 @@ ] }, "children": [], - "id": 37, + "id": 41, "name": "ParameterList", - "src": "380:0:0" + "src": "420:0:0" }, { "children": [ { "attributes": { "assignments": [ - 38 + 42 ] }, "children": [ @@ -636,7 +707,7 @@ "attributes": { "constant": false, "name": "user", - "scope": 70, + "scope": 74, "stateVariable": false, "storageLocation": "default", "type": "struct CapCoin.User storage pointer", @@ -645,9 +716,9 @@ "visibility": "internal" }, "children": [], - "id": 38, + "id": 42, "name": "VariableDeclaration", - "src": "386:8:0" + "src": "426:8:0" }, { "attributes": { @@ -665,13 +736,13 @@ "overloadedDeclarations": [ null ], - "referencedDeclaration": 30, + "referencedDeclaration": 34, "type": "mapping(address => struct CapCoin.User storage ref)", "value": "addressToUser" }, - "id": 39, + "id": 43, "name": "Identifier", - "src": "397:13:0" + "src": "437:13:0" }, { "attributes": { @@ -691,28 +762,28 @@ "overloadedDeclarations": [ null ], - "referencedDeclaration": 112, + "referencedDeclaration": 146, "type": "msg", "value": "msg" }, - "id": 40, + "id": 44, "name": "Identifier", - "src": "411:3:0" + "src": "451:3:0" } ], - "id": 41, + "id": 45, "name": "MemberAccess", - "src": "411:10:0" + "src": "451:10:0" } ], - "id": 42, + "id": 46, "name": "IndexAccess", - "src": "397:25:0" + "src": "437:25:0" } ], - "id": 43, + "id": 47, "name": "VariableDeclarationStatement", - "src": "386:36:0" + "src": "426:36:0" }, { "children": [ @@ -735,7 +806,7 @@ "isPure": false, "lValueRequested": true, "member_name": "name", - "referencedDeclaration": 23, + "referencedDeclaration": 27, "type": "string storage ref" }, "children": [ @@ -745,18 +816,18 @@ "overloadedDeclarations": [ null ], - "referencedDeclaration": 38, + "referencedDeclaration": 42, "type": "struct CapCoin.User storage pointer", "value": "user" }, - "id": 44, + "id": 48, "name": "Identifier", - "src": "429:4:0" + "src": "469:4:0" } ], - "id": 46, + "id": 50, "name": "MemberAccess", - "src": "429:9:0" + "src": "469:9:0" }, { "attributes": { @@ -764,23 +835,23 @@ "overloadedDeclarations": [ null ], - "referencedDeclaration": 35, + "referencedDeclaration": 39, "type": "string memory", "value": "name" }, - "id": 47, + "id": 51, "name": "Identifier", - "src": "441:4:0" + "src": "481:4:0" } ], - "id": 48, + "id": 52, "name": "Assignment", - "src": "429:16:0" + "src": "469:16:0" } ], - "id": 49, + "id": 53, "name": "ExpressionStatement", - "src": "429:16:0" + "src": "469:16:0" }, { "children": [ @@ -803,7 +874,7 @@ "isPure": false, "lValueRequested": true, "member_name": "coinBalance", - "referencedDeclaration": 25, + "referencedDeclaration": 29, "type": "uint256" }, "children": [ @@ -813,18 +884,18 @@ "overloadedDeclarations": [ null ], - "referencedDeclaration": 38, + "referencedDeclaration": 42, "type": "struct CapCoin.User storage pointer", "value": "user" }, - "id": 50, + "id": 54, "name": "Identifier", - "src": "451:4:0" + "src": "491:4:0" } ], - "id": 52, + "id": 56, "name": "MemberAccess", - "src": "451:16:0" + "src": "491:16:0" }, { "attributes": { @@ -839,19 +910,19 @@ "type": "int_const 0", "value": "0" }, - "id": 53, + "id": 57, "name": "Literal", - "src": "470:1:0" + "src": "510:1:0" } ], - "id": 54, + "id": 58, "name": "Assignment", - "src": "451:20:0" + "src": "491:20:0" } ], - "id": 55, + "id": 59, "name": "ExpressionStatement", - "src": "451:20:0" + "src": "491:20:0" }, { "children": [ @@ -908,18 +979,18 @@ "overloadedDeclarations": [ null ], - "referencedDeclaration": 33, + "referencedDeclaration": 37, "type": "address[] storage ref", "value": "users" }, - "id": 56, + "id": 60, "name": "Identifier", - "src": "478:5:0" + "src": "518:5:0" } ], - "id": 58, + "id": 62, "name": "MemberAccess", - "src": "478:10:0" + "src": "518:10:0" }, { "attributes": { @@ -939,23 +1010,23 @@ "overloadedDeclarations": [ null ], - "referencedDeclaration": 112, + "referencedDeclaration": 146, "type": "msg", "value": "msg" }, - "id": 59, + "id": 63, "name": "Identifier", - "src": "489:3:0" + "src": "529:3:0" } ], - "id": 60, + "id": 64, "name": "MemberAccess", - "src": "489:10:0" + "src": "529:10:0" } ], - "id": 61, + "id": 65, "name": "FunctionCall", - "src": "478:22:0" + "src": "518:22:0" }, { "attributes": { @@ -970,19 +1041,19 @@ "type": "int_const 1", "value": "1" }, - "id": 62, + "id": 66, "name": "Literal", - "src": "502:1:0" + "src": "542:1:0" } ], - "id": 63, + "id": 67, "name": "BinaryOperation", - "src": "478:25:0" + "src": "518:25:0" } ], - "id": 64, + "id": 68, "name": "ExpressionStatement", - "src": "478:25:0" + "src": "518:25:0" }, { "children": [ @@ -1016,9 +1087,9 @@ "type": "function (string memory)", "value": "NewUser" }, - "id": 65, + "id": 69, "name": "Identifier", - "src": "509:7:0" + "src": "549:7:0" }, { "attributes": { @@ -1026,33 +1097,33 @@ "overloadedDeclarations": [ null ], - "referencedDeclaration": 35, + "referencedDeclaration": 39, "type": "string memory", "value": "name" }, - "id": 66, + "id": 70, "name": "Identifier", - "src": "517:4:0" + "src": "557:4:0" } ], - "id": 67, + "id": 71, "name": "FunctionCall", - "src": "509:13:0" + "src": "549:13:0" } ], - "id": 68, + "id": 72, "name": "ExpressionStatement", - "src": "509:13:0" + "src": "549:13:0" } ], - "id": 69, + "id": 73, "name": "Block", - "src": "380:147:0" + "src": "420:147:0" } ], - "id": 70, + "id": 74, "name": "FunctionDefinition", - "src": "340:187:0" + "src": "380:187:0" }, { "attributes": { @@ -1064,7 +1135,7 @@ ], "name": "getUsers", "payable": false, - "scope": 100, + "scope": 134, "stateMutability": "view", "superFunction": null, "visibility": "public" @@ -1077,9 +1148,9 @@ ] }, "children": [], - "id": 71, + "id": 75, "name": "ParameterList", - "src": "548:2:0" + "src": "588:2:0" }, { "children": [ @@ -1087,7 +1158,7 @@ "attributes": { "constant": false, "name": "", - "scope": 79, + "scope": 83, "stateVariable": false, "storageLocation": "default", "type": "address[] memory", @@ -1106,30 +1177,30 @@ "name": "address", "type": "address" }, - "id": 72, + "id": 76, "name": "ElementaryTypeName", - "src": "572:7:0" + "src": "612:7:0" } ], - "id": 73, + "id": 77, "name": "ArrayTypeName", - "src": "572:9:0" + "src": "612:9:0" } ], - "id": 74, + "id": 78, "name": "VariableDeclaration", - "src": "572:9:0" + "src": "612:9:0" } ], - "id": 75, + "id": 79, "name": "ParameterList", - "src": "571:11:0" + "src": "611:11:0" }, { "children": [ { "attributes": { - "functionReturnParameters": 75 + "functionReturnParameters": 79 }, "children": [ { @@ -1138,28 +1209,28 @@ "overloadedDeclarations": [ null ], - "referencedDeclaration": 33, + "referencedDeclaration": 37, "type": "address[] storage ref", "value": "users" }, - "id": 76, + "id": 80, "name": "Identifier", - "src": "596:5:0" + "src": "636:5:0" } ], - "id": 77, + "id": 81, "name": "Return", - "src": "589:12:0" + "src": "629:12:0" } ], - "id": 78, + "id": 82, "name": "Block", - "src": "583:23:0" + "src": "623:23:0" } ], - "id": 79, + "id": 83, "name": "FunctionDefinition", - "src": "531:75:0" + "src": "571:75:0" }, { "attributes": { @@ -1171,7 +1242,7 @@ ], "name": "getUser", "payable": false, - "scope": 100, + "scope": 134, "stateMutability": "view", "superFunction": null, "visibility": "public" @@ -1184,9 +1255,9 @@ ] }, "children": [], - "id": 80, + "id": 84, "name": "ParameterList", - "src": "626:2:0" + "src": "666:2:0" }, { "children": [ @@ -1194,7 +1265,7 @@ "attributes": { "constant": false, "name": "", - "scope": 99, + "scope": 103, "stateVariable": false, "storageLocation": "default", "type": "string memory", @@ -1207,20 +1278,20 @@ "name": "string", "type": "string storage pointer" }, - "id": 81, + "id": 85, "name": "ElementaryTypeName", - "src": "650:6:0" + "src": "690:6:0" } ], - "id": 82, + "id": 86, "name": "VariableDeclaration", - "src": "650:6:0" + "src": "690:6:0" }, { "attributes": { "constant": false, "name": "", - "scope": 99, + "scope": 103, "stateVariable": false, "storageLocation": "default", "type": "uint256", @@ -1233,25 +1304,25 @@ "name": "uint", "type": "uint256" }, - "id": 83, + "id": 87, "name": "ElementaryTypeName", - "src": "658:4:0" + "src": "698:4:0" } ], - "id": 84, + "id": 88, "name": "VariableDeclaration", - "src": "658:4:0" + "src": "698:4:0" } ], - "id": 85, + "id": 89, "name": "ParameterList", - "src": "649:14:0" + "src": "689:14:0" }, { "children": [ { "attributes": { - "functionReturnParameters": 85 + "functionReturnParameters": 89 }, "children": [ { @@ -1273,7 +1344,7 @@ "isPure": false, "lValueRequested": false, "member_name": "name", - "referencedDeclaration": 23, + "referencedDeclaration": 27, "type": "string storage ref" }, "children": [ @@ -1293,13 +1364,13 @@ "overloadedDeclarations": [ null ], - "referencedDeclaration": 30, + "referencedDeclaration": 34, "type": "mapping(address => struct CapCoin.User storage ref)", "value": "addressToUser" }, - "id": 86, + "id": 90, "name": "Identifier", - "src": "678:13:0" + "src": "718:13:0" }, { "attributes": { @@ -1319,28 +1390,28 @@ "overloadedDeclarations": [ null ], - "referencedDeclaration": 112, + "referencedDeclaration": 146, "type": "msg", "value": "msg" }, - "id": 87, + "id": 91, "name": "Identifier", - "src": "692:3:0" + "src": "732:3:0" } ], - "id": 88, + "id": 92, "name": "MemberAccess", - "src": "692:10:0" + "src": "732:10:0" } ], - "id": 89, + "id": 93, "name": "IndexAccess", - "src": "678:25:0" + "src": "718:25:0" } ], - "id": 90, + "id": 94, "name": "MemberAccess", - "src": "678:30:0" + "src": "718:30:0" }, { "attributes": { @@ -1350,7 +1421,7 @@ "isPure": false, "lValueRequested": false, "member_name": "coinBalance", - "referencedDeclaration": 25, + "referencedDeclaration": 29, "type": "uint256" }, "children": [ @@ -1370,13 +1441,13 @@ "overloadedDeclarations": [ null ], - "referencedDeclaration": 30, + "referencedDeclaration": 34, "type": "mapping(address => struct CapCoin.User storage ref)", "value": "addressToUser" }, - "id": 91, + "id": 95, "name": "Identifier", - "src": "710:13:0" + "src": "750:13:0" }, { "attributes": { @@ -1396,58 +1467,469 @@ "overloadedDeclarations": [ null ], - "referencedDeclaration": 112, + "referencedDeclaration": 146, "type": "msg", "value": "msg" }, - "id": 92, + "id": 96, "name": "Identifier", - "src": "724:3:0" + "src": "764:3:0" } ], - "id": 93, + "id": 97, "name": "MemberAccess", - "src": "724:10:0" + "src": "764:10:0" } ], - "id": 94, + "id": 98, "name": "IndexAccess", - "src": "710:25:0" + "src": "750:25:0" } ], - "id": 95, + "id": 99, "name": "MemberAccess", - "src": "710:37:0" + "src": "750:37:0" } ], - "id": 96, + "id": 100, "name": "TupleExpression", - "src": "677:71:0" + "src": "717:71:0" } ], - "id": 97, + "id": 101, "name": "Return", - "src": "670:78:0" + "src": "710:78:0" + } + ], + "id": 102, + "name": "Block", + "src": "704:89:0" + } + ], + "id": 103, + "name": "FunctionDefinition", + "src": "650:143:0" + }, + { + "attributes": { + "constant": false, + "implemented": true, + "isConstructor": false, + "modifiers": [ + null + ], + "name": "buyTokens", + "payable": false, + "scope": 134, + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + "children": [ + { + "children": [ + { + "attributes": { + "constant": false, + "name": "amount", + "scope": 133, + "stateVariable": false, + "storageLocation": "default", + "type": "uint256", + "value": null, + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "uint", + "type": "uint256" + }, + "id": 104, + "name": "ElementaryTypeName", + "src": "816:4:0" + } + ], + "id": 105, + "name": "VariableDeclaration", + "src": "816:11:0" + } + ], + "id": 106, + "name": "ParameterList", + "src": "815:13:0" + }, + { + "attributes": { + "parameters": [ + null + ] + }, + "children": [], + "id": 107, + "name": "ParameterList", + "src": "836:0:0" + }, + { + "children": [ + { + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "operator": "+=", + "type": "uint256" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": true, + "member_name": "coinBalance", + "referencedDeclaration": 29, + "type": "uint256" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": false, + "type": "struct CapCoin.User storage ref" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 34, + "type": "mapping(address => struct CapCoin.User storage ref)", + "value": "addressToUser" + }, + "id": 108, + "name": "Identifier", + "src": "842:13:0" + }, + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "member_name": "sender", + "referencedDeclaration": null, + "type": "address" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 146, + "type": "msg", + "value": "msg" + }, + "id": 109, + "name": "Identifier", + "src": "856:3:0" + } + ], + "id": 110, + "name": "MemberAccess", + "src": "856:10:0" + } + ], + "id": 111, + "name": "IndexAccess", + "src": "842:25:0" + } + ], + "id": 112, + "name": "MemberAccess", + "src": "842:37:0" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 105, + "type": "uint256", + "value": "amount" + }, + "id": 113, + "name": "Identifier", + "src": "883:6:0" + } + ], + "id": 114, + "name": "Assignment", + "src": "842:47:0" + } + ], + "id": 115, + "name": "ExpressionStatement", + "src": "842:47:0" + }, + { + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "operator": "+=", + "type": "uint256" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 15, + "type": "uint256", + "value": "coinsBought" + }, + "id": 116, + "name": "Identifier", + "src": "895:11:0" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 105, + "type": "uint256", + "value": "amount" + }, + "id": 117, + "name": "Identifier", + "src": "910:6:0" + } + ], + "id": 118, + "name": "Assignment", + "src": "895:21:0" + } + ], + "id": 119, + "name": "ExpressionStatement", + "src": "895:21:0" + }, + { + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "operator": "-=", + "type": "uint256" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 12, + "type": "uint256", + "value": "coinSupply" + }, + "id": 120, + "name": "Identifier", + "src": "922:10:0" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 105, + "type": "uint256", + "value": "amount" + }, + "id": 121, + "name": "Identifier", + "src": "936:6:0" + } + ], + "id": 122, + "name": "Assignment", + "src": "922:20:0" + } + ], + "id": 123, + "name": "ExpressionStatement", + "src": "922:20:0" + }, + { + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "isStructConstructorCall": false, + "lValueRequested": false, + "names": [ + null + ], + "type": "tuple()", + "type_conversion": false + }, + "children": [ + { + "attributes": { + "argumentTypes": [ + { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + ], + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 9, + "type": "function (uint256)", + "value": "BoughtTokens" + }, + "id": 124, + "name": "Identifier", + "src": "948:12:0" + }, + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": false, + "member_name": "coinBalance", + "referencedDeclaration": 29, + "type": "uint256" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": false, + "type": "struct CapCoin.User storage ref" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 34, + "type": "mapping(address => struct CapCoin.User storage ref)", + "value": "addressToUser" + }, + "id": 125, + "name": "Identifier", + "src": "961:13:0" + }, + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "member_name": "sender", + "referencedDeclaration": null, + "type": "address" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 146, + "type": "msg", + "value": "msg" + }, + "id": 126, + "name": "Identifier", + "src": "975:3:0" + } + ], + "id": 127, + "name": "MemberAccess", + "src": "975:10:0" + } + ], + "id": 128, + "name": "IndexAccess", + "src": "961:25:0" + } + ], + "id": 129, + "name": "MemberAccess", + "src": "961:37:0" + } + ], + "id": 130, + "name": "FunctionCall", + "src": "948:51:0" + } + ], + "id": 131, + "name": "ExpressionStatement", + "src": "948:51:0" } ], - "id": 98, + "id": 132, "name": "Block", - "src": "664:89:0" + "src": "836:168:0" } ], - "id": 99, + "id": 133, "name": "FunctionDefinition", - "src": "610:143:0" + "src": "797:207:0" } ], - "id": 100, + "id": 134, "name": "ContractDefinition", - "src": "26:729:0" + "src": "26:980:0" } ], - "id": 101, + "id": 135, "name": "SourceUnit", - "src": "0:756:0" + "src": "0:1007:0" }, "compiler": { "name": "solc", @@ -1461,5 +1943,5 @@ } }, "schemaVersion": "1.0.1", - "updatedAt": "2018-01-18T21:15:28.082Z" + "updatedAt": "2018-01-18T21:50:57.977Z" } \ No newline at end of file diff --git a/build/contracts/Migrations.json b/build/contracts/Migrations.json index 4211d134..f4950e39 100644 --- a/build/contracts/Migrations.json +++ b/build/contracts/Migrations.json @@ -823,5 +823,5 @@ } }, "schemaVersion": "1.0.1", - "updatedAt": "2018-01-18T21:15:28.084Z" + "updatedAt": "2018-01-18T21:50:57.978Z" } \ No newline at end of file diff --git a/build/contracts/SimpleStorage.json b/build/contracts/SimpleStorage.json index 098bf725..153dab28 100644 --- a/build/contracts/SimpleStorage.json +++ b/build/contracts/SimpleStorage.json @@ -344,5 +344,5 @@ } }, "schemaVersion": "1.0.1", - "updatedAt": "2018-01-18T21:15:28.081Z" + "updatedAt": "2018-01-18T21:50:57.975Z" } \ No newline at end of file diff --git a/contracts/CapCoin.sol b/contracts/CapCoin.sol index 897a028d..8fdd7eba 100644 --- a/contracts/CapCoin.sol +++ b/contracts/CapCoin.sol @@ -3,6 +3,7 @@ pragma solidity ^0.4.18; contract CapCoin { event NewUser(string name); + event BoughtTokens(uint coinBalance); uint coinSupply = 1000000; uint coinsBought = 0; @@ -37,4 +38,11 @@ contract CapCoin { function getUser() public view returns (string, uint) { return (addressToUser[msg.sender].name, addressToUser[msg.sender].coinBalance); } + + function buyTokens(uint amount) public { + addressToUser[msg.sender].coinBalance += amount; + coinsBought += amount; + coinSupply -= amount; + BoughtTokens(addressToUser[msg.sender].coinBalance); + } } diff --git a/src/components/Exchange.js b/src/components/Exchange.js index 8d5ae5f7..0c08d219 100644 --- a/src/components/Exchange.js +++ b/src/components/Exchange.js @@ -1,24 +1,60 @@ import React, {Component} from 'react' import {connect} from 'react-redux' +import SelectField from 'material-ui/SelectField'; +import MenuItem from 'material-ui/MenuItem'; +import RaisedButton from 'material-ui/RaisedButton'; +import { buyTokens } from '../store/user'; -const Exchange = props => ( -
-

Buy Tokens

-
- ) +class Exchange extends Component { + + constructor(props) { + super(props); + this.state = {value: 1}; + } + + handleChange = (event, index, value) => this.setState({value}); + + render() { + return ( +
+

Buy Tokens

+ + + + + + + + + + this.props.buyTokens(e, this.state.value, this.props.contract.buyTokens, this.props.accounts[0])} + label="Buy Tokens" primary={true} + /> +
+ ); + } +} -/** - * CONTAINER - */ const mapState = (state) => { return { user: state.user, - contract: state.contract + contract: state.contract, + accounts: state.accounts } } const mapDispatch = (dispatch) => { - return {} + return { + buyTokens: function(e, amount, contractFunc, account){ + e.preventDefault() + return dispatch(buyTokens(amount, contractFunc, account)) + } + } } export default connect(mapState, mapDispatch)(Exchange) diff --git a/src/components/Profile.js b/src/components/Profile.js index 4f7dc3b0..d54fad07 100644 --- a/src/components/Profile.js +++ b/src/components/Profile.js @@ -1,11 +1,17 @@ import React from 'react' import {connect} from 'react-redux' import LoadingIndicator from 'react-loading-indicator'; +import { Link } from 'react-router-dom'; const Profile = props => (
{props.user ? -

Welcome {props.user.name}

+
+

Welcome {props.user.name}

+

You currently have {props.user.coinBalance} Tokens
+ Buy More +

+
: } diff --git a/src/store/user.js b/src/store/user.js index 79e8d23a..8da2ed2e 100644 --- a/src/store/user.js +++ b/src/store/user.js @@ -8,16 +8,18 @@ const defaultUser = {} */ const GET_USER = 'GET_USER'; const CREATE_USER = 'CREATE_USER'; +const BUY_TOKENS = 'BUY_TOKENS'; /** * ACTION CREATORS */ const getUser = user => ({type: GET_USER, user}) const createUser = user => ({type: CREATE_USER, user}) +const boughtTokens = amount => ({type: BUY_TOKENS, amount}) + /** * THUNK CREATORS */ - export const fetchUser = (contractFunc, account) => dispatch => contractFunc.call({from: account}) @@ -32,11 +34,14 @@ export const fetchUser = (contractFunc, account) => export const addUser = (name, contractFunc, account) => dispatch => contractFunc(name, {from: account}) - .then(res => { + .then(res => dispatch(createUser(res.logs[0].args))) + .catch(err => console.log(err)); - console.log(res) - dispatch(createUser(res.logs[0].args))}) - .catch(err => console.log(err)) +export const buyTokens = (amount, contractFunc, account) => + dispatch => + contractFunc(amount, {from: account}) + .then(res => dispatch(boughtTokens(res.logs[0].args.coinBalance.c[0]))) + .catch(err => console.log(err)); /** * REDUCER @@ -47,6 +52,8 @@ export default function (state = defaultUser, action) { return action.user; case CREATE_USER: return action.user; + case BUY_TOKENS: + return Object.assign({}, state, {coinBalance: action.amount}) default: return state }