From 1192a1c53611637bc32ca61dd5f34a6138c98f5e Mon Sep 17 00:00:00 2001 From: PK Rasam Date: Sat, 12 May 2018 11:32:58 +1000 Subject: [PATCH 1/2] Created CalculatorV3.sol Refractored contract code to the latest version of Solidity. --- .DS_Store | Bin 6148 -> 6148 bytes contracts/CalculatorV3.sol | 58 +++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 contracts/CalculatorV3.sol diff --git a/.DS_Store b/.DS_Store index b77d1682b8986931eee3733ab298d0e7497c7c18..5008ddfcf53c02e82d7eee2e57c38e5672ef89f6 100644 GIT binary patch delta 70 zcmZoMXfc=|#>AjHu~2NHo+1YW5HK<@2y8ZFzQ(fIf%z8GW_AvK4xj>{$am(+{342+ UKzW7)kiy9(Jj$D6L{=~Z03S{czyJUM delta 377 zcmZoMXfc=|#>B)qF;Q%yo}wrd0|Nsi1A_oVaY0f}eiD%PGpS%>;&R4%kPI_JB0~W~ zK~g!gY))oziGjgQMkZz!RyKAHPA+aPZf{FB?l)5CnsmTfJAk*v8kz!g0Yc#t&T#q zxw(Okf{C$NZLPpJ4i0HeQ%B#(g4(V{iln(r2|D6HzrCFKmTbKcj C)M=&w diff --git a/contracts/CalculatorV3.sol b/contracts/CalculatorV3.sol new file mode 100644 index 0000000..31d99b6 --- /dev/null +++ b/contracts/CalculatorV3.sol @@ -0,0 +1,58 @@ +// pk: changed to latest version 0.4.23 +pragma solidity ^0.4.23; + +// pk: changed the contract version from 2 to 3 +contract CalculatorV3 { + + uint result; + + event NumberAdded(uint n); + event NumberSubtracted(uint n); + event NumberMultiplied(uint n); + event NumberDivided(uint n); + + // pk: changed the function name to something other than the contract name + function Calculator(uint num) public { + // constructor + result = num; + } + + // returns the result + // pk: "constant" deprecated, replaced with "view" + function getResult() public view returns (uint){ + return result; + } + + // result = result + num + function addToNumber(uint num) public returns (uint) { + result += num; + // pk: inserted "emit" before calling the event + emit NumberAdded(num); + return result; + } + + // result = result - num + function substractNumber(uint num) public returns (uint) { + result -= num; + // pk: inserted "emit" before calling the event + emit NumberSubtracted(num); + return result; + } + + // result = result * num + function multiplyWithNumber(uint num) public returns (uint) { + result *= num; + // pk: inserted "emit" before calling the event + emit NumberMultiplied(num); + return result; + } + + // result = result / num + function divideByNumber(uint num) public returns (uint) { + result /= num; + // pk: inserted "emit" before calling the event + emit NumberDivided(num); + return result; + } + +} From d535dc405689ef34ea4e3f5a6769e295903ee2e1 Mon Sep 17 00:00:00 2001 From: PK Date: Sat, 12 May 2018 12:45:05 +1000 Subject: [PATCH 2/2] added some for colour commentary to "Readme.md" --- Readme.md | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/Readme.md b/Readme.md index 55c2ceb..53b2825 100644 --- a/Readme.md +++ b/Readme.md @@ -1,12 +1,26 @@ -Part of the course on "Ethereum Blockchain DAPP Development" +## Part of the course on "Ethereum Blockchain DApp Development" http://www.ACloudFan.com -MAC/UBUNTU/LINUX Users: +### MAC/UBUNTU/LINUX Users: +Please rename truffle-config.js to config.js -Please rename truffle-config to config.js +### Sample Contracts +The following sample smart contracts are used across several lectures: +* Calculator +* CalculatorV2 +* CalculatorV3 +* interactionChannel -Calculator/CalculatorV2/interactionChannel contract is used as a sample in lectures in the course +### Objectives +The aim is to achieve the following objectives: +1. Introduction to DApp development +2. Demonstrate the use of various wallets +3. How to manage smart contracts +4. Introduction to Remix +5. Demonstrate the use of a browser based Solidity IDE for smart contract development +6. Development of contracts using Truffle framework -1 DAPP development sample and for demonstrating the use of wallets for managing contracts -2. For demonstrating use of Broweser based Solidity contract development -2. Development of contracts using Truffle framework \ No newline at end of file +#### Legend: +- DApp: Decentralised Application +- IDE: Integrated Development Environment +- Remix: Solidity IDE