diff --git a/Betting Contract/contracts/betting.sol b/Betting Contract/contracts/betting.sol index fb3bb1f..74d08c1 100644 --- a/Betting Contract/contracts/betting.sol +++ b/Betting Contract/contracts/betting.sol @@ -4,6 +4,8 @@ pragma solidity 0.4.19; contract Betting { /* Constructor function, where owner and outcomes are set */ function Betting(uint[] _outcomes) public { + owner = msg.sender; + } /* Fallback function */ @@ -30,41 +32,134 @@ contract Betting { mapping (address => uint) winnings; /* Keep track of all outcomes (maps index to numerical outcome) */ mapping (uint => uint) public outcomes; + uint outLen; /* Add any events you think are necessary */ event BetMade(address gambler); event BetClosed(); + event oracleSet(); /* Uh Oh, what are these? */ - modifier ownerOnly() {_;} - modifier oracleOnly() {_;} - modifier outcomeExists(uint outcome) {_;} + modifier ownerOnly() { + require (msg.sender == owner); + _; + } + + modifier oracleOnly() { + require (msg.sender == oracle); + _; + } + + modifier outcomeExists(uint outcome) { + uint outcomeNum = 0; + while (outcomeNum++ && outcomeNum < outLen) { + if (outcomes[outcomeNum] == outcome) { + _; + } + } + + + } /* Owner chooses their trusted Oracle */ function chooseOracle(address _oracle) public ownerOnly() returns (address) { + require (_oracle != gamblerA); + require (_oracle != gamblerB); + oracle = _oracle; + + oracleSet(); + return oracle; + } /* Gamblers place their bets, preferably after calling checkOutcomes */ function makeBet(uint _outcome) public payable returns (bool) { + require (msg.sender != oracle); + require (bets[msg.sender] == false); + + if (bets[gamblerA].initialized) { + bets[msg.sender] = Bet(_outcome,msg.value,true); + outLen+=1; + gamblerB = msg.sender; + BetMade(gamblerB); + return true; + } + + else if (bets[gamblerB].initialized) { + bets[msg.sender] = Bet(_outcome,msg.value,true); + outLen+=1; + gamblerA = msg.sender; + BetMade(gamblerA); + return true; + } + else { + return false; + } + } /* The oracle chooses which outcome wins */ function makeDecision(uint _outcome) public oracleOnly() outcomeExists(_outcome) { + require(oracleOnly()); + require(bets[gamblerA].initialized); + require(bets[gamblerB].initialized); + + if (bets[gamblerA].outcome == bets[gamblerB].outcome) { + winnings[gamblerA] += bets[gamblerA].amount; + winnings[gamblerB] += bets[gamblerB].amount; + + } + else if (bets[gamblerA].outcome == _outcome) { + winnings[gamblerA] += bets[gamblerA].amount + bets[gamblerB].amount; + + } + + else if (bets[gamblerB].outcome == _outcome) { + winnings[gamblerB] += bets[gamblerA].amount + bets[gamblerB].amount; + + } + else { + winnings[oracle] += bets[gamblerA].amount + bets[gamblerB].amount; + } + + contractReset(); } /* Allow anyone to withdraw their winnings safely (if they have enough) */ function withdraw(uint withdrawAmount) public returns (uint) { + require (winnings[msg.sender] >= withdrawAmount); + + + winnings[msg.sender] -= withdrawAmount; + if (msg.sender.send(withdrawAmount)) { + return winnings[msg.sender]; + } + else { + winnings[msg.sender] += withdrawAmount; + return winnings[msg.sender]; //cant return -1 bc uint??? return this instead + } + + } /* Allow anyone to check the outcomes they can bet on */ function checkOutcomes(uint outcome) public view returns (uint) { + return outcomes[outcome]; } /* Allow anyone to check if they won any bets */ function checkWinnings() public view returns(uint) { + return winnings[msg.sender]; } /* Call delete() to reset certain state variables. Which ones? That's upto you to decide */ function contractReset() public ownerOnly() { + delete gamblerA; + delete gamblerB; + delete oracle; + delete bets[gamblerA]; + delete bets[gamblerB]; + + BetClosed(); } } diff --git a/Intro to Solidity/build/contracts/Concatenate.json b/Intro to Solidity/build/contracts/Concatenate.json new file mode 100644 index 0000000..483749c --- /dev/null +++ b/Intro to Solidity/build/contracts/Concatenate.json @@ -0,0 +1,1321 @@ +{ + "contractName": "Concatenate", + "abi": [ + { + "constant": true, + "inputs": [ + { + "name": "str1", + "type": "string" + }, + { + "name": "str2", + "type": "string" + } + ], + "name": "concatWithoutImport", + "outputs": [ + { + "name": "", + "type": "string" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + } + ], + "bytecode": "0x6060604052341561000f57600080fd5b6103868061001e6000396000f300606060405260043610610041576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806334d1460b14610046575b600080fd5b341561005157600080fd5b6100e4600480803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509190505061015f565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610124578082015181840152602081019050610109565b50505050905090810190601f1680156101515780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b610167610332565b61016f610346565b610177610346565b61017f610332565b610187610346565b60008088955087945084518651016040518059106101a25750595b9080825280601f01601f19166020018201604052509350839250600091505b855182101561026e5785828151811015156101d857fe5b9060200101517f010000000000000000000000000000000000000000000000000000000000000090047f010000000000000000000000000000000000000000000000000000000000000002838381518110151561023157fe5b9060200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535081806001019250506101c1565b600090505b845181101561032357848181518110151561028a57fe5b9060200101517f010000000000000000000000000000000000000000000000000000000000000090047f01000000000000000000000000000000000000000000000000000000000000000283828851018151811015156102e657fe5b9060200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508080600101915050610273565b82965050505050505092915050565b602060405190810160405280600081525090565b6020604051908101604052806000815250905600a165627a7a72305820105477eb69e078c2aab366a30aa8119fc2256cb8994111e68a888a0e2a3cf10d0029", + "deployedBytecode": "0x606060405260043610610041576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806334d1460b14610046575b600080fd5b341561005157600080fd5b6100e4600480803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509190505061015f565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610124578082015181840152602081019050610109565b50505050905090810190601f1680156101515780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b610167610332565b61016f610346565b610177610346565b61017f610332565b610187610346565b60008088955087945084518651016040518059106101a25750595b9080825280601f01601f19166020018201604052509350839250600091505b855182101561026e5785828151811015156101d857fe5b9060200101517f010000000000000000000000000000000000000000000000000000000000000090047f010000000000000000000000000000000000000000000000000000000000000002838381518110151561023157fe5b9060200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535081806001019250506101c1565b600090505b845181101561032357848181518110151561028a57fe5b9060200101517f010000000000000000000000000000000000000000000000000000000000000090047f01000000000000000000000000000000000000000000000000000000000000000283828851018151811015156102e657fe5b9060200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508080600101915050610273565b82965050505050505092915050565b602060405190810160405280600081525090565b6020604051908101604052806000815250905600a165627a7a72305820105477eb69e078c2aab366a30aa8119fc2256cb8994111e68a888a0e2a3cf10d0029", + "sourceMap": "25:517:1:-;;;;;;;;;;;;;;;;;", + "deployedSourceMap": "25:517:1:-;;;;;;;;;;;;;;;;;;;;;;;;57:478;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;57:478:1;137:6;;:::i;:::-;155:18;;:::i;:::-;197;;:::i;:::-;239;;:::i;:::-;309:19;;:::i;:::-;357:6;427;182:4;155:32;;224:4;197:32;;286:5;:12;271:5;:12;:27;260:39;;;;;;;;;;;;;;;;;;;;;;;;;;;239:60;;337:4;309:33;;366:1;357:10;;352:60;373:5;:12;369:1;:16;352:60;;;404:5;410:1;404:8;;;;;;;;;;;;;;;;;;;;392:6;399:1;392:9;;;;;;;;;;;;;;:20;;;;;;;;;;;387:3;;;;;;;352:60;;;436:1;427:10;;422:75;443:5;:12;439:1;:16;422:75;;;489:5;495:1;489:8;;;;;;;;;;;;;;;;;;;;462:6;484:1;469:5;:12;:16;462:24;;;;;;;;;;;;;;:35;;;;;;;;;;;457:3;;;;;;;422:75;;;521:6;507:21;;57:478;;;;;;;;;;:::o;25:517::-;;;;;;;;;;;;;;;:::o;:::-;;;;;;;;;;;;;;;:::o", + "source": "pragma solidity 0.4.19;\n\ncontract Concatenate {\n \n function concatWithoutImport(string str1, string str2) public constant returns (string) {\n bytes memory _str1 = bytes(str1);\n bytes memory _str2 = bytes(str2);\n string memory _str = new string(_str1.length + _str2.length);\n bytes memory result = bytes(_str);\n for (uint i = 0; i < _str1.length; i++) result[i] = _str1[i];\n for (uint k = 0; k < _str2.length; k++) result[_str1.length + k] = _str2[k];\n return string(result);\n }\n \n}\n", + "sourcePath": "/Users/adithyaj/Google Drive/berkeley/babDev/lab2/Intro to Solidity/contracts/concatenate.sol", + "ast": { + "attributes": { + "absolutePath": "/Users/adithyaj/Google Drive/berkeley/babDev/lab2/Intro to Solidity/contracts/concatenate.sol", + "exportedSymbols": { + "Concatenate": [ + 145 + ] + } + }, + "children": [ + { + "attributes": { + "literals": [ + "solidity", + "0.4", + ".19" + ] + }, + "id": 58, + "name": "PragmaDirective", + "src": "0:23:1" + }, + { + "attributes": { + "baseContracts": [ + null + ], + "contractDependencies": [ + null + ], + "contractKind": "contract", + "documentation": null, + "fullyImplemented": true, + "linearizedBaseContracts": [ + 145 + ], + "name": "Concatenate", + "scope": 146 + }, + "children": [ + { + "attributes": { + "constant": true, + "implemented": true, + "isConstructor": false, + "modifiers": [ + null + ], + "name": "concatWithoutImport", + "payable": false, + "scope": 145, + "stateMutability": "view", + "superFunction": null, + "visibility": "public" + }, + "children": [ + { + "children": [ + { + "attributes": { + "constant": false, + "name": "str1", + "scope": 144, + "stateVariable": false, + "storageLocation": "default", + "type": "string memory", + "value": null, + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "string", + "type": "string storage pointer" + }, + "id": 59, + "name": "ElementaryTypeName", + "src": "86:6:1" + } + ], + "id": 60, + "name": "VariableDeclaration", + "src": "86:11:1" + }, + { + "attributes": { + "constant": false, + "name": "str2", + "scope": 144, + "stateVariable": false, + "storageLocation": "default", + "type": "string memory", + "value": null, + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "string", + "type": "string storage pointer" + }, + "id": 61, + "name": "ElementaryTypeName", + "src": "99:6:1" + } + ], + "id": 62, + "name": "VariableDeclaration", + "src": "99:11:1" + } + ], + "id": 63, + "name": "ParameterList", + "src": "85:26:1" + }, + { + "children": [ + { + "attributes": { + "constant": false, + "name": "", + "scope": 144, + "stateVariable": false, + "storageLocation": "default", + "type": "string memory", + "value": null, + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "string", + "type": "string storage pointer" + }, + "id": 64, + "name": "ElementaryTypeName", + "src": "137:6:1" + } + ], + "id": 65, + "name": "VariableDeclaration", + "src": "137:6:1" + } + ], + "id": 66, + "name": "ParameterList", + "src": "136:8:1" + }, + { + "children": [ + { + "attributes": { + "assignments": [ + 68 + ] + }, + "children": [ + { + "attributes": { + "constant": false, + "name": "_str1", + "scope": 144, + "stateVariable": false, + "storageLocation": "memory", + "type": "bytes memory", + "value": null, + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "bytes", + "type": "bytes storage pointer" + }, + "id": 67, + "name": "ElementaryTypeName", + "src": "155:5:1" + } + ], + "id": 68, + "name": "VariableDeclaration", + "src": "155:18:1" + }, + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "isStructConstructorCall": false, + "lValueRequested": false, + "names": [ + null + ], + "type": "bytes memory", + "type_conversion": true + }, + "children": [ + { + "attributes": { + "argumentTypes": [ + { + "typeIdentifier": "t_string_memory_ptr", + "typeString": "string memory" + } + ], + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "type": "type(bytes storage pointer)", + "value": "bytes" + }, + "id": 69, + "name": "ElementaryTypeNameExpression", + "src": "176:5:1" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 60, + "type": "string memory", + "value": "str1" + }, + "id": 70, + "name": "Identifier", + "src": "182:4:1" + } + ], + "id": 71, + "name": "FunctionCall", + "src": "176:11:1" + } + ], + "id": 72, + "name": "VariableDeclarationStatement", + "src": "155:32:1" + }, + { + "attributes": { + "assignments": [ + 74 + ] + }, + "children": [ + { + "attributes": { + "constant": false, + "name": "_str2", + "scope": 144, + "stateVariable": false, + "storageLocation": "memory", + "type": "bytes memory", + "value": null, + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "bytes", + "type": "bytes storage pointer" + }, + "id": 73, + "name": "ElementaryTypeName", + "src": "197:5:1" + } + ], + "id": 74, + "name": "VariableDeclaration", + "src": "197:18:1" + }, + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "isStructConstructorCall": false, + "lValueRequested": false, + "names": [ + null + ], + "type": "bytes memory", + "type_conversion": true + }, + "children": [ + { + "attributes": { + "argumentTypes": [ + { + "typeIdentifier": "t_string_memory_ptr", + "typeString": "string memory" + } + ], + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "type": "type(bytes storage pointer)", + "value": "bytes" + }, + "id": 75, + "name": "ElementaryTypeNameExpression", + "src": "218:5:1" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 62, + "type": "string memory", + "value": "str2" + }, + "id": 76, + "name": "Identifier", + "src": "224:4:1" + } + ], + "id": 77, + "name": "FunctionCall", + "src": "218:11:1" + } + ], + "id": 78, + "name": "VariableDeclarationStatement", + "src": "197:32:1" + }, + { + "attributes": { + "assignments": [ + 80 + ] + }, + "children": [ + { + "attributes": { + "constant": false, + "name": "_str", + "scope": 144, + "stateVariable": false, + "storageLocation": "memory", + "type": "string memory", + "value": null, + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "string", + "type": "string storage pointer" + }, + "id": 79, + "name": "ElementaryTypeName", + "src": "239:6:1" + } + ], + "id": 80, + "name": "VariableDeclaration", + "src": "239:18:1" + }, + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "isStructConstructorCall": false, + "lValueRequested": false, + "names": [ + null + ], + "type": "string memory", + "type_conversion": false + }, + "children": [ + { + "attributes": { + "argumentTypes": [ + { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + ], + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "type": "function (uint256) pure returns (string memory)" + }, + "children": [ + { + "attributes": { + "name": "string", + "type": "string storage pointer" + }, + "id": 81, + "name": "ElementaryTypeName", + "src": "264:6:1" + } + ], + "id": 82, + "name": "NewExpression", + "src": "260:10:1" + }, + { + "attributes": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "operator": "+", + "type": "uint256" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "member_name": "length", + "referencedDeclaration": null, + "type": "uint256" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 68, + "type": "bytes memory", + "value": "_str1" + }, + "id": 83, + "name": "Identifier", + "src": "271:5:1" + } + ], + "id": 84, + "name": "MemberAccess", + "src": "271:12:1" + }, + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "member_name": "length", + "referencedDeclaration": null, + "type": "uint256" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 74, + "type": "bytes memory", + "value": "_str2" + }, + "id": 85, + "name": "Identifier", + "src": "286:5:1" + } + ], + "id": 86, + "name": "MemberAccess", + "src": "286:12:1" + } + ], + "id": 87, + "name": "BinaryOperation", + "src": "271:27:1" + } + ], + "id": 88, + "name": "FunctionCall", + "src": "260:39:1" + } + ], + "id": 89, + "name": "VariableDeclarationStatement", + "src": "239:60:1" + }, + { + "attributes": { + "assignments": [ + 91 + ] + }, + "children": [ + { + "attributes": { + "constant": false, + "name": "result", + "scope": 144, + "stateVariable": false, + "storageLocation": "memory", + "type": "bytes memory", + "value": null, + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "bytes", + "type": "bytes storage pointer" + }, + "id": 90, + "name": "ElementaryTypeName", + "src": "309:5:1" + } + ], + "id": 91, + "name": "VariableDeclaration", + "src": "309:19:1" + }, + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "isStructConstructorCall": false, + "lValueRequested": false, + "names": [ + null + ], + "type": "bytes memory", + "type_conversion": true + }, + "children": [ + { + "attributes": { + "argumentTypes": [ + { + "typeIdentifier": "t_string_memory_ptr", + "typeString": "string memory" + } + ], + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "type": "type(bytes storage pointer)", + "value": "bytes" + }, + "id": 92, + "name": "ElementaryTypeNameExpression", + "src": "331:5:1" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 80, + "type": "string memory", + "value": "_str" + }, + "id": 93, + "name": "Identifier", + "src": "337:4:1" + } + ], + "id": 94, + "name": "FunctionCall", + "src": "331:11:1" + } + ], + "id": 95, + "name": "VariableDeclarationStatement", + "src": "309:33:1" + }, + { + "children": [ + { + "attributes": { + "assignments": [ + 97 + ] + }, + "children": [ + { + "attributes": { + "constant": false, + "name": "i", + "scope": 144, + "stateVariable": false, + "storageLocation": "default", + "type": "uint256", + "value": null, + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "uint", + "type": "uint256" + }, + "id": 96, + "name": "ElementaryTypeName", + "src": "357:4:1" + } + ], + "id": 97, + "name": "VariableDeclaration", + "src": "357:6:1" + }, + { + "attributes": { + "argumentTypes": null, + "hexvalue": "30", + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "subdenomination": null, + "token": "number", + "type": "int_const 0", + "value": "0" + }, + "id": 98, + "name": "Literal", + "src": "366:1:1" + } + ], + "id": 99, + "name": "VariableDeclarationStatement", + "src": "357:10:1" + }, + { + "attributes": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "operator": "<", + "type": "bool" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 97, + "type": "uint256", + "value": "i" + }, + "id": 100, + "name": "Identifier", + "src": "369:1:1" + }, + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "member_name": "length", + "referencedDeclaration": null, + "type": "uint256" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 68, + "type": "bytes memory", + "value": "_str1" + }, + "id": 101, + "name": "Identifier", + "src": "373:5:1" + } + ], + "id": 102, + "name": "MemberAccess", + "src": "373:12:1" + } + ], + "id": 103, + "name": "BinaryOperation", + "src": "369:16:1" + }, + { + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "operator": "++", + "prefix": false, + "type": "uint256" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 97, + "type": "uint256", + "value": "i" + }, + "id": 104, + "name": "Identifier", + "src": "387:1:1" + } + ], + "id": 105, + "name": "UnaryOperation", + "src": "387:3:1" + } + ], + "id": 106, + "name": "ExpressionStatement", + "src": "387:3:1" + }, + { + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "operator": "=", + "type": "bytes1" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": true, + "type": "bytes1" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 91, + "type": "bytes memory", + "value": "result" + }, + "id": 107, + "name": "Identifier", + "src": "392:6:1" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 97, + "type": "uint256", + "value": "i" + }, + "id": 108, + "name": "Identifier", + "src": "399:1:1" + } + ], + "id": 109, + "name": "IndexAccess", + "src": "392:9:1" + }, + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": false, + "type": "bytes1" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 68, + "type": "bytes memory", + "value": "_str1" + }, + "id": 110, + "name": "Identifier", + "src": "404:5:1" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 97, + "type": "uint256", + "value": "i" + }, + "id": 111, + "name": "Identifier", + "src": "410:1:1" + } + ], + "id": 112, + "name": "IndexAccess", + "src": "404:8:1" + } + ], + "id": 113, + "name": "Assignment", + "src": "392:20:1" + } + ], + "id": 114, + "name": "ExpressionStatement", + "src": "392:20:1" + } + ], + "id": 115, + "name": "ForStatement", + "src": "352:60:1" + }, + { + "children": [ + { + "attributes": { + "assignments": [ + 117 + ] + }, + "children": [ + { + "attributes": { + "constant": false, + "name": "k", + "scope": 144, + "stateVariable": false, + "storageLocation": "default", + "type": "uint256", + "value": null, + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "uint", + "type": "uint256" + }, + "id": 116, + "name": "ElementaryTypeName", + "src": "427:4:1" + } + ], + "id": 117, + "name": "VariableDeclaration", + "src": "427:6:1" + }, + { + "attributes": { + "argumentTypes": null, + "hexvalue": "30", + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "subdenomination": null, + "token": "number", + "type": "int_const 0", + "value": "0" + }, + "id": 118, + "name": "Literal", + "src": "436:1:1" + } + ], + "id": 119, + "name": "VariableDeclarationStatement", + "src": "427:10:1" + }, + { + "attributes": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "operator": "<", + "type": "bool" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 117, + "type": "uint256", + "value": "k" + }, + "id": 120, + "name": "Identifier", + "src": "439:1:1" + }, + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "member_name": "length", + "referencedDeclaration": null, + "type": "uint256" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 74, + "type": "bytes memory", + "value": "_str2" + }, + "id": 121, + "name": "Identifier", + "src": "443:5:1" + } + ], + "id": 122, + "name": "MemberAccess", + "src": "443:12:1" + } + ], + "id": 123, + "name": "BinaryOperation", + "src": "439:16:1" + }, + { + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "operator": "++", + "prefix": false, + "type": "uint256" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 117, + "type": "uint256", + "value": "k" + }, + "id": 124, + "name": "Identifier", + "src": "457:1:1" + } + ], + "id": 125, + "name": "UnaryOperation", + "src": "457:3:1" + } + ], + "id": 126, + "name": "ExpressionStatement", + "src": "457:3:1" + }, + { + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "operator": "=", + "type": "bytes1" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": true, + "type": "bytes1" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 91, + "type": "bytes memory", + "value": "result" + }, + "id": 127, + "name": "Identifier", + "src": "462:6:1" + }, + { + "attributes": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "operator": "+", + "type": "uint256" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "member_name": "length", + "referencedDeclaration": null, + "type": "uint256" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 68, + "type": "bytes memory", + "value": "_str1" + }, + "id": 128, + "name": "Identifier", + "src": "469:5:1" + } + ], + "id": 129, + "name": "MemberAccess", + "src": "469:12:1" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 117, + "type": "uint256", + "value": "k" + }, + "id": 130, + "name": "Identifier", + "src": "484:1:1" + } + ], + "id": 131, + "name": "BinaryOperation", + "src": "469:16:1" + } + ], + "id": 132, + "name": "IndexAccess", + "src": "462:24:1" + }, + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": false, + "type": "bytes1" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 74, + "type": "bytes memory", + "value": "_str2" + }, + "id": 133, + "name": "Identifier", + "src": "489:5:1" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 117, + "type": "uint256", + "value": "k" + }, + "id": 134, + "name": "Identifier", + "src": "495:1:1" + } + ], + "id": 135, + "name": "IndexAccess", + "src": "489:8:1" + } + ], + "id": 136, + "name": "Assignment", + "src": "462:35:1" + } + ], + "id": 137, + "name": "ExpressionStatement", + "src": "462:35:1" + } + ], + "id": 138, + "name": "ForStatement", + "src": "422:75:1" + }, + { + "attributes": { + "functionReturnParameters": 66 + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "isStructConstructorCall": false, + "lValueRequested": false, + "names": [ + null + ], + "type": "string memory", + "type_conversion": true + }, + "children": [ + { + "attributes": { + "argumentTypes": [ + { + "typeIdentifier": "t_bytes_memory_ptr", + "typeString": "bytes memory" + } + ], + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "type": "type(string storage pointer)", + "value": "string" + }, + "id": 139, + "name": "ElementaryTypeNameExpression", + "src": "514:6:1" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 91, + "type": "bytes memory", + "value": "result" + }, + "id": 140, + "name": "Identifier", + "src": "521:6:1" + } + ], + "id": 141, + "name": "FunctionCall", + "src": "514:14:1" + } + ], + "id": 142, + "name": "Return", + "src": "507:21:1" + } + ], + "id": 143, + "name": "Block", + "src": "145:390:1" + } + ], + "id": 144, + "name": "FunctionDefinition", + "src": "57:478:1" + } + ], + "id": 145, + "name": "ContractDefinition", + "src": "25:517:1" + } + ], + "id": 146, + "name": "SourceUnit", + "src": "0:543:1" + }, + "compiler": { + "name": "solc", + "version": "0.4.19+commit.c4cbbb05.Emscripten.clang" + }, + "networks": { + "1519292400608": { + "events": {}, + "links": {}, + "address": "0x1d6f245021da435ef7b02821e10888c748af0441" + } + }, + "schemaVersion": "1.0.1", + "updatedAt": "2018-02-22T09:55:38.789Z" +} \ No newline at end of file diff --git a/Intro to Solidity/build/contracts/Greeter.json b/Intro to Solidity/build/contracts/Greeter.json new file mode 100644 index 0000000..65c59a0 --- /dev/null +++ b/Intro to Solidity/build/contracts/Greeter.json @@ -0,0 +1,344 @@ +{ + "contractName": "Greeter", + "abi": [ + { + "inputs": [ + { + "name": "_greeter", + "type": "string" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "constant": true, + "inputs": [], + "name": "greet", + "outputs": [ + { + "name": "", + "type": "string" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + } + ], + "bytecode": "0x6060604052341561000f57600080fd5b6040516102b83803806102b8833981016040528080518201919050508060009080519060200190610041929190610048565b50506100ed565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061008957805160ff19168380011785556100b7565b828001600101855582156100b7579182015b828111156100b657825182559160200191906001019061009b565b5b5090506100c491906100c8565b5090565b6100ea91905b808211156100e65760008160009055506001016100ce565b5090565b90565b6101bc806100fc6000396000f300606060405260043610610041576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063cfae321714610046575b600080fd5b341561005157600080fd5b6100596100d4565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561009957808201518184015260208101905061007e565b50505050905090810190601f1680156100c65780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6100dc61017c565b60008054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156101725780601f1061014757610100808354040283529160200191610172565b820191906000526020600020905b81548152906001019060200180831161015557829003601f168201915b5050505050905090565b6020604051908101604052806000815250905600a165627a7a7230582085da4cc749930efbe5e8b49862363ae8ee3dbf99b2b4e96f0d6422d88688d02f0029", + "deployedBytecode": "0x606060405260043610610041576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063cfae321714610046575b600080fd5b341561005157600080fd5b6100596100d4565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561009957808201518184015260208101905061007e565b50505050905090810190601f1680156100c65780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6100dc61017c565b60008054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156101725780601f1061014757610100808354040283529160200191610172565b820191906000526020600020905b81548152906001019060200180831161015557829003601f168201915b5050505050905090565b6020604051908101604052806000815250905600a165627a7a7230582085da4cc749930efbe5e8b49862363ae8ee3dbf99b2b4e96f0d6422d88688d02f0029", + "sourceMap": "25:240:3:-;;;83:77;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;145:8;134;:19;;;;;;;;;;;;:::i;:::-;;83:77;25:240;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;:::o;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;:::-;;;;;;;", + "deployedSourceMap": "25:240:3:-;;;;;;;;;;;;;;;;;;;;;;;;170:78;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;170:78:3;208:6;;:::i;:::-;233:8;226:15;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;170:78;:::o;25:240::-;;;;;;;;;;;;;;;:::o", + "source": "pragma solidity 0.4.19;\n\ncontract Greeter {\n\n string private greeting;\n \n function Greeter(string _greeter) public {\n greeting = _greeter;\n }\n \n function greet() public view returns (string) {\n return greeting;\n }\n \n \n \n}\n", + "sourcePath": "/Users/adithyaj/Google Drive/berkeley/babDev/lab2/Intro to Solidity/contracts/greeter.sol", + "ast": { + "attributes": { + "absolutePath": "/Users/adithyaj/Google Drive/berkeley/babDev/lab2/Intro to Solidity/contracts/greeter.sol", + "exportedSymbols": { + "Greeter": [ + 211 + ] + } + }, + "children": [ + { + "attributes": { + "literals": [ + "solidity", + "0.4", + ".19" + ] + }, + "id": 190, + "name": "PragmaDirective", + "src": "0:23:3" + }, + { + "attributes": { + "baseContracts": [ + null + ], + "contractDependencies": [ + null + ], + "contractKind": "contract", + "documentation": null, + "fullyImplemented": true, + "linearizedBaseContracts": [ + 211 + ], + "name": "Greeter", + "scope": 212 + }, + "children": [ + { + "attributes": { + "constant": false, + "name": "greeting", + "scope": 211, + "stateVariable": true, + "storageLocation": "default", + "type": "string storage ref", + "value": null, + "visibility": "private" + }, + "children": [ + { + "attributes": { + "name": "string", + "type": "string storage pointer" + }, + "id": 191, + "name": "ElementaryTypeName", + "src": "49:6:3" + } + ], + "id": 192, + "name": "VariableDeclaration", + "src": "49:23:3" + }, + { + "attributes": { + "constant": false, + "implemented": true, + "isConstructor": true, + "modifiers": [ + null + ], + "name": "Greeter", + "payable": false, + "scope": 211, + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + "children": [ + { + "children": [ + { + "attributes": { + "constant": false, + "name": "_greeter", + "scope": 202, + "stateVariable": false, + "storageLocation": "default", + "type": "string memory", + "value": null, + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "string", + "type": "string storage pointer" + }, + "id": 193, + "name": "ElementaryTypeName", + "src": "100:6:3" + } + ], + "id": 194, + "name": "VariableDeclaration", + "src": "100:15:3" + } + ], + "id": 195, + "name": "ParameterList", + "src": "99:17:3" + }, + { + "attributes": { + "parameters": [ + null + ] + }, + "children": [], + "id": 196, + "name": "ParameterList", + "src": "124:0:3" + }, + { + "children": [ + { + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "operator": "=", + "type": "string storage ref" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 192, + "type": "string storage ref", + "value": "greeting" + }, + "id": 197, + "name": "Identifier", + "src": "134:8:3" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 194, + "type": "string memory", + "value": "_greeter" + }, + "id": 198, + "name": "Identifier", + "src": "145:8:3" + } + ], + "id": 199, + "name": "Assignment", + "src": "134:19:3" + } + ], + "id": 200, + "name": "ExpressionStatement", + "src": "134:19:3" + } + ], + "id": 201, + "name": "Block", + "src": "124:36:3" + } + ], + "id": 202, + "name": "FunctionDefinition", + "src": "83:77:3" + }, + { + "attributes": { + "constant": true, + "implemented": true, + "isConstructor": false, + "modifiers": [ + null + ], + "name": "greet", + "payable": false, + "scope": 211, + "stateMutability": "view", + "superFunction": null, + "visibility": "public" + }, + "children": [ + { + "attributes": { + "parameters": [ + null + ] + }, + "children": [], + "id": 203, + "name": "ParameterList", + "src": "184:2:3" + }, + { + "children": [ + { + "attributes": { + "constant": false, + "name": "", + "scope": 210, + "stateVariable": false, + "storageLocation": "default", + "type": "string memory", + "value": null, + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "string", + "type": "string storage pointer" + }, + "id": 204, + "name": "ElementaryTypeName", + "src": "208:6:3" + } + ], + "id": 205, + "name": "VariableDeclaration", + "src": "208:6:3" + } + ], + "id": 206, + "name": "ParameterList", + "src": "207:8:3" + }, + { + "children": [ + { + "attributes": { + "functionReturnParameters": 206 + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 192, + "type": "string storage ref", + "value": "greeting" + }, + "id": 207, + "name": "Identifier", + "src": "233:8:3" + } + ], + "id": 208, + "name": "Return", + "src": "226:15:3" + } + ], + "id": 209, + "name": "Block", + "src": "216:32:3" + } + ], + "id": 210, + "name": "FunctionDefinition", + "src": "170:78:3" + } + ], + "id": 211, + "name": "ContractDefinition", + "src": "25:240:3" + } + ], + "id": 212, + "name": "SourceUnit", + "src": "0:266:3" + }, + "compiler": { + "name": "solc", + "version": "0.4.19+commit.c4cbbb05.Emscripten.clang" + }, + "networks": { + "1519292400608": { + "events": {}, + "links": {}, + "address": "0x35a7816ba5847bf3fdae602289da723f84d581a9" + } + }, + "schemaVersion": "1.0.1", + "updatedAt": "2018-02-22T09:55:38.788Z" +} \ No newline at end of file diff --git a/Intro to Solidity/build/contracts/Migrations.json b/Intro to Solidity/build/contracts/Migrations.json new file mode 100644 index 0000000..81c426b --- /dev/null +++ b/Intro to Solidity/build/contracts/Migrations.json @@ -0,0 +1,827 @@ +{ + "contractName": "Migrations", + "abi": [ + { + "constant": true, + "inputs": [], + "name": "last_completed_migration", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "owner", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "constant": false, + "inputs": [ + { + "name": "completed", + "type": "uint256" + } + ], + "name": "setCompleted", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "new_address", + "type": "address" + } + ], + "name": "upgrade", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + } + ], + "bytecode": "0x6060604052341561000f57600080fd5b336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506102db8061005e6000396000f300606060405260043610610062576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680630900f01014610067578063445df0ac146100a05780638da5cb5b146100c9578063fdacd5761461011e575b600080fd5b341561007257600080fd5b61009e600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610141565b005b34156100ab57600080fd5b6100b3610224565b6040518082815260200191505060405180910390f35b34156100d457600080fd5b6100dc61022a565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561012957600080fd5b61013f600480803590602001909190505061024f565b005b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610220578190508073ffffffffffffffffffffffffffffffffffffffff1663fdacd5766001546040518263ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180828152602001915050600060405180830381600087803b151561020b57600080fd5b6102c65a03f1151561021c57600080fd5b5050505b5050565b60015481565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614156102ac57806001819055505b505600a165627a7a72305820ff889e22f716b3de3e1cf9ad9d040fbf12058040297c8eebfb40d713281014770029", + "deployedBytecode": "0x606060405260043610610062576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680630900f01014610067578063445df0ac146100a05780638da5cb5b146100c9578063fdacd5761461011e575b600080fd5b341561007257600080fd5b61009e600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610141565b005b34156100ab57600080fd5b6100b3610224565b6040518082815260200191505060405180910390f35b34156100d457600080fd5b6100dc61022a565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561012957600080fd5b61013f600480803590602001909190505061024f565b005b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610220578190508073ffffffffffffffffffffffffffffffffffffffff1663fdacd5766001546040518263ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180828152602001915050600060405180830381600087803b151561020b57600080fd5b6102c65a03f1151561021c57600080fd5b5050505b5050565b60015481565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614156102ac57806001819055505b505600a165627a7a72305820ff889e22f716b3de3e1cf9ad9d040fbf12058040297c8eebfb40d713281014770029", + "sourceMap": "26:488:0:-;;;178:58;;;;;;;;221:10;213:5;;:18;;;;;;;;;;;;;;;;;;26:488;;;;;;", + "deployedSourceMap": "26:488:0:-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;347:165;;;;;;;;;;;;;;;;;;;;;;;;;;;;74:36;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;50:20;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;240:103;;;;;;;;;;;;;;;;;;;;;;;;;;347:165;409:19;161:5;;;;;;;;;;;147:19;;:10;:19;;;143:26;;;442:11;409:45;;460:8;:21;;;482:24;;460:47;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;143:26;347:165;;:::o;74:36::-;;;;:::o;50:20::-;;;;;;;;;;;;;:::o;240:103::-;161:5;;;;;;;;;;;147:19;;:10;:19;;;143:26;;;329:9;302:24;:36;;;;143:26;240:103;:::o", + "source": "pragma solidity ^0.4.17;\n\ncontract Migrations {\n address public owner;\n uint public last_completed_migration;\n\n modifier restricted() {\n if (msg.sender == owner) _;\n }\n\n function Migrations() public {\n owner = msg.sender;\n }\n\n function setCompleted(uint completed) public restricted {\n last_completed_migration = completed;\n }\n\n function upgrade(address new_address) public restricted {\n Migrations upgraded = Migrations(new_address);\n upgraded.setCompleted(last_completed_migration);\n }\n}\n", + "sourcePath": "/Users/adithyaj/Google Drive/berkeley/babDev/lab2/Intro to Solidity/contracts/Migrations.sol", + "ast": { + "attributes": { + "absolutePath": "/Users/adithyaj/Google Drive/berkeley/babDev/lab2/Intro to Solidity/contracts/Migrations.sol", + "exportedSymbols": { + "Migrations": [ + 56 + ] + } + }, + "children": [ + { + "attributes": { + "literals": [ + "solidity", + "^", + "0.4", + ".17" + ] + }, + "id": 1, + "name": "PragmaDirective", + "src": "0:24:0" + }, + { + "attributes": { + "baseContracts": [ + null + ], + "contractDependencies": [ + null + ], + "contractKind": "contract", + "documentation": null, + "fullyImplemented": true, + "linearizedBaseContracts": [ + 56 + ], + "name": "Migrations", + "scope": 57 + }, + "children": [ + { + "attributes": { + "constant": false, + "name": "owner", + "scope": 56, + "stateVariable": true, + "storageLocation": "default", + "type": "address", + "value": null, + "visibility": "public" + }, + "children": [ + { + "attributes": { + "name": "address", + "type": "address" + }, + "id": 2, + "name": "ElementaryTypeName", + "src": "50:7:0" + } + ], + "id": 3, + "name": "VariableDeclaration", + "src": "50:20:0" + }, + { + "attributes": { + "constant": false, + "name": "last_completed_migration", + "scope": 56, + "stateVariable": true, + "storageLocation": "default", + "type": "uint256", + "value": null, + "visibility": "public" + }, + "children": [ + { + "attributes": { + "name": "uint", + "type": "uint256" + }, + "id": 4, + "name": "ElementaryTypeName", + "src": "74:4:0" + } + ], + "id": 5, + "name": "VariableDeclaration", + "src": "74:36:0" + }, + { + "attributes": { + "name": "restricted", + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "parameters": [ + null + ] + }, + "children": [], + "id": 6, + "name": "ParameterList", + "src": "134:2:0" + }, + { + "children": [ + { + "attributes": { + "falseBody": null + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "operator": "==", + "type": "bool" + }, + "children": [ + { + "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": 246, + "type": "msg", + "value": "msg" + }, + "id": 7, + "name": "Identifier", + "src": "147:3:0" + } + ], + "id": 8, + "name": "MemberAccess", + "src": "147:10:0" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 3, + "type": "address", + "value": "owner" + }, + "id": 9, + "name": "Identifier", + "src": "161:5:0" + } + ], + "id": 10, + "name": "BinaryOperation", + "src": "147:19:0" + }, + { + "id": 11, + "name": "PlaceholderStatement", + "src": "168:1:0" + } + ], + "id": 12, + "name": "IfStatement", + "src": "143:26:0" + } + ], + "id": 13, + "name": "Block", + "src": "137:37:0" + } + ], + "id": 14, + "name": "ModifierDefinition", + "src": "115:59:0" + }, + { + "attributes": { + "constant": false, + "implemented": true, + "isConstructor": true, + "modifiers": [ + null + ], + "name": "Migrations", + "payable": false, + "scope": 56, + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + "children": [ + { + "attributes": { + "parameters": [ + null + ] + }, + "children": [], + "id": 15, + "name": "ParameterList", + "src": "197:2:0" + }, + { + "attributes": { + "parameters": [ + null + ] + }, + "children": [], + "id": 16, + "name": "ParameterList", + "src": "207:0:0" + }, + { + "children": [ + { + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "operator": "=", + "type": "address" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 3, + "type": "address", + "value": "owner" + }, + "id": 17, + "name": "Identifier", + "src": "213:5: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": 246, + "type": "msg", + "value": "msg" + }, + "id": 18, + "name": "Identifier", + "src": "221:3:0" + } + ], + "id": 19, + "name": "MemberAccess", + "src": "221:10:0" + } + ], + "id": 20, + "name": "Assignment", + "src": "213:18:0" + } + ], + "id": 21, + "name": "ExpressionStatement", + "src": "213:18:0" + } + ], + "id": 22, + "name": "Block", + "src": "207:29:0" + } + ], + "id": 23, + "name": "FunctionDefinition", + "src": "178:58:0" + }, + { + "attributes": { + "constant": false, + "implemented": true, + "isConstructor": false, + "name": "setCompleted", + "payable": false, + "scope": 56, + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + "children": [ + { + "children": [ + { + "attributes": { + "constant": false, + "name": "completed", + "scope": 35, + "stateVariable": false, + "storageLocation": "default", + "type": "uint256", + "value": null, + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "uint", + "type": "uint256" + }, + "id": 24, + "name": "ElementaryTypeName", + "src": "262:4:0" + } + ], + "id": 25, + "name": "VariableDeclaration", + "src": "262:14:0" + } + ], + "id": 26, + "name": "ParameterList", + "src": "261:16:0" + }, + { + "attributes": { + "parameters": [ + null + ] + }, + "children": [], + "id": 29, + "name": "ParameterList", + "src": "296:0:0" + }, + { + "attributes": { + "arguments": [ + null + ] + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 14, + "type": "modifier ()", + "value": "restricted" + }, + "id": 27, + "name": "Identifier", + "src": "285:10:0" + } + ], + "id": 28, + "name": "ModifierInvocation", + "src": "285:10:0" + }, + { + "children": [ + { + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "operator": "=", + "type": "uint256" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 5, + "type": "uint256", + "value": "last_completed_migration" + }, + "id": 30, + "name": "Identifier", + "src": "302:24:0" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 25, + "type": "uint256", + "value": "completed" + }, + "id": 31, + "name": "Identifier", + "src": "329:9:0" + } + ], + "id": 32, + "name": "Assignment", + "src": "302:36:0" + } + ], + "id": 33, + "name": "ExpressionStatement", + "src": "302:36:0" + } + ], + "id": 34, + "name": "Block", + "src": "296:47:0" + } + ], + "id": 35, + "name": "FunctionDefinition", + "src": "240:103:0" + }, + { + "attributes": { + "constant": false, + "implemented": true, + "isConstructor": false, + "name": "upgrade", + "payable": false, + "scope": 56, + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + "children": [ + { + "children": [ + { + "attributes": { + "constant": false, + "name": "new_address", + "scope": 55, + "stateVariable": false, + "storageLocation": "default", + "type": "address", + "value": null, + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "address", + "type": "address" + }, + "id": 36, + "name": "ElementaryTypeName", + "src": "364:7:0" + } + ], + "id": 37, + "name": "VariableDeclaration", + "src": "364:19:0" + } + ], + "id": 38, + "name": "ParameterList", + "src": "363:21:0" + }, + { + "attributes": { + "parameters": [ + null + ] + }, + "children": [], + "id": 41, + "name": "ParameterList", + "src": "403:0:0" + }, + { + "attributes": { + "arguments": [ + null + ] + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 14, + "type": "modifier ()", + "value": "restricted" + }, + "id": 39, + "name": "Identifier", + "src": "392:10:0" + } + ], + "id": 40, + "name": "ModifierInvocation", + "src": "392:10:0" + }, + { + "children": [ + { + "attributes": { + "assignments": [ + 43 + ] + }, + "children": [ + { + "attributes": { + "constant": false, + "name": "upgraded", + "scope": 55, + "stateVariable": false, + "storageLocation": "default", + "type": "contract Migrations", + "value": null, + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "contractScope": null, + "name": "Migrations", + "referencedDeclaration": 56, + "type": "contract Migrations" + }, + "id": 42, + "name": "UserDefinedTypeName", + "src": "409:10:0" + } + ], + "id": 43, + "name": "VariableDeclaration", + "src": "409:19:0" + }, + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "isStructConstructorCall": false, + "lValueRequested": false, + "names": [ + null + ], + "type": "contract Migrations", + "type_conversion": true + }, + "children": [ + { + "attributes": { + "argumentTypes": [ + { + "typeIdentifier": "t_address", + "typeString": "address" + } + ], + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 56, + "type": "type(contract Migrations)", + "value": "Migrations" + }, + "id": 44, + "name": "Identifier", + "src": "431:10:0" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 37, + "type": "address", + "value": "new_address" + }, + "id": 45, + "name": "Identifier", + "src": "442:11:0" + } + ], + "id": 46, + "name": "FunctionCall", + "src": "431:23:0" + } + ], + "id": 47, + "name": "VariableDeclarationStatement", + "src": "409:45: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" + } + ], + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "member_name": "setCompleted", + "referencedDeclaration": 35, + "type": "function (uint256) external" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 43, + "type": "contract Migrations", + "value": "upgraded" + }, + "id": 48, + "name": "Identifier", + "src": "460:8:0" + } + ], + "id": 50, + "name": "MemberAccess", + "src": "460:21:0" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 5, + "type": "uint256", + "value": "last_completed_migration" + }, + "id": 51, + "name": "Identifier", + "src": "482:24:0" + } + ], + "id": 52, + "name": "FunctionCall", + "src": "460:47:0" + } + ], + "id": 53, + "name": "ExpressionStatement", + "src": "460:47:0" + } + ], + "id": 54, + "name": "Block", + "src": "403:109:0" + } + ], + "id": 55, + "name": "FunctionDefinition", + "src": "347:165:0" + } + ], + "id": 56, + "name": "ContractDefinition", + "src": "26:488:0" + } + ], + "id": 57, + "name": "SourceUnit", + "src": "0:515:0" + }, + "compiler": { + "name": "solc", + "version": "0.4.19+commit.c4cbbb05.Emscripten.clang" + }, + "networks": { + "1519292400608": { + "events": {}, + "links": {}, + "address": "0xff5f4c62cca982a3b1417634f7b094f1d7031021" + } + }, + "schemaVersion": "1.0.1", + "updatedAt": "2018-02-22T09:55:38.797Z" +} \ No newline at end of file diff --git a/Intro to Solidity/build/contracts/XOR.json b/Intro to Solidity/build/contracts/XOR.json new file mode 100644 index 0000000..3003a92 --- /dev/null +++ b/Intro to Solidity/build/contracts/XOR.json @@ -0,0 +1,340 @@ +{ + "contractName": "XOR", + "abi": [ + { + "constant": true, + "inputs": [ + { + "name": "num1", + "type": "uint256" + }, + { + "name": "num2", + "type": "uint256" + } + ], + "name": "xor", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "pure", + "type": "function" + } + ], + "bytecode": "0x6060604052341561000f57600080fd5b60c98061001d6000396000f300606060405260043610603f576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680639ed41ba1146044575b600080fd5b3415604e57600080fd5b606b60048080359060200190919080359060200190919050506081565b6040518082815260200191505060405180910390f35b600081831415609257600090506097565b600190505b929150505600a165627a7a7230582085e7c634aea5946f99911041ef7ee53a1e6e695ed18cf793f8c206a268dc1af20029", + "deployedBytecode": "0x606060405260043610603f576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680639ed41ba1146044575b600080fd5b3415604e57600080fd5b606b60048080359060200190919080359060200190919050506081565b6040518082815260200191505060405180910390f35b600081831415609257600090506097565b600190505b929150505600a165627a7a7230582085e7c634aea5946f99911041ef7ee53a1e6e695ed18cf793f8c206a268dc1af20029", + "sourceMap": "25:199:4:-;;;;;;;;;;;;;;;;;", + "deployedSourceMap": "25:199:4:-;;;;;;;;;;;;;;;;;;;;;;;;49:168;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;105:4;133;125;:12;121:90;;;160:1;153:8;;;;121:90;199:1;192:8;;49:168;;;;;:::o", + "source": "pragma solidity 0.4.19;\n\ncontract XOR {\n \n function xor(uint num1, uint num2) public pure returns (uint) {\n if (num1 == num2) {\n return 0;\n } else {\n return 1;\n }\n }\n \n}\n", + "sourcePath": "/Users/adithyaj/Google Drive/berkeley/babDev/lab2/Intro to Solidity/contracts/xor.sol", + "ast": { + "attributes": { + "absolutePath": "/Users/adithyaj/Google Drive/berkeley/babDev/lab2/Intro to Solidity/contracts/xor.sol", + "exportedSymbols": { + "XOR": [ + 234 + ] + } + }, + "children": [ + { + "attributes": { + "literals": [ + "solidity", + "0.4", + ".19" + ] + }, + "id": 213, + "name": "PragmaDirective", + "src": "0:23:4" + }, + { + "attributes": { + "baseContracts": [ + null + ], + "contractDependencies": [ + null + ], + "contractKind": "contract", + "documentation": null, + "fullyImplemented": true, + "linearizedBaseContracts": [ + 234 + ], + "name": "XOR", + "scope": 235 + }, + "children": [ + { + "attributes": { + "constant": true, + "implemented": true, + "isConstructor": false, + "modifiers": [ + null + ], + "name": "xor", + "payable": false, + "scope": 234, + "stateMutability": "pure", + "superFunction": null, + "visibility": "public" + }, + "children": [ + { + "children": [ + { + "attributes": { + "constant": false, + "name": "num1", + "scope": 233, + "stateVariable": false, + "storageLocation": "default", + "type": "uint256", + "value": null, + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "uint", + "type": "uint256" + }, + "id": 214, + "name": "ElementaryTypeName", + "src": "62:4:4" + } + ], + "id": 215, + "name": "VariableDeclaration", + "src": "62:9:4" + }, + { + "attributes": { + "constant": false, + "name": "num2", + "scope": 233, + "stateVariable": false, + "storageLocation": "default", + "type": "uint256", + "value": null, + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "uint", + "type": "uint256" + }, + "id": 216, + "name": "ElementaryTypeName", + "src": "73:4:4" + } + ], + "id": 217, + "name": "VariableDeclaration", + "src": "73:9:4" + } + ], + "id": 218, + "name": "ParameterList", + "src": "61:22:4" + }, + { + "children": [ + { + "attributes": { + "constant": false, + "name": "", + "scope": 233, + "stateVariable": false, + "storageLocation": "default", + "type": "uint256", + "value": null, + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "uint", + "type": "uint256" + }, + "id": 219, + "name": "ElementaryTypeName", + "src": "105:4:4" + } + ], + "id": 220, + "name": "VariableDeclaration", + "src": "105:4:4" + } + ], + "id": 221, + "name": "ParameterList", + "src": "104:6:4" + }, + { + "children": [ + { + "children": [ + { + "attributes": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "operator": "==", + "type": "bool" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 215, + "type": "uint256", + "value": "num1" + }, + "id": 222, + "name": "Identifier", + "src": "125:4:4" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 217, + "type": "uint256", + "value": "num2" + }, + "id": 223, + "name": "Identifier", + "src": "133:4:4" + } + ], + "id": 224, + "name": "BinaryOperation", + "src": "125:12:4" + }, + { + "children": [ + { + "attributes": { + "functionReturnParameters": 221 + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "hexvalue": "30", + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "subdenomination": null, + "token": "number", + "type": "int_const 0", + "value": "0" + }, + "id": 225, + "name": "Literal", + "src": "160:1:4" + } + ], + "id": 226, + "name": "Return", + "src": "153:8:4" + } + ], + "id": 227, + "name": "Block", + "src": "139:33:4" + }, + { + "children": [ + { + "attributes": { + "functionReturnParameters": 221 + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "hexvalue": "31", + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "subdenomination": null, + "token": "number", + "type": "int_const 1", + "value": "1" + }, + "id": 228, + "name": "Literal", + "src": "199:1:4" + } + ], + "id": 229, + "name": "Return", + "src": "192:8:4" + } + ], + "id": 230, + "name": "Block", + "src": "178:33:4" + } + ], + "id": 231, + "name": "IfStatement", + "src": "121:90:4" + } + ], + "id": 232, + "name": "Block", + "src": "111:106:4" + } + ], + "id": 233, + "name": "FunctionDefinition", + "src": "49:168:4" + } + ], + "id": 234, + "name": "ContractDefinition", + "src": "25:199:4" + } + ], + "id": 235, + "name": "SourceUnit", + "src": "0:225:4" + }, + "compiler": { + "name": "solc", + "version": "0.4.19+commit.c4cbbb05.Emscripten.clang" + }, + "networks": { + "1519292400608": { + "events": {}, + "links": {}, + "address": "0xca8940ca46ce24d4abb3faa7ef36e153c5ca0de9" + } + }, + "schemaVersion": "1.0.1", + "updatedAt": "2018-02-22T09:55:38.788Z" +} \ No newline at end of file diff --git a/Intro to Solidity/build/contracts/fibonacci.json b/Intro to Solidity/build/contracts/fibonacci.json new file mode 100644 index 0000000..2786917 --- /dev/null +++ b/Intro to Solidity/build/contracts/fibonacci.json @@ -0,0 +1,623 @@ +{ + "contractName": "fibonacci", + "abi": [ + { + "constant": false, + "inputs": [], + "name": "fibonnaci", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "fibIter", + "outputs": [ + { + "name": "fib", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + } + ], + "bytecode": "0x60606040526000805560018055341561001757600080fd5b60e5806100256000396000f3006060604052600436106049576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806371a5dc0214604e578063fdd1d35a146074575b600080fd5b3415605857600080fd5b605e6086565b6040518082815260200191505060405180910390f35b3415607e57600080fd5b608460a9565b005b600080600054905060015460008190555060015481016001819055508091505090565b60008081905550600180819055505600a165627a7a723058206ed8ca6d84ab18a3bdc9ac7a37c23852730e2c82f7177100713c1133c2b02cbc0029", + "deployedBytecode": "0x6060604052600436106049576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806371a5dc0214604e578063fdd1d35a146074575b600080fd5b3415605857600080fd5b605e6086565b6040518082815260200191505060405180910390f35b3415607e57600080fd5b608460a9565b005b600080600054905060015460008190555060015481016001819055508091505090565b60008081905550600180819055505600a165627a7a723058206ed8ca6d84ab18a3bdc9ac7a37c23852730e2c82f7177100713c1133c2b02cbc0029", + "sourceMap": "25:316:0:-;;;63:1;50:14;;83:1;70:14;;25:316;;;;;;;;;;;;;;", + "deployedSourceMap": "25:316:0:-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;171:153;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;91:73;;;;;;;;;;;;;;171:153;206:8;226:9;238:5;;226:17;;261:5;;253;:13;;;;291:5;;284:4;:12;276:5;:20;;;;313:4;306:11;;171:153;;:::o;91:73::-;137:1;129:5;:9;;;;156:1;148:5;:9;;;;91:73::o", + "source": "pragma solidity 0.4.19;\n\ncontract fibonacci {\n uint _curr = 0;\n uint _next = 1;\n\n function fibonnaci() public {\n _curr = 0;\n _next = 1;\n }\n\n\n function fibIter() public returns (uint fib) {\n uint stor = _curr;\n _curr = _next;\n _next = stor + _next;\n return stor;\n }\n \n \n \n}\n", + "sourcePath": "/Users/adithyaj/Google Drive/berkeley/babDev/lab2/Intro to Solidity/contracts/fibonacci.sol", + "ast": { + "attributes": { + "absolutePath": "/Users/adithyaj/Google Drive/berkeley/babDev/lab2/Intro to Solidity/contracts/fibonacci.sol", + "exportedSymbols": { + "fibonacci": [ + 42 + ] + } + }, + "children": [ + { + "attributes": { + "literals": [ + "solidity", + "0.4", + ".19" + ] + }, + "id": 1, + "name": "PragmaDirective", + "src": "0:23:0" + }, + { + "attributes": { + "baseContracts": [ + null + ], + "contractDependencies": [ + null + ], + "contractKind": "contract", + "documentation": null, + "fullyImplemented": true, + "linearizedBaseContracts": [ + 42 + ], + "name": "fibonacci", + "scope": 43 + }, + "children": [ + { + "attributes": { + "constant": false, + "name": "_curr", + "scope": 42, + "stateVariable": true, + "storageLocation": "default", + "type": "uint256", + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "uint", + "type": "uint256" + }, + "id": 2, + "name": "ElementaryTypeName", + "src": "50:4:0" + }, + { + "attributes": { + "argumentTypes": null, + "hexvalue": "30", + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "subdenomination": null, + "token": "number", + "type": "int_const 0", + "value": "0" + }, + "id": 3, + "name": "Literal", + "src": "63:1:0" + } + ], + "id": 4, + "name": "VariableDeclaration", + "src": "50:14:0" + }, + { + "attributes": { + "constant": false, + "name": "_next", + "scope": 42, + "stateVariable": true, + "storageLocation": "default", + "type": "uint256", + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "uint", + "type": "uint256" + }, + "id": 5, + "name": "ElementaryTypeName", + "src": "70:4:0" + }, + { + "attributes": { + "argumentTypes": null, + "hexvalue": "31", + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "subdenomination": null, + "token": "number", + "type": "int_const 1", + "value": "1" + }, + "id": 6, + "name": "Literal", + "src": "83:1:0" + } + ], + "id": 7, + "name": "VariableDeclaration", + "src": "70:14:0" + }, + { + "attributes": { + "constant": false, + "implemented": true, + "isConstructor": false, + "modifiers": [ + null + ], + "name": "fibonnaci", + "payable": false, + "scope": 42, + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + "children": [ + { + "attributes": { + "parameters": [ + null + ] + }, + "children": [], + "id": 8, + "name": "ParameterList", + "src": "109:2:0" + }, + { + "attributes": { + "parameters": [ + null + ] + }, + "children": [], + "id": 9, + "name": "ParameterList", + "src": "119:0:0" + }, + { + "children": [ + { + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "operator": "=", + "type": "uint256" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 4, + "type": "uint256", + "value": "_curr" + }, + "id": 10, + "name": "Identifier", + "src": "129:5:0" + }, + { + "attributes": { + "argumentTypes": null, + "hexvalue": "30", + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "subdenomination": null, + "token": "number", + "type": "int_const 0", + "value": "0" + }, + "id": 11, + "name": "Literal", + "src": "137:1:0" + } + ], + "id": 12, + "name": "Assignment", + "src": "129:9:0" + } + ], + "id": 13, + "name": "ExpressionStatement", + "src": "129:9:0" + }, + { + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "operator": "=", + "type": "uint256" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 7, + "type": "uint256", + "value": "_next" + }, + "id": 14, + "name": "Identifier", + "src": "148:5:0" + }, + { + "attributes": { + "argumentTypes": null, + "hexvalue": "31", + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "subdenomination": null, + "token": "number", + "type": "int_const 1", + "value": "1" + }, + "id": 15, + "name": "Literal", + "src": "156:1:0" + } + ], + "id": 16, + "name": "Assignment", + "src": "148:9:0" + } + ], + "id": 17, + "name": "ExpressionStatement", + "src": "148:9:0" + } + ], + "id": 18, + "name": "Block", + "src": "119:45:0" + } + ], + "id": 19, + "name": "FunctionDefinition", + "src": "91:73:0" + }, + { + "attributes": { + "constant": false, + "implemented": true, + "isConstructor": false, + "modifiers": [ + null + ], + "name": "fibIter", + "payable": false, + "scope": 42, + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + "children": [ + { + "attributes": { + "parameters": [ + null + ] + }, + "children": [], + "id": 20, + "name": "ParameterList", + "src": "187:2:0" + }, + { + "children": [ + { + "attributes": { + "constant": false, + "name": "fib", + "scope": 41, + "stateVariable": false, + "storageLocation": "default", + "type": "uint256", + "value": null, + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "uint", + "type": "uint256" + }, + "id": 21, + "name": "ElementaryTypeName", + "src": "206:4:0" + } + ], + "id": 22, + "name": "VariableDeclaration", + "src": "206:8:0" + } + ], + "id": 23, + "name": "ParameterList", + "src": "205:10:0" + }, + { + "children": [ + { + "attributes": { + "assignments": [ + 25 + ] + }, + "children": [ + { + "attributes": { + "constant": false, + "name": "stor", + "scope": 41, + "stateVariable": false, + "storageLocation": "default", + "type": "uint256", + "value": null, + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "uint", + "type": "uint256" + }, + "id": 24, + "name": "ElementaryTypeName", + "src": "226:4:0" + } + ], + "id": 25, + "name": "VariableDeclaration", + "src": "226:9:0" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 4, + "type": "uint256", + "value": "_curr" + }, + "id": 26, + "name": "Identifier", + "src": "238:5:0" + } + ], + "id": 27, + "name": "VariableDeclarationStatement", + "src": "226:17:0" + }, + { + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "operator": "=", + "type": "uint256" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 4, + "type": "uint256", + "value": "_curr" + }, + "id": 28, + "name": "Identifier", + "src": "253:5:0" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 7, + "type": "uint256", + "value": "_next" + }, + "id": 29, + "name": "Identifier", + "src": "261:5:0" + } + ], + "id": 30, + "name": "Assignment", + "src": "253:13:0" + } + ], + "id": 31, + "name": "ExpressionStatement", + "src": "253:13:0" + }, + { + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "operator": "=", + "type": "uint256" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 7, + "type": "uint256", + "value": "_next" + }, + "id": 32, + "name": "Identifier", + "src": "276:5:0" + }, + { + "attributes": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "operator": "+", + "type": "uint256" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 25, + "type": "uint256", + "value": "stor" + }, + "id": 33, + "name": "Identifier", + "src": "284:4:0" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 7, + "type": "uint256", + "value": "_next" + }, + "id": 34, + "name": "Identifier", + "src": "291:5:0" + } + ], + "id": 35, + "name": "BinaryOperation", + "src": "284:12:0" + } + ], + "id": 36, + "name": "Assignment", + "src": "276:20:0" + } + ], + "id": 37, + "name": "ExpressionStatement", + "src": "276:20:0" + }, + { + "attributes": { + "functionReturnParameters": 23 + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 25, + "type": "uint256", + "value": "stor" + }, + "id": 38, + "name": "Identifier", + "src": "313:4:0" + } + ], + "id": 39, + "name": "Return", + "src": "306:11:0" + } + ], + "id": 40, + "name": "Block", + "src": "216:108:0" + } + ], + "id": 41, + "name": "FunctionDefinition", + "src": "171:153:0" + } + ], + "id": 42, + "name": "ContractDefinition", + "src": "25:316:0" + } + ], + "id": 43, + "name": "SourceUnit", + "src": "0:342:0" + }, + "compiler": { + "name": "solc", + "version": "0.4.19+commit.c4cbbb05.Emscripten.clang" + }, + "networks": { + "1519292400608": { + "events": {}, + "links": {}, + "address": "0xc6abfa5ba7f1700b81bfe217d6571ff1ae68d3c2" + } + }, + "schemaVersion": "1.0.1", + "updatedAt": "2018-02-22T09:55:38.788Z" +} \ No newline at end of file diff --git a/Intro to Solidity/build/contracts/fibonnaci.json b/Intro to Solidity/build/contracts/fibonnaci.json new file mode 100644 index 0000000..42e3fae --- /dev/null +++ b/Intro to Solidity/build/contracts/fibonnaci.json @@ -0,0 +1,614 @@ +{ + "contractName": "fibonnaci", + "abi": [ + { + "inputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "constant": false, + "inputs": [], + "name": "fibIter", + "outputs": [ + { + "name": "fib", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + } + ], + "bytecode": "0x60606040526000805560018055341561001757600080fd5b600080819055506001808190555060b9806100336000396000f300606060405260043610603f576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806371a5dc02146044575b600080fd5b3415604e57600080fd5b6054606a565b6040518082815260200191505060405180910390f35b6000806000549050600154600081905550600154810160018190555080915050905600a165627a7a723058206d48ab981b4b3ff77736d22db61779fcd0e4d763ae3b4f6a52e6f5f83bc764760029", + "deployedBytecode": "0x606060405260043610603f576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806371a5dc02146044575b600080fd5b3415604e57600080fd5b6054606a565b6040518082815260200191505060405180910390f35b6000806000549050600154600081905550600154810160018190555080915050905600a165627a7a723058206d48ab981b4b3ff77736d22db61779fcd0e4d763ae3b4f6a52e6f5f83bc764760029", + "sourceMap": "25:316:2:-;;;63:1;50:14;;83:1;70:14;;91:73;;;;;;;;137:1;129:5;:9;;;;156:1;148:5;:9;;;;25:316;;;;;;", + "deployedSourceMap": "25:316:2:-;;;;;;;;;;;;;;;;;;;;;;;;171:153;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;206:8;226:9;238:5;;226:17;;261:5;;253;:13;;;;291:5;;284:4;:12;276:5;:20;;;;313:4;306:11;;171:153;;:::o", + "source": "pragma solidity 0.4.19;\n\ncontract fibonnaci {\n uint _curr = 0;\n uint _next = 1;\n\n function fibonnaci() public {\n _curr = 0;\n _next = 1;\n }\n\n\n function fibIter() public returns (uint fib) {\n uint stor = _curr;\n _curr = _next;\n _next = stor + _next;\n return stor;\n }\n \n \n \n}\n", + "sourcePath": "/Users/adithyaj/Google Drive/berkeley/babDev/lab2/Intro to Solidity/contracts/fibonacci.sol", + "ast": { + "attributes": { + "absolutePath": "/Users/adithyaj/Google Drive/berkeley/babDev/lab2/Intro to Solidity/contracts/fibonacci.sol", + "exportedSymbols": { + "fibonnaci": [ + 188 + ] + } + }, + "children": [ + { + "attributes": { + "literals": [ + "solidity", + "0.4", + ".19" + ] + }, + "id": 147, + "name": "PragmaDirective", + "src": "0:23:2" + }, + { + "attributes": { + "baseContracts": [ + null + ], + "contractDependencies": [ + null + ], + "contractKind": "contract", + "documentation": null, + "fullyImplemented": true, + "linearizedBaseContracts": [ + 188 + ], + "name": "fibonnaci", + "scope": 189 + }, + "children": [ + { + "attributes": { + "constant": false, + "name": "_curr", + "scope": 188, + "stateVariable": true, + "storageLocation": "default", + "type": "uint256", + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "uint", + "type": "uint256" + }, + "id": 148, + "name": "ElementaryTypeName", + "src": "50:4:2" + }, + { + "attributes": { + "argumentTypes": null, + "hexvalue": "30", + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "subdenomination": null, + "token": "number", + "type": "int_const 0", + "value": "0" + }, + "id": 149, + "name": "Literal", + "src": "63:1:2" + } + ], + "id": 150, + "name": "VariableDeclaration", + "src": "50:14:2" + }, + { + "attributes": { + "constant": false, + "name": "_next", + "scope": 188, + "stateVariable": true, + "storageLocation": "default", + "type": "uint256", + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "uint", + "type": "uint256" + }, + "id": 151, + "name": "ElementaryTypeName", + "src": "70:4:2" + }, + { + "attributes": { + "argumentTypes": null, + "hexvalue": "31", + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "subdenomination": null, + "token": "number", + "type": "int_const 1", + "value": "1" + }, + "id": 152, + "name": "Literal", + "src": "83:1:2" + } + ], + "id": 153, + "name": "VariableDeclaration", + "src": "70:14:2" + }, + { + "attributes": { + "constant": false, + "implemented": true, + "isConstructor": true, + "modifiers": [ + null + ], + "name": "fibonnaci", + "payable": false, + "scope": 188, + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + "children": [ + { + "attributes": { + "parameters": [ + null + ] + }, + "children": [], + "id": 154, + "name": "ParameterList", + "src": "109:2:2" + }, + { + "attributes": { + "parameters": [ + null + ] + }, + "children": [], + "id": 155, + "name": "ParameterList", + "src": "119:0:2" + }, + { + "children": [ + { + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "operator": "=", + "type": "uint256" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 150, + "type": "uint256", + "value": "_curr" + }, + "id": 156, + "name": "Identifier", + "src": "129:5:2" + }, + { + "attributes": { + "argumentTypes": null, + "hexvalue": "30", + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "subdenomination": null, + "token": "number", + "type": "int_const 0", + "value": "0" + }, + "id": 157, + "name": "Literal", + "src": "137:1:2" + } + ], + "id": 158, + "name": "Assignment", + "src": "129:9:2" + } + ], + "id": 159, + "name": "ExpressionStatement", + "src": "129:9:2" + }, + { + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "operator": "=", + "type": "uint256" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 153, + "type": "uint256", + "value": "_next" + }, + "id": 160, + "name": "Identifier", + "src": "148:5:2" + }, + { + "attributes": { + "argumentTypes": null, + "hexvalue": "31", + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "subdenomination": null, + "token": "number", + "type": "int_const 1", + "value": "1" + }, + "id": 161, + "name": "Literal", + "src": "156:1:2" + } + ], + "id": 162, + "name": "Assignment", + "src": "148:9:2" + } + ], + "id": 163, + "name": "ExpressionStatement", + "src": "148:9:2" + } + ], + "id": 164, + "name": "Block", + "src": "119:45:2" + } + ], + "id": 165, + "name": "FunctionDefinition", + "src": "91:73:2" + }, + { + "attributes": { + "constant": false, + "implemented": true, + "isConstructor": false, + "modifiers": [ + null + ], + "name": "fibIter", + "payable": false, + "scope": 188, + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + "children": [ + { + "attributes": { + "parameters": [ + null + ] + }, + "children": [], + "id": 166, + "name": "ParameterList", + "src": "187:2:2" + }, + { + "children": [ + { + "attributes": { + "constant": false, + "name": "fib", + "scope": 187, + "stateVariable": false, + "storageLocation": "default", + "type": "uint256", + "value": null, + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "uint", + "type": "uint256" + }, + "id": 167, + "name": "ElementaryTypeName", + "src": "206:4:2" + } + ], + "id": 168, + "name": "VariableDeclaration", + "src": "206:8:2" + } + ], + "id": 169, + "name": "ParameterList", + "src": "205:10:2" + }, + { + "children": [ + { + "attributes": { + "assignments": [ + 171 + ] + }, + "children": [ + { + "attributes": { + "constant": false, + "name": "stor", + "scope": 187, + "stateVariable": false, + "storageLocation": "default", + "type": "uint256", + "value": null, + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "uint", + "type": "uint256" + }, + "id": 170, + "name": "ElementaryTypeName", + "src": "226:4:2" + } + ], + "id": 171, + "name": "VariableDeclaration", + "src": "226:9:2" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 150, + "type": "uint256", + "value": "_curr" + }, + "id": 172, + "name": "Identifier", + "src": "238:5:2" + } + ], + "id": 173, + "name": "VariableDeclarationStatement", + "src": "226:17:2" + }, + { + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "operator": "=", + "type": "uint256" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 150, + "type": "uint256", + "value": "_curr" + }, + "id": 174, + "name": "Identifier", + "src": "253:5:2" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 153, + "type": "uint256", + "value": "_next" + }, + "id": 175, + "name": "Identifier", + "src": "261:5:2" + } + ], + "id": 176, + "name": "Assignment", + "src": "253:13:2" + } + ], + "id": 177, + "name": "ExpressionStatement", + "src": "253:13:2" + }, + { + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "operator": "=", + "type": "uint256" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 153, + "type": "uint256", + "value": "_next" + }, + "id": 178, + "name": "Identifier", + "src": "276:5:2" + }, + { + "attributes": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "operator": "+", + "type": "uint256" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 171, + "type": "uint256", + "value": "stor" + }, + "id": 179, + "name": "Identifier", + "src": "284:4:2" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 153, + "type": "uint256", + "value": "_next" + }, + "id": 180, + "name": "Identifier", + "src": "291:5:2" + } + ], + "id": 181, + "name": "BinaryOperation", + "src": "284:12:2" + } + ], + "id": 182, + "name": "Assignment", + "src": "276:20:2" + } + ], + "id": 183, + "name": "ExpressionStatement", + "src": "276:20:2" + }, + { + "attributes": { + "functionReturnParameters": 169 + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 171, + "type": "uint256", + "value": "stor" + }, + "id": 184, + "name": "Identifier", + "src": "313:4:2" + } + ], + "id": 185, + "name": "Return", + "src": "306:11:2" + } + ], + "id": 186, + "name": "Block", + "src": "216:108:2" + } + ], + "id": 187, + "name": "FunctionDefinition", + "src": "171:153:2" + } + ], + "id": 188, + "name": "ContractDefinition", + "src": "25:316:2" + } + ], + "id": 189, + "name": "SourceUnit", + "src": "0:342:2" + }, + "compiler": { + "name": "solc", + "version": "0.4.19+commit.c4cbbb05.Emscripten.clang" + }, + "networks": {}, + "schemaVersion": "1.0.1", + "updatedAt": "2018-02-22T09:53:49.602Z" +} \ No newline at end of file diff --git a/Intro to Solidity/contracts/concatenate.sol b/Intro to Solidity/contracts/concatenate.sol index 4172912..6555e60 100644 --- a/Intro to Solidity/contracts/concatenate.sol +++ b/Intro to Solidity/contracts/concatenate.sol @@ -1,11 +1,15 @@ pragma solidity 0.4.19; - contract Concatenate { - function concatWithoutImport(string _s, string _t) public returns (string) { - } - - /* BONUS */ - function concatWithImport(string s, string t) public returns (string) { + + function concatWithoutImport(string str1, string str2) public constant returns (string) { + bytes memory _str1 = bytes(str1); + bytes memory _str2 = bytes(str2); + string memory _str = new string(_str1.length + _str2.length); + bytes memory result = bytes(_str); + for (uint i = 0; i < _str1.length; i++) result[i] = _str1[i]; + for (uint k = 0; k < _str2.length; k++) result[_str1.length + k] = _str2[k]; + return string(result); } + } diff --git a/Intro to Solidity/contracts/fibonacci.sol b/Intro to Solidity/contracts/fibonacci.sol index b8ea5fc..1e8f5aa 100644 --- a/Intro to Solidity/contracts/fibonacci.sol +++ b/Intro to Solidity/contracts/fibonacci.sol @@ -1,12 +1,22 @@ pragma solidity 0.4.19; +contract fibonacci { + uint _curr = 0; + uint _next = 1; -contract Fibonacci { - /* Carry out calculations to find the nth Fibonacci number */ - function fibRecur(uint n) public pure returns (uint) { + function fibonnaci() public { + _curr = 0; + _next = 1; } - /* Carry out calculations to find the nth Fibonacci number */ - function fibIter(uint n) public returns (uint) { + + function fibIter() public returns (uint fib) { + uint stor = _curr; + _curr = _next; + _next = stor + _next; + return stor; } + + + } diff --git a/Intro to Solidity/contracts/greeter.sol b/Intro to Solidity/contracts/greeter.sol index 730011e..a2d2054 100644 --- a/Intro to Solidity/contracts/greeter.sol +++ b/Intro to Solidity/contracts/greeter.sol @@ -1,12 +1,17 @@ pragma solidity 0.4.19; - contract Greeter { - string private greeting; + string private greeting; + function Greeter(string _greeter) public { + greeting = _greeter; } - + function greet() public view returns (string) { + return greeting; } + + + } diff --git a/Intro to Solidity/contracts/xor.sol b/Intro to Solidity/contracts/xor.sol index 70af908..44a6741 100644 --- a/Intro to Solidity/contracts/xor.sol +++ b/Intro to Solidity/contracts/xor.sol @@ -1,7 +1,13 @@ pragma solidity 0.4.19; - contract XOR { - function xor(uint a, uint b) public pure returns (uint) { + + function xor(uint num1, uint num2) public pure returns (uint) { + if (num1 == num2) { + return 0; + } else { + return 1; + } } + } diff --git a/Intro to Solidity/migrations/2_deploy_contracts.js b/Intro to Solidity/migrations/2_deploy_contracts.js index 1431ead..d495741 100644 --- a/Intro to Solidity/migrations/2_deploy_contracts.js +++ b/Intro to Solidity/migrations/2_deploy_contracts.js @@ -1,7 +1,7 @@ -var Greeter = artifacts.require("./Greeter.sol"); -var Fibonacci = artifacts.require("./Fibonacci.sol"); -var XOR = artifacts.require("./XOR.sol"); -var Concatenate = artifacts.require("./Concatenate.sol"); +var Greeter = artifacts.require("./greeter.sol"); +var Fibonacci = artifacts.require("./fibonacci.sol"); +var XOR = artifacts.require("./xor.sol"); +var Concatenate = artifacts.require("./concatenate.sol"); module.exports = function(deployer) { deployer.deploy(Greeter, "hello");