diff --git a/.DS_Store b/.DS_Store index b77d168..5008ddf 100644 Binary files a/.DS_Store and b/.DS_Store differ 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 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; + } + +}