├── .DS_Store ├── Basic ├── 0_helloworld.sol ├── 10_payable.sol ├── 11_revert.sol ├── 12_assert.sol ├── 13_require.sol ├── 14_loop.sol ├── 1_int.sol ├── 2_string.sol ├── 3_bool.sol ├── 4_array.sol ├── 5_address.sol ├── 6_mapping.sol ├── 7_struct.sol ├── 8_conditon.sol └── 9_enum.sol ├── Intermediate ├── 0_visibility.sol ├── 10_1_import.sol ├── 10_2_import.sol ├── 10_destruct.sol ├── 1_constant.sol ├── 2_immutable.sol ├── 4_modifier.sol ├── 6_1_inheritance.sol ├── 6_2_inheritance.sol ├── 7_interface.sol ├── 8_abstract.sol └── 9_library.sol ├── LICENSE ├── MarketPlace └── 1_marketplace.sol ├── Project ├── .gitignore ├── LICENSE ├── assets │ ├── css │ │ └── style.css │ ├── images │ │ ├── avatar.png │ │ ├── card-main.png │ │ ├── double-card.png │ │ ├── hands.png │ │ ├── header.png │ │ ├── icons.png │ │ ├── logo.png │ │ ├── logo2.png │ │ └── tick.png │ └── js │ │ └── index.js ├── contract │ ├── abi │ │ └── tree.json │ └── tree.sol ├── index.js ├── package.json ├── public │ ├── assets │ │ ├── avatar.png │ │ ├── card-main.png │ │ ├── css │ │ │ └── style.css │ │ ├── double-card.png │ │ ├── hands.png │ │ ├── header.png │ │ ├── icons.png │ │ ├── images │ │ │ ├── avatar.png │ │ │ ├── card-main.png │ │ │ ├── double-card.png │ │ │ ├── hands.png │ │ │ ├── header.png │ │ │ ├── icons.png │ │ │ ├── logo.png │ │ │ ├── logo2.png │ │ │ └── tick.png │ │ ├── js │ │ │ └── index.js │ │ ├── logo.png │ │ ├── logo2.png │ │ └── tick.png │ ├── index.html │ └── main.js ├── src │ ├── index.html │ └── main.js ├── webpack.config.js └── yarn.lock ├── README.md └── boilerplate ├── .gitignore ├── LICENSE ├── contract └── tree.sol ├── index.js ├── package.json ├── src ├── index.html └── main.js └── webpack.config.js /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DFMlab/dapp-solidity-smart-contract-training/45bc23656281b02ac0cb2e101879ed2c7c9179e8/.DS_Store -------------------------------------------------------------------------------- /Basic/0_helloworld.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-only 2 | // Decentralized Future in Motion Limited Training Contracts v0.0.1 (Basic/0_helloworld.sol) 3 | 4 | /** 5 | * @title A Simple Hello World Solidity Smart Contract 6 | * @dev A Simple Hello World Solidity Smart Contract 7 | * for demonstrating how solidity works. 8 | * @author Decentralized Future in Motion Lab Limited 9 | */ 10 | 11 | pragma solidity ^0.8.3; 12 | 13 | /// @title Hello World contract very similar to classes in C and C++ 14 | /// @dev Hello World contract 15 | 16 | contract HelloWorld { 17 | string hello = "hello world"; 18 | function helloWorld() public view returns(string memory) { 19 | return hello; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /Basic/10_payable.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-only 2 | // Decentralized Future in Motion Limited Training Contracts v0.0.1 (Basic/10_payable.sol) 3 | 4 | /** 5 | * @title A Simple Solidity Smart Contract 6 | * @dev A Simple Solidity Smart Contract 7 | * for demonstrating payable. 8 | * @author Decentralized Future in Motion Lab Limited 9 | */ 10 | pragma solidity ^0.8.3; 11 | 12 | contract Payable { 13 | /// @notice A structure that will holds the amount and time people donated 14 | /// to the contract. This is similar to crowdfunding. 15 | /// @dev A structure that will hold account, amount, timestamp, image 16 | struct Contribution { 17 | address acount; 18 | uint256 amount; 19 | uint256 timestamp; 20 | } 21 | 22 | /// @notice A variable that holds the address of the owner 23 | /// @dev A variable that holds the address of the owner 24 | address payable owner; 25 | 26 | /// @notice The constructor is a function that is called when the contract is first deployed 27 | /// and it will set the state variable owner to the address that deployed the contract 28 | /// @dev a constructor to initialize the name variable 29 | constructor() { 30 | owner = payable(msg.sender); 31 | } 32 | 33 | /// @notice A variable that holds multiple contributions 34 | /// @dev A variable that holds an array of contributions 35 | Contribution[] _contributions; 36 | 37 | /// @notice a function that adds a contribution to the crowfunding contract 38 | /// @dev a function that adds a contribution to the state variable contributions. 39 | /// This is a public function can be called internally and externally. 40 | // a payable function will require certain amount of wei (fraction of a coin) to be sent with it 41 | // a 10^18 wei == 1 ether 42 | function donate() public payable { 43 | Contribution memory contribution = Contribution( 44 | msg.sender, 45 | msg.value, 46 | block.timestamp 47 | ); 48 | _contributions.push(contribution); 49 | } 50 | 51 | /// @notice a function that withdraws wei from the crowfunding contract 52 | /// @dev a function that transfers wei to the owner address 53 | /// This is a public function can be called internally and externally. 54 | // a payable function will require certain amount of wei to be sent with it 55 | function withdraw(uint256 amount) public payable { 56 | owner.transfer(amount); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /Basic/11_revert.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-only 2 | // Decentralized Future in Motion Limited Training Contracts v0.0.1 (Basic/11_revert.sol) 3 | 4 | /** 5 | * @title A Simple Solidity Smart Contract 6 | * @dev A Simple Solidity Smart Contract 7 | * for demonstrating revert. 8 | * @author Decentralized Future in Motion Lab Limited 9 | */ 10 | pragma solidity ^0.8.3; 11 | 12 | contract Revert { 13 | error InsufficientContribution(); 14 | 15 | error UnauthorizedAccess(string message); 16 | 17 | struct Contribution { 18 | address acount; 19 | uint256 amount; 20 | uint256 timestamp; 21 | } 22 | 23 | address payable owner; 24 | 25 | constructor() { 26 | owner = payable(msg.sender); 27 | } 28 | 29 | Contribution[] _contributions; 30 | 31 | /// @notice a function that adds a contribution to the crowfunding contract 32 | /// minimum amount to be sent is 1000 wei or else the contract will fail 33 | /// and refund the remaining gas 34 | /// @dev a function that adds a contribution to the state variable contributions. 35 | /// This is a public function can be called internally and externally. 36 | // a payable function will require certain amount of wei (fraction of a coin) to be sent with it 37 | // a 10^18 wei == 1 ether 38 | function donate() public payable { 39 | if (msg.value < 1000) { 40 | // revert(); 41 | revert InsufficientContribution(); 42 | } 43 | 44 | Contribution memory contribution = Contribution( 45 | msg.sender, 46 | msg.value, 47 | block.timestamp 48 | ); 49 | _contributions.push(contribution); 50 | } 51 | 52 | function withdraw(uint256 amount) public payable { 53 | if (msg.sender != address(owner)) { 54 | // revert("only owner can call this function"); 55 | revert UnauthorizedAccess("only owner can call this function"); 56 | } 57 | 58 | owner.transfer(amount); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /Basic/12_assert.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-only 2 | // Decentralized Future in Motion Limited Training Contracts v0.0.1 (Basic/12_assert.sol) 3 | 4 | /** 5 | * @title A Simple Solidity Smart Contract 6 | * @dev A Simple Solidity Smart Contract 7 | * for demonstrating assert. 8 | * @author Decentralized Future in Motion Lab Limited 9 | */ 10 | pragma solidity ^0.8.3; 11 | 12 | contract Revert { 13 | error InsufficientContribution(); 14 | 15 | error UnauthorizedAccess(string message); 16 | 17 | struct Contribution { 18 | address acount; 19 | uint256 amount; 20 | uint256 timestamp; 21 | } 22 | 23 | address payable owner; 24 | 25 | constructor() { 26 | owner = payable(msg.sender); 27 | } 28 | 29 | Contribution[] _contributions; 30 | 31 | /// @notice a function that adds a contribution to the crowfunding contract 32 | /// minimum amount to be sent is 1000 wei or else the contract will fail 33 | /// and refund the remaining gas 34 | /// the donate function also assert if the balance is zero after calling the function 35 | /// @dev a function that adds a contribution to the state variable contributions. 36 | /// This is a public function can be called internally and externally. 37 | // a payable function will require certain amount of wei (fraction of a coin) to be sent with it 38 | // a 10^18 wei == 1 ether 39 | function donate() public payable { 40 | if (msg.value < 1000) { 41 | // revert(); 42 | revert InsufficientContribution(); 43 | } 44 | 45 | Contribution memory contribution = Contribution( 46 | msg.sender, 47 | msg.value, 48 | block.timestamp 49 | ); 50 | _contributions.push(contribution); 51 | 52 | assert(address(this).balance > 0); 53 | } 54 | 55 | function withdraw(uint256 amount) public payable { 56 | if (msg.sender != address(owner)) { 57 | // revert("only owner can call this function"); 58 | revert UnauthorizedAccess("only owner can call this function"); 59 | } 60 | 61 | owner.transfer(amount); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /Basic/13_require.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-only 2 | // Decentralized Future in Motion Limited Training Contracts v0.0.1 (Basic/13_require.sol) 3 | 4 | /** 5 | * @title A Simple Solidity Smart Contract 6 | * @dev A Simple Solidity Smart Contract 7 | * for demonstrating require. 8 | * @author Decentralized Future in Motion Lab Limited 9 | */ 10 | pragma solidity ^0.8.3; 11 | 12 | contract Revert { 13 | error InsufficientContribution(); 14 | 15 | error UnauthorizedAccess(string message); 16 | 17 | struct Contribution { 18 | address acount; 19 | uint256 amount; 20 | uint256 timestamp; 21 | } 22 | 23 | address payable owner; 24 | 25 | constructor() { 26 | owner = payable(msg.sender); 27 | } 28 | 29 | Contribution[] _contributions; 30 | 31 | /// @notice a function that adds a contribution to the crowfunding contract 32 | /// minimum amount to be sent is 1000 wei or else the contract will fail 33 | /// and refund the remaining gas 34 | /// the donate function also assert if the balance is zero after calling the function 35 | /// @dev a function that adds a contribution to the state variable contributions. 36 | /// This is a public function can be called internally and externally. 37 | // a payable function will require certain amount of wei (fraction of a coin) to be sent with it 38 | // a 10^18 wei == 1 ether 39 | function donate() public payable { 40 | 41 | require(msg.value > 1000, "INSUFFICIENT_CONTRIBUTION"); 42 | 43 | Contribution memory contribution = Contribution( 44 | msg.sender, 45 | msg.value, 46 | block.timestamp 47 | ); 48 | _contributions.push(contribution); 49 | 50 | assert(address(this).balance > 0); 51 | } 52 | 53 | function withdraw(uint256 amount) public payable { 54 | 55 | require(msg.sender == address(owner), "only owner can call this function"); 56 | 57 | owner.transfer(amount); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /Basic/14_loop.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-only 2 | // Decentralized Future in Motion Limited Training Contracts v0.0.1 (Basic/14_loop.sol) 3 | 4 | /** 5 | * @title A Simple Solidity Smart Contract 6 | * @dev A Simple Solidity Smart Contract 7 | * for demonstrating loop. 8 | * @author Decentralized Future in Motion Lab Limited 9 | */ 10 | pragma solidity ^0.8.3; 11 | 12 | contract Enum { 13 | enum ProductStatus { 14 | IN_STOCK, 15 | OUT_OF_STOCK, 16 | BACK_ORDER 17 | } 18 | 19 | struct Product { 20 | address owner; 21 | uint256 price; 22 | string title; 23 | string image; 24 | ProductStatus status; 25 | } 26 | 27 | /// @notice A variable that holds multiple products 28 | /// @dev A variable that holds an array of products 29 | Product[] public _products; 30 | 31 | function addProduct( 32 | address owner, 33 | uint256 price, 34 | string memory title, 35 | string memory image, 36 | uint8 status 37 | ) public { 38 | _products.push( 39 | Product(owner, price, title, image, ProductStatus(status)) 40 | ); 41 | } 42 | 43 | /// @notice function that adds a products to the 44 | /// products variable using for loop 45 | /// @dev function that adds a products 46 | function addProducts( 47 | address[] memory owners, 48 | uint256[] memory prices, 49 | string[] memory titles, 50 | string[] memory images, 51 | uint8[] memory statuses 52 | ) public { 53 | uint256 ownerLength = owners.length; 54 | 55 | require(ownerLength > 0, "ZERO_LENGTH_ERROR"); 56 | 57 | require( 58 | ownerLength == prices.length && 59 | ownerLength == titles.length && 60 | ownerLength == images.length && 61 | ownerLength == statuses.length, 62 | "LENGTH_MISMATCH" 63 | ); 64 | 65 | for (uint24 i = 0; i < ownerLength; i++) { 66 | addProduct(owners[i], prices[i], titles[i], images[i], statuses[i]); 67 | } 68 | } 69 | 70 | /// @notice function that adds a products to the 71 | /// products variable using while loop 72 | /// @dev function that adds a products 73 | // function addProducts( 74 | // address[] memory owners, 75 | // uint256[] memory prices, 76 | // string[] memory titles, 77 | // string[] memory images, 78 | // uint8[] memory statuses 79 | // ) public { 80 | // uint256 ownerLength = owners.length; 81 | 82 | // require(ownerLength > 0, "ZERO_LENGTH_ERROR"); 83 | 84 | // require( 85 | // ownerLength == prices.length && 86 | // ownerLength == titles.length && 87 | // ownerLength == images.length && 88 | // ownerLength == statuses.length, 89 | // "LENGTH_MISMATCH" 90 | // ); 91 | 92 | // uint256 i = 0; 93 | 94 | // while (i < ownerLength) { 95 | // addProduct(owners[i], prices[i], titles[i], images[i], statuses[i]); 96 | // i++; 97 | // } 98 | // } 99 | } 100 | -------------------------------------------------------------------------------- /Basic/1_int.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-only 2 | // Decentralized Future in Motion Limited Training Contracts v0.0.1 (Basic/1_int.sol) 3 | 4 | /** 5 | * @title A Simple Solidity Smart Contract 6 | * @dev A Simple Solidity Smart Contract 7 | * for demonstrating set and get function. 8 | * @author Decentralized Future in Motion Lab Limited 9 | */ 10 | 11 | pragma solidity ^0.8.3; 12 | 13 | contract Integer { 14 | /// @notice A variable that holds the amount 15 | /// @dev A state variable that holds an integer value (amount) 16 | uint256 _amount; 17 | 18 | /// @notice a function that sets the amount on blockchain 19 | /// @dev a function that sets the state variable amount. 20 | /// This is a public function can be called internally and externally 21 | /// @param amount the value to be set 22 | function setAmount(uint256 amount) public { 23 | _amount = amount; // amount is a local variable 24 | } 25 | 26 | /// @notice a function that gets the amount stored on the blockchain 27 | /// @dev a function that gets the state variable amount. 28 | /// This is a public function can be called internally and externally. 29 | /// a view function will not modify the state of the blockchain 30 | /// @return uint256 from the state variable that 31 | function getAmount() public view returns (uint256) { 32 | return _amount; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Basic/2_string.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-only 2 | // Decentralized Future in Motion Limited Training Contracts v0.0.1 (Basic/2_string.sol) 3 | 4 | /** 5 | * @title A Simple Solidity Smart Contract 6 | * @dev A Simple Solidity Smart Contract 7 | * for demonstrating constructor and str memory. 8 | * @author Decentralized Future in Motion Lab Limited 9 | */ 10 | 11 | pragma solidity ^0.8.3; 12 | 13 | contract String { 14 | uint256 _amount; 15 | 16 | /// @notice A variable that holds the name 17 | /// @dev A state variable that holds an string value (name) 18 | string _name; 19 | 20 | /// @notice The constructor is a function that is called when the contract is first deployed 21 | /// @dev a constructor to initialize the name variable 22 | /// @param name the name is a local variable help in the memory 23 | constructor(string memory name) { 24 | _name = name; // local variable 25 | } 26 | 27 | /// @notice a function that gets a name 28 | /// @dev a function that gets the state variable name. 29 | /// This is a public function can be called internally and externally. 30 | /// a view function will not modify the state of the blockchain 31 | /// @return string memory from the state variable that 32 | function getName() public view returns (string memory) { 33 | return _name; 34 | } 35 | 36 | function setAmount(uint256 amount) public { 37 | _amount = amount; // amount is a local variable 38 | } 39 | 40 | function getAmount() public view returns (uint256) { 41 | return _amount; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Basic/3_bool.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-only 2 | // Decentralized Future in Motion Limited Training Contracts v0.0.1 (Basic/3_bool.sol) 3 | 4 | /** 5 | * @title A Simple Solidity Smart Contract 6 | * @dev A Simple Solidity Smart Contract 7 | * for demonstrating public visibility and bool. 8 | * @author Decentralized Future in Motion Lab Limited 9 | */ 10 | 11 | pragma solidity ^0.8.3; 12 | 13 | contract Bool { 14 | uint256 _amount; 15 | 16 | /// @notice A variable that holds the name 17 | /// @dev A state variable that holds an string value (name) 18 | /// This variable doesn't need a getter anymore 19 | /// @return string 20 | string public _name; 21 | 22 | bool _active; 23 | 24 | /// @notice The constructor is a function that is called when the contract is first deployed 25 | /// @dev a constructor to initialize the name variable 26 | /// @param name the name is a local variable help in the memory 27 | constructor(string memory name, bool active) { 28 | _name = name; // local variable 29 | _active = active; // local variable 30 | } 31 | 32 | function setAmount(uint256 amount) public { 33 | _amount = amount; // amount is a local variable 34 | } 35 | 36 | function getAmount() public view returns (uint256) { 37 | return _amount; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Basic/4_array.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-only 2 | // Decentralized Future in Motion Limited Training Contracts v0.0.1 (Basic/4_array.sol) 3 | 4 | /** 5 | * @title A Simple Solidity Smart Contract 6 | * @dev A Simple Solidity Smart Contract 7 | * for demonstrating array and overloading. 8 | * @author Decentralized Future in Motion Lab Limited 9 | */ 10 | 11 | pragma solidity ^0.8.3; 12 | 13 | contract Array { 14 | /// @notice A variable that holds the ids 15 | /// @dev A state variable that holds an array of uint8 values (ids) 16 | /// this is a variable length array 17 | uint8[] _ids; 18 | 19 | /// @notice A variable that holds the oids 20 | /// @dev A state variable that holds an array of uint8 values (oids) 21 | /// this is a variable length array 22 | uint8[2] _oids; 23 | 24 | /// @notice a function that sets the ids on blockchain 25 | /// @dev a function that sets the state variable ids. 26 | /// This is a public function can be called internally and externally 27 | /// @param ids the values to be set 28 | function setIds(uint8[] memory ids) public { 29 | _ids = ids; 30 | } 31 | 32 | /// @notice a function that sets the ids on blockchain 33 | /// @dev a function that sets the state variable ids. 34 | /// This is a public function can be called internally and externally 35 | /// @param oids the values to be set 36 | function setOids(uint8[2] memory oids) public { 37 | _oids = oids; 38 | } 39 | 40 | /// @notice a function that gets the ids 41 | /// @dev a function that gets the state variable ids. 42 | /// This is a public function can be called internally and externally. 43 | /// a view function will not modify the state of the blockchain 44 | /// @return uint8 [] memory 45 | function getIds() public view returns (uint8[] memory) { 46 | return _ids; 47 | } 48 | 49 | /// @notice a function that gets the ids 50 | /// @dev a function that gets the state variable ids. 51 | /// This is a public function can be called internally and externally. 52 | /// a view function will not modify the state of the blockchain 53 | /// @return uint8 [] memory 54 | function getIds(uint8 id) public view returns (uint8) { 55 | return _ids[id]; 56 | } 57 | 58 | /// @notice a function that gets the oids 59 | /// @dev a function that gets the state variable oids. 60 | /// This is a public function can be called internally and externally. 61 | /// a view function will not modify the state of the blockchain 62 | /// @return uint8 [] memory 63 | function getOids() public view returns (uint8[2] memory) { 64 | return _oids; 65 | } 66 | 67 | /// @notice a function that gets the oids 68 | /// @dev a function that gets the state variable oids. 69 | /// This is a public function can be called internally and externally. 70 | /// a view function will not modify the state of the blockchain 71 | /// @return uint8 [] memory 72 | function getOids(uint8 id) public view returns (uint8) { 73 | return _oids[id]; 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /Basic/5_address.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-only 2 | // Decentralized Future in Motion Limited Training Contracts v0.0.1 (Basic/5_address.sol) 3 | 4 | /** 5 | * @title Hello World Solidity Smart Contract 6 | * @dev A Simple Solidity Smart Contract 7 | * for demonstrating global variable, address and payable address. 8 | * @author Decentralized Future in Motion Lab Limited 9 | */ 10 | 11 | pragma solidity ^0.8.3; 12 | 13 | contract Address { 14 | /// @notice A variable that holds the owner address 15 | /// @dev A state variable that holds an string address (address) 16 | /// This address can not receive ether 17 | /// This variable doesn't need a getter anymore 18 | /// @return string 19 | address public _owner; 20 | 21 | /// @notice A variable that holds the account address 22 | /// @dev A state variable that holds an account address (address) 23 | /// This address can receive ether 24 | /// This variable doesn't need a getter anymore 25 | /// @return string 26 | address payable public _account; 27 | 28 | /// @notice The constructor is a function that is called when the contract is first deployed 29 | /// @dev a constructor to initialize the owner and account variable 30 | /// This function uses a global variable named msg.sender and block.timestamp 31 | constructor() { 32 | _owner = msg.sender; 33 | _account = payable(msg.sender); 34 | } 35 | 36 | /// @notice a function that gets the current blocktime 37 | /// @dev a function that gets the current block timestamp. 38 | /// This is a public function can be called internally and externally. 39 | /// a view function will not modify the state of the blockchain 40 | /// @return uint256 from the current block.timestamp 41 | function getTime() public view returns (uint256) { 42 | return block.timestamp; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Basic/6_mapping.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-only 2 | // Decentralized Future in Motion Limited Training Contracts v0.0.1 (Basic/6_address.sol) 3 | 4 | /** 5 | * @title A Simple Solidity Smart Contract 6 | * @dev A Simple Solidity Smart Contract 7 | * for demonstrating mapping. 8 | * @author Decentralized Future in Motion Lab Limited 9 | */ 10 | 11 | pragma solidity ^0.8.3; 12 | 13 | contract Mapping { 14 | /// @notice A variable that holds the balances of each address 15 | /// @dev A state variable that maps addresses to balance 16 | mapping(address => uint256) _balances; 17 | 18 | /// @notice a function that sets the balance of an address on blockchain 19 | /// @dev a function that maps an address to balance. 20 | /// This is a public function can be called internally and externally 21 | /// @param amount the value to be set 22 | /// @param account the address to map to 23 | function setBalance(uint256 amount, address account) public { 24 | _balances[account] = amount; 25 | } 26 | 27 | /// @notice a function that gets the balance of an address from the blockchain 28 | /// @dev a function that gets the balance of an address 29 | /// This is a public function can be called internally and externally. 30 | /// a view function will not modify the state of the blockchain 31 | /// @param account the address to query 32 | /// @return uint256 from the state variable that 33 | function getBalance(address account) public view returns(uint256) { 34 | return _balances[account]; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Basic/7_struct.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-only 2 | // Decentralized Future in Motion Limited Training Contracts v0.0.1 (Basic/7_struct.sol) 3 | 4 | /** 5 | * @title A Simple Solidity Smart Contract 6 | * @dev A Simple Solidity Smart Contract 7 | * for demonstrating struct. 8 | * @author Decentralized Future in Motion Lab Limited 9 | */ 10 | 11 | pragma solidity ^0.8.3; 12 | 13 | contract Struct { 14 | /// @notice A structure that will holds the address of the 15 | /// owner address, price of the product, title and image 16 | /// @dev A structure that will hold owner, price, title, image 17 | struct Product { 18 | address owner; 19 | uint256 price; 20 | string title; 21 | string image; 22 | } 23 | 24 | /// @notice A variable that holds a single product 25 | /// @dev A variable that holds a single product 26 | Product _product = 27 | Product( 28 | 0x0000000000000000000000000000000000000000, 29 | 10, 30 | "simple product", 31 | "https://product.example.com" 32 | ); 33 | 34 | /// @notice A variable that holds multiple products 35 | /// @dev A variable that holds an array of products 36 | Product[] _products; 37 | 38 | function addProduct( 39 | address owner, 40 | uint256 price, 41 | string memory title, 42 | string memory image 43 | ) public { 44 | // _products[_products.length] = Product(owner, price, title, image); 45 | _products[_products.length].owner = owner; 46 | _products[_products.length].price = price; 47 | _products[_products.length].title = title; 48 | _products[_products.length].image = image; 49 | } 50 | 51 | /// @notice a function that gets the product variable from the blocktime 52 | /// @dev a function that gets the state variable product. 53 | /// This is a public function can be called internally and externally. 54 | /// a view function will not modify the state of the blockchain 55 | /// @return Product the product structure 56 | function getProduct() public view returns (Product memory) { 57 | return _product; 58 | } 59 | 60 | /// @notice a function that gets a product by id from the blocktime 61 | /// @dev a function that gets a product by id. 62 | /// This is a public function can be called internally and externally. 63 | /// a view function will not modify the state of the blockchain 64 | /// @param id the id of the product 65 | /// @return Product the product structure 66 | function getProduct(uint256 id) public view returns (Product memory) { 67 | return _products[id]; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /Basic/8_conditon.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-only 2 | // Decentralized Future in Motion Limited Training Contracts v0.0.1 (Basic/8_condition.sol) 3 | 4 | /** 5 | * @title A Simple Solidity Smart Contract 6 | * @dev A Simple Solidity Smart Contract 7 | * for demonstrating struct. 8 | * @author Decentralized Future in Motion Lab Limited 9 | */ 10 | 11 | pragma solidity ^0.8.3; 12 | 13 | contract Condition { 14 | struct Product { 15 | address owner; 16 | uint256 price; 17 | string title; 18 | string image; 19 | } 20 | 21 | /// @notice A variable that holds multiple products 22 | /// @dev A variable that holds an array of products 23 | mapping(uint256 => Product) _exclusive; 24 | 25 | /// @notice Number of products in exclusive 26 | /// @dev A variable that holds the number of products in exclusive 27 | uint256 _exclusiveCount = 0; 28 | 29 | /// @notice A variable that holds multiple products 30 | /// @dev A variable that holds an array of products 31 | mapping(uint256 => Product) _products; 32 | 33 | /// @notice Number of products in product variable 34 | /// @dev A variable that holds the number of products in exclusive 35 | uint256 _productsCount = 0; 36 | 37 | /// @notice A variable that holds multiple products 38 | /// @dev A variable that holds an array of products 39 | mapping(uint256 => Product) _sales; 40 | 41 | /// @notice Number of products in exclusive 42 | /// @dev A variable that holds the number of products in exclusive 43 | uint256 _salesCount = 0; 44 | 45 | function addProduct( 46 | address owner, 47 | uint256 price, 48 | string memory title, 49 | string memory image, 50 | uint8 _type 51 | ) public { 52 | if (_type == 0) { 53 | _exclusive[_exclusiveCount] = Product(owner, price, title, image); 54 | _exclusiveCount++; 55 | } else if (_type == 1) { 56 | _sales[_salesCount] = Product(owner, price, title, image); 57 | _salesCount++; 58 | } else { 59 | _products[_productsCount] = Product(owner, price, title, image); 60 | _productsCount++; 61 | } 62 | } 63 | 64 | function getProduct(uint256 id, uint8 _type) 65 | public 66 | view 67 | returns (Product memory) 68 | { 69 | if (_type == 0) { 70 | return _exclusive[id]; 71 | } else if (_type == 1) { 72 | return _sales[id]; 73 | } else { 74 | return _products[id]; 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /Basic/9_enum.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-only 2 | // Decentralized Future in Motion Limited Training Contracts v0.0.1 (Basic/9_enum.sol) 3 | 4 | /** 5 | * @title A Simple Solidity Smart Contract 6 | * @dev A Simple Solidity Smart Contract 7 | * for demonstrating struct. 8 | * @author Decentralized Future in Motion Lab Limited 9 | */ 10 | pragma solidity ^0.8.3; 11 | 12 | contract Enum { 13 | enum ProductStatus { 14 | IN_STOCK, 15 | OUT_OF_STOCK, 16 | BACK_ORDER 17 | } 18 | 19 | struct Product { 20 | address owner; 21 | uint256 price; 22 | string title; 23 | string image; 24 | ProductStatus status; 25 | } 26 | 27 | /// @notice A variable that holds multiple products 28 | /// @dev A variable that holds an array of products 29 | Product[] _products; 30 | 31 | function setProduct( 32 | address owner, 33 | uint256 price, 34 | string memory title, 35 | string memory image, 36 | uint8 status 37 | ) public { 38 | _products.push( 39 | Product(owner, price, title, image, ProductStatus(status)) 40 | ); 41 | } 42 | 43 | function getProduct(uint256 id) public view returns (Product memory) { 44 | return _products[id]; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /Intermediate/0_visibility.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-only 2 | // Decentralized Future in Motion Limited Training Contracts v0.0.1 (Intermediate/0_visibility.sol) 3 | 4 | /** 5 | * @title A Simple Solidity Smart Contract 6 | * @dev A Simple Solidity Smart Contract 7 | * for demonstrating visibility. 8 | * @author Decentralized Future in Motion Lab Limited 9 | */ 10 | pragma solidity ^0.8.3; 11 | 12 | contract Visibiility { 13 | error InsufficientContribution(); 14 | 15 | error UnauthorizedAccess(string message); 16 | 17 | struct Contribution { 18 | address acount; 19 | uint256 amount; 20 | uint256 timestamp; 21 | } 22 | 23 | /// @dev A public variable can be accessed off-chain 24 | address payable public owner; 25 | 26 | /// @dev A private variable is accessible only in the contract that defines it 27 | address private _topDonor; 28 | 29 | /// @dev A publc variable can be accessed off-chain 30 | uint256 public largestDonation; 31 | 32 | constructor() { 33 | owner = payable(msg.sender); 34 | } 35 | 36 | Contribution[] _contributions; 37 | 38 | /// @notice a function that adds a contribution to the crowfunding contract 39 | /// minimum amount to be sent is 1000 wei or else the contract will fail 40 | /// and refund the remaining gas 41 | /// the donate function also assert if the balance is zero after calling the function 42 | /// @dev a function that adds a contribution to the state variable contributions. 43 | /// This is a public function can be called internally and externally. 44 | // a payable function will require certain amount of wei (fraction of a coin) to be sent with it 45 | // a 10^18 wei == 1 ether 46 | function donate() public payable { 47 | require(msg.value > 1000, "INSUFFICIENT_CONTRIBUTION"); 48 | 49 | Contribution memory contribution = Contribution( 50 | msg.sender, 51 | msg.value, 52 | block.timestamp 53 | ); 54 | _contributions.push(contribution); 55 | 56 | if (msg.value >= largestDonation) { 57 | _setTopDonor(msg.sender); 58 | } 59 | 60 | _safeCheck(); 61 | } 62 | 63 | function _safeCheck() private view { 64 | assert(address(this).balance > 0); 65 | } 66 | 67 | function _setTopDonor(address topDonor) internal { 68 | _topDonor = topDonor; 69 | } 70 | 71 | function withdraw(uint256 amount) public payable { 72 | require( 73 | msg.sender == address(owner), 74 | "only owner can call this function" 75 | ); 76 | 77 | owner.transfer(amount); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /Intermediate/10_1_import.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-only 2 | // Decentralized Future in Motion Limited Training Contracts v0.0.1 (Intermediate/10_1_import.sol) 3 | 4 | /** 5 | * @title A Simple Solidity Smart Contract 6 | * @dev A Simple Solidity Smart Contract 7 | * for demonstrating import. 8 | * @author Decentralized Future in Motion Lab Limited 9 | */ 10 | 11 | pragma solidity ^0.8.3; 12 | 13 | library Math { 14 | function add(uint256 a, uint256 b) internal pure returns (uint256) { 15 | return a + b; 16 | } 17 | 18 | function div(uint256 a, uint256 b) internal pure returns (uint256) { 19 | require(b != 0, "ZERO_DIVISION_ERROR"); 20 | return a / b; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Intermediate/10_2_import.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-only 2 | // Decentralized Future in Motion Limited Training Contracts v0.0.1 (Intermediate/10_2_import.sol) 3 | 4 | /** 5 | * @title A Simple Solidity Smart Contract 6 | * @dev A Simple Solidity Smart Contract 7 | * for demonstrating import. 8 | * @author Decentralized Future in Motion Lab Limited 9 | */ 10 | 11 | pragma solidity ^0.8.3; 12 | 13 | 14 | import "./10_1_import.sol"; 15 | 16 | abstract contract Admin { 17 | mapping(address => bool) _admins; 18 | 19 | constructor(address _address) { 20 | _admins[_address] = true; 21 | } 22 | 23 | modifier onlyAdmin() { 24 | require(_admins[msg.sender], "PERMISSION_ERROR"); 25 | _; 26 | } 27 | 28 | function addAdmin(address _address) public onlyAdmin { 29 | _admins[_address] = true; 30 | } 31 | 32 | function removeAdmin(address _address) public onlyAdmin { 33 | _admins[_address] = false; 34 | } 35 | 36 | function renounceAdmin() public virtual { 37 | _admins[msg.sender] = false; 38 | } 39 | } 40 | 41 | contract Inheritance is Admin { 42 | 43 | using Math for uint256; 44 | 45 | /// @notice A structure that will holds the address of the 46 | /// owner address, price of the product, title and image 47 | /// @dev A structure that will hold owner, price, title, image 48 | struct Product { 49 | address owner; 50 | uint256 price; 51 | string title; 52 | string image; 53 | } 54 | 55 | uint256 constant _tax = 10; 56 | 57 | /// @notice A variable that holds multiple products 58 | /// @dev A variable that holds an array of products 59 | Product[] public _products; 60 | 61 | constructor(address _address) Admin(_address) {} 62 | 63 | function addProduct( 64 | address owner, 65 | uint256 price, 66 | string memory title, 67 | string memory image 68 | ) public onlyAdmin { 69 | uint256 tax = price.div(_tax); 70 | 71 | uint256 actualPrice = price.add(tax); 72 | 73 | _products[_products.length] = Product(owner, actualPrice, title, image); 74 | } 75 | 76 | function editProduct( 77 | uint256 id, 78 | address owner, 79 | uint256 price, 80 | string memory title, 81 | string memory image 82 | ) public onlyAdmin { 83 | uint256 tax = price.div(_tax); 84 | 85 | uint256 actualPrice = price.add(tax); 86 | 87 | _products[id] = Product(owner, actualPrice, title, image); 88 | } 89 | 90 | function renounceAdmin() public pure override { 91 | revert("RENOUNCE_ERROR"); 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /Intermediate/10_destruct.sol: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DFMlab/dapp-solidity-smart-contract-training/45bc23656281b02ac0cb2e101879ed2c7c9179e8/Intermediate/10_destruct.sol -------------------------------------------------------------------------------- /Intermediate/1_constant.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-only 2 | // Decentralized Future in Motion Limited Training Contracts v0.0.1 (Basic/1_constant.sol) 3 | 4 | /** 5 | * @title A Simple Solidity Smart Contract 6 | * @dev A Simple Solidity Smart Contract 7 | * for demonstrating constant. 8 | * @author Decentralized Future in Motion Lab Limited 9 | */ 10 | pragma solidity ^0.8.3; 11 | 12 | contract Visibiility { 13 | error InsufficientContribution(); 14 | 15 | error UnauthorizedAccess(string message); 16 | 17 | struct Contribution { 18 | address acount; 19 | uint256 amount; 20 | uint256 timestamp; 21 | } 22 | 23 | address payable public owner; 24 | 25 | /// @dev A constant variable can not be re-assigned 26 | uint256 constant public minimumDonation = 1*10**10; 27 | 28 | /// @dev A constant variable can not be re-assigned 29 | uint256 constant public maximumDonation = 1*10**19; 30 | 31 | address private _topDonor; 32 | 33 | uint256 public largestDonation; 34 | 35 | constructor() { 36 | owner = payable(msg.sender); 37 | } 38 | 39 | Contribution[] _contributions; 40 | 41 | /// @notice a function that adds a contribution to the crowfunding contract 42 | /// minimum amount to be sent is 1000 wei or else the contract will fail 43 | /// and refund the remaining gas 44 | /// the donate function also assert if the balance is zero after calling the function 45 | /// @dev a function that adds a contribution to the state variable contributions. 46 | /// This is a public function can be called internally and externally. 47 | // a payable function will require certain amount of wei (fraction of a coin) to be sent with it 48 | // a 10^18 wei == 1 ether 49 | function donate() public payable { 50 | require(msg.value >= minimumDonation, "INSUFFICIENT_CONTRIBUTION"); 51 | require(msg.value <= maximumDonation, "EXCEED_CONTRIBUTION_LIMIT"); 52 | 53 | Contribution memory contribution = Contribution( 54 | msg.sender, 55 | msg.value, 56 | block.timestamp 57 | ); 58 | _contributions.push(contribution); 59 | 60 | if (msg.value >= largestDonation) { 61 | _setTopDonor(msg.sender); 62 | } 63 | 64 | _safeCheck(); 65 | } 66 | 67 | function _safeCheck() private view { 68 | assert(address(this).balance > 0); 69 | } 70 | 71 | function _setTopDonor(address topDonor) internal { 72 | _topDonor = topDonor; 73 | } 74 | 75 | function withdraw(uint256 amount) public payable { 76 | require( 77 | msg.sender == address(owner), 78 | "only owner can call this function" 79 | ); 80 | 81 | owner.transfer(amount); 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /Intermediate/2_immutable.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-only 2 | // Decentralized Future in Motion Limited Training Contracts v0.0.1 (Intermediate/2_immutable.sol) 3 | 4 | /** 5 | * @title A Simple Solidity Smart Contract 6 | * @dev A Simple Solidity Smart Contract 7 | * for demonstrating immutability. 8 | * @author Decentralized Future in Motion Lab Limited 9 | */ 10 | pragma solidity ^0.8.3; 11 | 12 | contract Visibiility { 13 | error InsufficientContribution(); 14 | 15 | error UnauthorizedAccess(string message); 16 | 17 | struct Contribution { 18 | address acount; 19 | uint256 amount; 20 | uint256 timestamp; 21 | } 22 | 23 | /// @dev A constant variable can be initialized only once 24 | address payable public immutable owner; 25 | 26 | /// @dev A constant variable can be initialized only once 27 | uint256 public immutable _minimumDonation; 28 | 29 | /// @dev A constant variable can be initialized only once 30 | uint256 public immutable _maximumDonation; 31 | 32 | address private _topDonor; 33 | 34 | uint256 public largestDonation; 35 | 36 | constructor(uint256 minimumDonation, uint256 maximumDonation) { 37 | owner = payable(msg.sender); 38 | _minimumDonation = minimumDonation; 39 | _maximumDonation = maximumDonation; 40 | } 41 | 42 | Contribution[] _contributions; 43 | 44 | /// @notice a function that adds a contribution to the crowfunding contract 45 | /// minimum amount to be sent is 1000 wei or else the contract will fail 46 | /// and refund the remaining gas 47 | /// the donate function also assert if the balance is zero after calling the function 48 | /// @dev a function that adds a contribution to the state variable contributions. 49 | /// This is a public function can be called internally and externally. 50 | // a payable function will require certain amount of wei (fraction of a coin) to be sent with it 51 | // a 10^18 wei == 1 ether 52 | function donate() public payable { 53 | require(msg.value >= _minimumDonation, "INSUFFICIENT_CONTRIBUTION"); 54 | require(msg.value <= _maximumDonation, "EXCEED_CONTRIBUTION_LIMIT"); 55 | 56 | Contribution memory contribution = Contribution( 57 | msg.sender, 58 | msg.value, 59 | block.timestamp 60 | ); 61 | _contributions.push(contribution); 62 | 63 | if (msg.value >= largestDonation) { 64 | _setTopDonor(msg.sender); 65 | } 66 | 67 | _safeCheck(); 68 | } 69 | 70 | function _safeCheck() private view { 71 | assert(address(this).balance > 0); 72 | } 73 | 74 | function _setTopDonor(address topDonor) internal { 75 | _topDonor = topDonor; 76 | } 77 | 78 | function withdraw(uint256 amount) public payable { 79 | require( 80 | msg.sender == address(owner), 81 | "only owner can call this function" 82 | ); 83 | 84 | owner.transfer(amount); 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /Intermediate/4_modifier.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-only 2 | // Decentralized Future in Motion Limited Training Contracts v0.0.1 (Intermediate/4_modifier.sol) 3 | 4 | /** 5 | * @title A Simple Solidity Smart Contract 6 | * @dev A Simple Solidity Smart Contract 7 | * for demonstrating modifier. 8 | * @author Decentralized Future in Motion Lab Limited 9 | */ 10 | 11 | pragma solidity ^0.8.3; 12 | 13 | contract Modifier { 14 | /// @notice A structure that will holds the address of the 15 | /// owner address, price of the product, title and image 16 | /// @dev A structure that will hold owner, price, title, image 17 | struct Product { 18 | address owner; 19 | uint256 price; 20 | string title; 21 | string image; 22 | } 23 | 24 | address _owner; 25 | 26 | constructor() { 27 | _owner = msg.sender; 28 | } 29 | 30 | modifier onlyOwner() { 31 | require(msg.sender == _owner, "PERMISSION_ERROR"); 32 | _; 33 | } 34 | 35 | /// @notice A variable that holds multiple products 36 | /// @dev A variable that holds an array of products 37 | Product[] public _products; 38 | 39 | /// @dev a function that adds a product 40 | // due to the set modifier, only owner can call the function 41 | function addProduct( 42 | address owner, 43 | uint256 price, 44 | string memory title, 45 | string memory image 46 | ) public onlyOwner { 47 | _products[_products.length] = Product(owner, price, title, image); 48 | } 49 | 50 | /// @dev a function that edits a product 51 | // due to the set modifier, only owner can call the function 52 | function editProduct( 53 | uint256 id, 54 | address owner, 55 | uint256 price, 56 | string memory title, 57 | string memory image 58 | ) public onlyOwner { 59 | _products[id] = Product(owner, price, title, image); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /Intermediate/6_1_inheritance.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-only 2 | // Decentralized Future in Motion Limited Training Contracts v0.0.1 (Intermediate/6_1_inheritance.sol) 3 | 4 | /** 5 | * @title A Simple Solidity Smart Contract 6 | * @dev A Simple Solidity Smart Contract 7 | * for demonstrating inheritance. 8 | * @author Decentralized Future in Motion Lab Limited 9 | */ 10 | 11 | pragma solidity ^0.8.3; 12 | 13 | contract Admin { 14 | mapping(address => bool) _admins; 15 | 16 | constructor() { 17 | _admins[msg.sender] = true; 18 | } 19 | 20 | modifier onlyAdmin() { 21 | require(_admins[msg.sender], "PERMISSION_ERROR"); 22 | _; 23 | } 24 | 25 | function addAdmin(address _address) public onlyAdmin { 26 | _admins[_address] = true; 27 | } 28 | 29 | function removeAdmin(address _address) public onlyAdmin { 30 | _admins[_address] = false; 31 | } 32 | 33 | function renounceAdmin() public { 34 | _admins[msg.sender] = false; 35 | } 36 | } 37 | 38 | contract Inheritance is Admin { 39 | /// @notice A structure that will holds the address of the 40 | /// owner address, price of the product, title and image 41 | /// @dev A structure that will hold owner, price, title, image 42 | struct Product { 43 | address owner; 44 | uint256 price; 45 | string title; 46 | string image; 47 | } 48 | 49 | /// @notice A variable that holds multiple products 50 | /// @dev A variable that holds an array of products 51 | Product[] public _products; 52 | 53 | function addProduct( 54 | address owner, 55 | uint256 price, 56 | string memory title, 57 | string memory image 58 | ) public onlyAdmin { 59 | _products[_products.length] = Product(owner, price, title, image); 60 | } 61 | 62 | function editProduct( 63 | uint256 id, 64 | address owner, 65 | uint256 price, 66 | string memory title, 67 | string memory image 68 | ) public onlyAdmin { 69 | _products[id] = Product(owner, price, title, image); 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /Intermediate/6_2_inheritance.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-only 2 | // Decentralized Future in Motion Limited Training Contracts v0.0.1 (Intermediate/6_2_inheritance.sol) 3 | 4 | /** 5 | * @title A Simple Solidity Smart Contract 6 | * @dev A Simple Solidity Smart Contract 7 | * for demonstrating inheritance. 8 | * @author Decentralized Future in Motion Lab Limited 9 | */ 10 | 11 | pragma solidity ^0.8.3; 12 | 13 | contract Admin { 14 | mapping(address => bool) _admins; 15 | 16 | constructor(address _address) { 17 | _admins[_address] = true; 18 | } 19 | 20 | modifier onlyAdmin() { 21 | require(_admins[msg.sender], "PERMISSION_ERROR"); 22 | _; 23 | } 24 | 25 | function addAdmin(address _address) public onlyAdmin { 26 | _admins[_address] = true; 27 | } 28 | 29 | function removeAdmin(address _address) public onlyAdmin { 30 | _admins[_address] = false; 31 | } 32 | 33 | function renounceAdmin() public { 34 | _admins[msg.sender] = false; 35 | } 36 | } 37 | 38 | contract Inheritance is Admin { 39 | /// @notice A structure that will holds the address of the 40 | /// owner address, price of the product, title and image 41 | /// @dev A structure that will hold owner, price, title, image 42 | struct Product { 43 | address owner; 44 | uint256 price; 45 | string title; 46 | string image; 47 | } 48 | 49 | /// @notice A variable that holds multiple products 50 | /// @dev A variable that holds an array of products 51 | Product[] public _products; 52 | 53 | constructor(address _address) Admin(_address) { 54 | } 55 | 56 | function addProduct( 57 | address owner, 58 | uint256 price, 59 | string memory title, 60 | string memory image 61 | ) public onlyAdmin { 62 | _products[_products.length] = Product(owner, price, title, image); 63 | } 64 | 65 | function editProduct( 66 | uint256 id, 67 | address owner, 68 | uint256 price, 69 | string memory title, 70 | string memory image 71 | ) public onlyAdmin { 72 | _products[id] = Product(owner, price, title, image); 73 | } 74 | 75 | } 76 | -------------------------------------------------------------------------------- /Intermediate/7_interface.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-only 2 | // Decentralized Future in Motion Limited Training Contracts v0.0.1 (Intermediate/7_interface.sol) 3 | 4 | /** 5 | * @title A Simple Solidity Smart Contract 6 | * @dev A Simple Solidity Smart Contract 7 | * for demonstrating interface. 8 | * @author Decentralized Future in Motion Lab Limited 9 | */ 10 | 11 | pragma solidity ^0.8.3; 12 | 13 | interface Interface { 14 | /// @notice A structure that will holds the address of the 15 | /// owner address, price of the product, title and image 16 | /// @dev A structure that will hold owner, price, title, image 17 | struct Product { 18 | address owner; 19 | uint256 price; 20 | string title; 21 | string image; 22 | } 23 | 24 | function addProduct( 25 | address, 26 | uint256, 27 | string memory, 28 | string memory 29 | ) external; 30 | 31 | function editProduct( 32 | uint256, 33 | address, 34 | uint256, 35 | string memory, 36 | string memory 37 | ) external; 38 | 39 | function getProduct(uint256 id) external view returns (Product memory); 40 | } 41 | 42 | contract Admin { 43 | mapping(address => bool) _admins; 44 | 45 | constructor(address _address) { 46 | _admins[_address] = true; 47 | } 48 | 49 | modifier onlyAdmin() { 50 | require(_admins[msg.sender], "PERMISSION_ERROR"); 51 | _; 52 | } 53 | 54 | function addAdmin(address _address) public onlyAdmin { 55 | _admins[_address] = true; 56 | } 57 | 58 | function removeAdmin(address _address) public onlyAdmin { 59 | _admins[_address] = false; 60 | } 61 | 62 | function renounceAdmin() public { 63 | _admins[msg.sender] = false; 64 | } 65 | } 66 | 67 | contract Inheritance is Admin, Interface { 68 | /// @notice A variable that holds multiple products 69 | /// @dev A variable that holds an array of products 70 | Product[] public _products; 71 | 72 | constructor(address _address) Admin(_address) {} 73 | 74 | function addProduct( 75 | address owner, 76 | uint256 price, 77 | string memory title, 78 | string memory image 79 | ) public onlyAdmin { 80 | _products[_products.length] = Product(owner, price, title, image); 81 | } 82 | 83 | function editProduct( 84 | uint256 id, 85 | address owner, 86 | uint256 price, 87 | string memory title, 88 | string memory image 89 | ) public onlyAdmin { 90 | _products[id] = Product(owner, price, title, image); 91 | } 92 | 93 | } 94 | -------------------------------------------------------------------------------- /Intermediate/8_abstract.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-only 2 | // Decentralized Future in Motion Limited Training Contracts v0.0.1 (Intermediate/8_abstract.sol) 3 | 4 | /** 5 | * @title A Simple Solidity Smart Contract 6 | * @dev A Simple Solidity Smart Contract 7 | * for demonstrating abstraction. 8 | * @author Decentralized Future in Motion Lab Limited 9 | */ 10 | 11 | pragma solidity ^0.8.3; 12 | 13 | abstract contract Admin { 14 | 15 | mapping(address => bool) _admins; 16 | 17 | constructor(address _address) { 18 | _admins[_address] = true; 19 | } 20 | 21 | modifier onlyAdmin() { 22 | require(_admins[msg.sender], "PERMISSION_ERROR"); 23 | _; 24 | } 25 | 26 | function addAdmin(address _address) public onlyAdmin { 27 | _admins[_address] = true; 28 | } 29 | 30 | function removeAdmin(address _address) public onlyAdmin { 31 | _admins[_address] = false; 32 | } 33 | 34 | function renounceAdmin() public virtual { 35 | _admins[msg.sender] = false; 36 | } 37 | } 38 | 39 | contract Inheritance is Admin { 40 | /// @notice A structure that will holds the address of the 41 | /// owner address, price of the product, title and image 42 | /// @dev A structure that will hold owner, price, title, image 43 | struct Product { 44 | address owner; 45 | uint256 price; 46 | string title; 47 | string image; 48 | } 49 | 50 | /// @notice A variable that holds multiple products 51 | /// @dev A variable that holds an array of products 52 | Product[] public _products; 53 | 54 | constructor(address _address) Admin(_address) {} 55 | 56 | function addProduct( 57 | address owner, 58 | uint256 price, 59 | string memory title, 60 | string memory image 61 | ) public onlyAdmin { 62 | _products[_products.length] = Product(owner, price, title, image); 63 | } 64 | 65 | function editProduct( 66 | uint256 id, 67 | address owner, 68 | uint256 price, 69 | string memory title, 70 | string memory image 71 | ) public onlyAdmin { 72 | _products[id] = Product(owner, price, title, image); 73 | } 74 | 75 | function renounceAdmin() public pure override { 76 | revert("RENOUNCE_ERROR"); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /Intermediate/9_library.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-only 2 | // Decentralized Future in Motion Limited Training Contracts v0.0.1 (Intermediate/9_library.sol) 3 | 4 | /** 5 | * @title A Simple Solidity Smart Contract 6 | * @dev A Simple Solidity Smart Contract 7 | * for demonstrating library. 8 | * @author Decentralized Future in Motion Lab Limited 9 | */ 10 | 11 | pragma solidity ^0.8.3; 12 | 13 | library Math { 14 | function add(uint256 a, uint256 b) internal pure returns (uint256) { 15 | return a + b; 16 | } 17 | 18 | function div(uint256 a, uint256 b) internal pure returns (uint256) { 19 | require(b != 0, "ZERO_DIVISION_ERROR"); 20 | return a / b; 21 | } 22 | } 23 | 24 | abstract contract Admin { 25 | mapping(address => bool) _admins; 26 | 27 | constructor(address _address) { 28 | _admins[_address] = true; 29 | } 30 | 31 | modifier onlyAdmin() { 32 | require(_admins[msg.sender], "PERMISSION_ERROR"); 33 | _; 34 | } 35 | 36 | function addAdmin(address _address) public onlyAdmin { 37 | _admins[_address] = true; 38 | } 39 | 40 | function removeAdmin(address _address) public onlyAdmin { 41 | _admins[_address] = false; 42 | } 43 | 44 | function renounceAdmin() public virtual { 45 | _admins[msg.sender] = false; 46 | } 47 | } 48 | 49 | contract Inheritance is Admin { 50 | using Math for uint256; 51 | 52 | /// @notice A structure that will holds the address of the 53 | /// owner address, price of the product, title and image 54 | /// @dev A structure that will hold owner, price, title, image 55 | struct Product { 56 | address owner; 57 | uint256 price; 58 | string title; 59 | string image; 60 | } 61 | 62 | uint256 constant _tax = 10; 63 | 64 | /// @notice A variable that holds multiple products 65 | /// @dev A variable that holds an array of products 66 | Product[] public _products; 67 | 68 | constructor(address _address) Admin(_address) {} 69 | 70 | function addProduct( 71 | address owner, 72 | uint256 price, 73 | string memory title, 74 | string memory image 75 | ) public onlyAdmin { 76 | uint256 tax = price.div(_tax); 77 | 78 | uint256 actualPrice = price.add(tax); 79 | 80 | _products[_products.length] = Product(owner, actualPrice, title, image); 81 | } 82 | 83 | function editProduct( 84 | uint256 id, 85 | address owner, 86 | uint256 price, 87 | string memory title, 88 | string memory image 89 | ) public onlyAdmin { 90 | uint256 tax = price.div(_tax); 91 | 92 | uint256 actualPrice = price.add(tax); 93 | 94 | _products[id] = Product(owner, actualPrice, title, image); 95 | } 96 | 97 | function renounceAdmin() public pure override { 98 | revert("RENOUNCE_ERROR"); 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /MarketPlace/1_marketplace.sol: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DFMlab/dapp-solidity-smart-contract-training/45bc23656281b02ac0cb2e101879ed2c7c9179e8/MarketPlace/1_marketplace.sol -------------------------------------------------------------------------------- /Project/.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | lerna-debug.log* 8 | 9 | # Diagnostic reports (https://nodejs.org/api/report.html) 10 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 11 | 12 | # Runtime data 13 | pids 14 | *.pid 15 | *.seed 16 | *.pid.lock 17 | 18 | # Directory for instrumented libs generated by jscoverage/JSCover 19 | lib-cov 20 | 21 | # Coverage directory used by tools like istanbul 22 | coverage 23 | *.lcov 24 | 25 | # nyc test coverage 26 | .nyc_output 27 | 28 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 29 | .grunt 30 | 31 | # Bower dependency directory (https://bower.io/) 32 | bower_components 33 | 34 | # node-waf configuration 35 | .lock-wscript 36 | 37 | # Compiled binary addons (https://nodejs.org/api/addons.html) 38 | build/Release 39 | 40 | # Dependency directories 41 | node_modules/ 42 | jspm_packages/ 43 | 44 | # TypeScript v1 declaration files 45 | typings/ 46 | 47 | # TypeScript cache 48 | *.tsbuildinfo 49 | 50 | # Optional npm cache directory 51 | .npm 52 | 53 | # Optional eslint cache 54 | .eslintcache 55 | 56 | # Microbundle cache 57 | .rpt2_cache/ 58 | .rts2_cache_cjs/ 59 | .rts2_cache_es/ 60 | .rts2_cache_umd/ 61 | 62 | # Optional REPL history 63 | .node_repl_history 64 | 65 | # Output of 'npm pack' 66 | *.tgz 67 | 68 | # Yarn Integrity file 69 | .yarn-integrity 70 | 71 | # dotenv environment variables file 72 | .env 73 | .env.test 74 | 75 | # parcel-bundler cache (https://parceljs.org/) 76 | .cache 77 | 78 | # Next.js build output 79 | .next 80 | 81 | # Nuxt.js build / generate output 82 | .nuxt 83 | dist 84 | 85 | # Gatsby files 86 | .cache/ 87 | # Comment in the public line in if your project uses Gatsby and *not* Next.js 88 | # https://nextjs.org/blog/next-9-1#public-directory-support 89 | # public 90 | 91 | # vuepress build output 92 | .vuepress/dist 93 | 94 | # Serverless directories 95 | .serverless/ 96 | 97 | # FuseBox cache 98 | .fusebox/ 99 | 100 | # DynamoDB Local files 101 | .dynamodb/ 102 | 103 | # TernJS port file 104 | .tern-port 105 | -------------------------------------------------------------------------------- /Project/assets/css/style.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | font-family: "Clash Display", sans-serif; 4 | } 5 | 6 | nav { 7 | display: flex; 8 | padding: 20px; 9 | color: white; 10 | 11 | margin: 0px 20px; 12 | justify-content: space-between; 13 | } 14 | [hidden] { 15 | display: none; 16 | } 17 | 18 | nav > div > a { 19 | text-decoration: none; 20 | color: white; 21 | margin-left: 10px; 22 | } 23 | 24 | .main-paragraph { 25 | font-weight: 400; 26 | font-size: 14px; 27 | 28 | text-transform: uppercase; 29 | line-height: 14.76px; 30 | } 31 | 32 | .links { 33 | display: flex; 34 | justify-content: space-between; 35 | } 36 | 37 | p { 38 | margin: 0; 39 | } 40 | 41 | .card { 42 | width: 320px; 43 | margin: 10px; 44 | background-color: #000000; 45 | } 46 | 47 | .card-body { 48 | padding: 15px 35px; 49 | } 50 | .img-holder { 51 | margin-top: 15px; 52 | } 53 | 54 | .card-img { 55 | width: 240px; 56 | height: 160px; 57 | } 58 | .top-creator { 59 | display: flex; 60 | margin-top: 5%; 61 | position: relative; 62 | flex-direction: column; 63 | justify-content: center; 64 | text-align: center; 65 | } 66 | 67 | .top-header { 68 | font-size: 48px; 69 | line-height: 83px; 70 | } 71 | 72 | .top-body { 73 | color: #676767; 74 | font-size: 16px; 75 | line-height: 32px; 76 | } 77 | .overflow { 78 | width: 120%; 79 | overflow-x: hidden; 80 | } 81 | 82 | .top-card { 83 | display: flex; 84 | justify-content: flex-start; 85 | align-items: center; 86 | margin: 10px; 87 | border: 1px solid #000000; 88 | text-align: left; 89 | border-radius: 50px; 90 | width: 315px; 91 | height: 80px; 92 | } 93 | .top-card > img { 94 | width: 49px; 95 | margin-left: 10px; 96 | height: 49px; 97 | } 98 | .top-card-user { 99 | font-size: 16px; 100 | line-height: 19px; 101 | font-weight: 500; 102 | } 103 | .top-card-item { 104 | color: #676767; 105 | font-size: 14px; 106 | line-height: 18px; 107 | } 108 | 109 | .avatar-div { 110 | display: flex; 111 | background-color: #fff; 112 | padding: 5px 18px; 113 | color: black; 114 | margin-top: 10%; 115 | border-radius: 20px; 116 | width: 9rem; 117 | height: 24px; 118 | } 119 | 120 | .avatar-div > p { 121 | font-weight: 500; 122 | margin-left: 10px; 123 | } 124 | 125 | .card:hover { 126 | background: linear-gradient( 127 | 159.38deg, 128 | #181187 9.6%, 129 | #e85556 39.44%, 130 | #1166f1 64.66%, 131 | #ca2c74 86.91% 132 | ); 133 | } 134 | 135 | .header { 136 | font-size: 62px; 137 | text-transform: capitalize; 138 | margin: 10px 0px; 139 | line-height: 83px; 140 | } 141 | 142 | .header-body { 143 | font-size: 16px; 144 | line-height: 32px; 145 | font-weight: 400; 146 | } 147 | 148 | .featured { 149 | color: #000000; 150 | padding: 20px; 151 | margin-top: 10%; 152 | } 153 | 154 | .featured-header { 155 | font-size: 48px; 156 | font-weight: 400; 157 | display: flex; 158 | margin: 20px 0px; 159 | justify-content: center; 160 | } 161 | 162 | .hero-section { 163 | display: grid; 164 | background-color: black; 165 | color: white; 166 | padding: 20px; 167 | grid-template-columns: 50% 20%; 168 | gap: 10%; 169 | } 170 | 171 | .absolute { 172 | position: absolute; 173 | } 174 | 175 | #menu > a { 176 | text-decoration: none; 177 | color: black; 178 | } 179 | 180 | .main { 181 | padding: 20px; 182 | margin-top: 75px; 183 | } 184 | 185 | .main > button { 186 | background-color: white; 187 | color: black; 188 | width: 192px; 189 | height: 57px; 190 | margin: 20px 0px; 191 | border: 0; 192 | font-weight: 500; 193 | line-height: 17.22px; 194 | } 195 | 196 | .supportedBy { 197 | text-transform: uppercase; 198 | } 199 | 200 | .about { 201 | padding: 5px 10px; 202 | display: grid; 203 | grid-template-columns: 50% 40%; 204 | } 205 | .get-started { 206 | margin-top: 30%; 207 | color: white; 208 | background: linear-gradient( 209 | 99.09deg, 210 | #000000 90.12%, 211 | rgba(0, 0, 0, 0) 88.59% 212 | ); 213 | } 214 | .started-div { 215 | display: flex; 216 | padding-left: 5%; 217 | justify-content: space-between; 218 | align-items: center; 219 | } 220 | .started-button { 221 | background-color: #fff; 222 | width: 201px; 223 | height: 57px; 224 | border: none; 225 | } 226 | .started-button > p { 227 | font-weight: 600; 228 | font-weight: 14px; 229 | } 230 | .started-header { 231 | font-size: 48px; 232 | line-height: 60px; 233 | font-weight: 500; 234 | } 235 | .aboutText { 236 | color: #676767; 237 | margin-top: 10px; 238 | text-transform: uppercase; 239 | font-size: 12px; 240 | line-height: 15px; 241 | } 242 | 243 | .aboutHeader { 244 | font-size: 64px; 245 | margin-top: 10px; 246 | color: #000000; 247 | } 248 | 249 | .aboutBody { 250 | color: #676767; 251 | margin-top: 10px; 252 | 253 | font-size: 16px; 254 | line-height: 32px; 255 | } 256 | 257 | .imgAbout { 258 | background-image: url("/assets/images/double-card.png"); 259 | background-position: center; 260 | background-size: contain; 261 | background-repeat: no-repeat; 262 | margin-top: 20%; 263 | } 264 | 265 | .hr { 266 | margin: 30px 0px; 267 | width: 100%; 268 | height: 1px; 269 | background: white; 270 | } 271 | 272 | .support-header { 273 | font-weight: 500; 274 | font-size: 48px; 275 | line-height: 83px; 276 | } 277 | 278 | .support { 279 | display: flex; 280 | margin-top: 10px; 281 | align-items: center; 282 | justify-content: space-between; 283 | width: 75%; 284 | } 285 | 286 | .support > img { 287 | width: 67px; 288 | height: 65px; 289 | } 290 | 291 | .card-title { 292 | font-size: 20px; 293 | line-height: 24px; 294 | margin-top: 10px; 295 | font-weight: 500; 296 | color: white; 297 | } 298 | .card-subtitle { 299 | margin-top: 40px; 300 | font-size: 10px; 301 | color: white; 302 | 303 | font-weight: 500; 304 | } 305 | .card-price { 306 | font-size: 20px; 307 | color: white; 308 | 309 | font-weight: 600; 310 | line-height: 24px; 311 | } 312 | .card-money { 313 | font-size: 12px; 314 | color: white; 315 | line-height: 14px; 316 | } 317 | .button-wrapper { 318 | margin-top: 20%; 319 | display: flex; 320 | justify-content: space-between; 321 | align-items: center; 322 | } 323 | .buyButton { 324 | width: 140px; 325 | height: 40px; 326 | font-weight: 500; 327 | background-color: #000000; 328 | border: 1px solid white; 329 | color: white; 330 | display: flex; 331 | align-items: center; 332 | justify-content: center; 333 | } 334 | .imgHeader { 335 | background-image: url("/assets/images/header.png"); 336 | background-position: center; 337 | background-size: contain; 338 | background-repeat: no-repeat; 339 | width: 500px; 340 | height: 800px; 341 | } 342 | 343 | .nav-button { 344 | border: 1px solid white; 345 | color: white; 346 | background-color: black; 347 | padding: 15px 30px; 348 | } 349 | .hamburger { 350 | cursor: pointer; 351 | width: 24px; 352 | height: 24px; 353 | transition: all 0.25s; 354 | background-color: #000000; 355 | border: none; 356 | position: relative; 357 | } 358 | 359 | .hamburger-top, 360 | .hamburger-middle, 361 | .hamburger-bottom { 362 | position: absolute; 363 | width: 24px; 364 | top: 0; 365 | left: 0; 366 | height: 1.5px; 367 | background-color: #fff; 368 | transform: rotate(0); 369 | transition: all 0.5s; 370 | } 371 | 372 | .hamburger-middle { 373 | width: 20px; 374 | margin-left: 4px; 375 | } 376 | 377 | .hamburger-middle { 378 | transform: translateY(7px); 379 | } 380 | 381 | .hamburger-bottom { 382 | transform: translateY(14px); 383 | } 384 | 385 | .hidden { 386 | display: none; 387 | } 388 | 389 | .open { 390 | /* transform: rotate(90deg); */ 391 | transform: translateY(0px); 392 | } 393 | 394 | .open .hamburger-top { 395 | transform: rotate(45deg) translateY(6px) translate(6px); 396 | } 397 | 398 | .open .hamburger-middle { 399 | display: none; 400 | } 401 | 402 | .open .hamburger-bottom { 403 | transform: rotate(-45deg) translateY(6px) translate(-6px); 404 | } 405 | 406 | .hero { 407 | background-color: black; 408 | color: white; 409 | } 410 | .img-wrapper { 411 | display: flex; 412 | justify-content: space-between; 413 | align-items: center; 414 | width: 40%; 415 | } 416 | .footer-wrapper { 417 | display: flex; 418 | margin-top: 10%; 419 | padding: 20px; 420 | align-items: center; 421 | justify-content: space-between; 422 | } 423 | .footer-links > a { 424 | color: black; 425 | font-size: 14px; 426 | font-weight: 500; 427 | margin-left: 40px; 428 | text-decoration: none; 429 | } 430 | .email-wrapper { 431 | display: flex; 432 | flex-direction: column; 433 | align-items: flex-end; 434 | margin-right: 40px; 435 | } 436 | .card-wrapper { 437 | display: flex; 438 | align-items: center; 439 | justify-content: center; 440 | flex-wrap: wrap; 441 | } 442 | .card-wrapper-rounded { 443 | display: flex; 444 | flex-wrap: wrap; 445 | } 446 | 447 | .email-wrapper > p { 448 | text-align: right; 449 | } 450 | .footer-hr { 451 | border-top: 1px solid rgba(0, 0, 0, 0.3); 452 | width: 100%; 453 | height: 1px; 454 | } 455 | .footer-body { 456 | padding: 40px; 457 | display: flex; 458 | align-items: center; 459 | justify-content: space-between; 460 | } 461 | .footer-body > p { 462 | font-size: 12px; 463 | } 464 | 465 | @media (max-width: 800px) { 466 | .support { 467 | width: 100%; 468 | justify-content: space-between; 469 | } 470 | .hero-section { 471 | display: block; 472 | } 473 | .header { 474 | text-align: center; 475 | } 476 | .imgHeader { 477 | width: 100%; 478 | height: 100%; 479 | } 480 | 481 | .started-div { 482 | display: flex; 483 | flex-direction: column; 484 | padding: 0; 485 | justify-content: center; 486 | } 487 | .footer-wrapper { 488 | justify-content: center; 489 | padding: 0px; 490 | width: 100%; 491 | flex-direction: column; 492 | } 493 | .img-wrapper { 494 | flex-direction: column; 495 | width: 100%; 496 | } 497 | .footer-links { 498 | display: flex; 499 | margin: 20px 0px; 500 | width: 100%; 501 | } 502 | .email-wrapper { 503 | align-items: center; 504 | margin-left: 10%; 505 | margin-top: 5%; 506 | margin-bottom: 5%; 507 | } 508 | 509 | .get-started { 510 | background-color: #000000; 511 | width: 100%; 512 | 513 | padding: 10px 0px; 514 | } 515 | .top-card { 516 | padding: 10px 6%; 517 | } 518 | .card-wrapper-rounded { 519 | justify-content: center; 520 | align-items: center; 521 | flex-wrap: nowrap; 522 | } 523 | 524 | .started-div > p { 525 | font-size: 25px; 526 | margin-bottom: 20px; 527 | } 528 | .started-div > button { 529 | margin-bottom: 20px; 530 | height: 40px; 531 | } 532 | .started-div > img { 533 | width: 300px; 534 | margin-top: 40px; 535 | } 536 | .main { 537 | display: flex; 538 | flex-direction: column; 539 | align-items: center; 540 | justify-content: center; 541 | } 542 | .aboutHeader { 543 | font-size: 35px; 544 | } 545 | } 546 | 547 | @media (max-width: 500px) { 548 | .support-header { 549 | font-size: 28px; 550 | } 551 | .header { 552 | font-size: 40px; 553 | } 554 | .header-body { 555 | text-align: center; 556 | } 557 | .support > img { 558 | width: 40px; 559 | height: 40px; 560 | } 561 | .imgAbout { 562 | height: 500px; 563 | } 564 | .about { 565 | display: flex; 566 | flex-direction: column; 567 | } 568 | } 569 | 570 | @media (min-width: 768px) { 571 | .md\:m-4 { 572 | margin: 1rem; 573 | } 574 | 575 | .md\:mb-0 { 576 | margin-bottom: 0px; 577 | } 578 | 579 | .md\:mt-0 { 580 | margin-top: 0px; 581 | } 582 | 583 | .md\:block { 584 | display: block; 585 | } 586 | 587 | .md\:flex { 588 | display: flex; 589 | } 590 | 591 | .md\:hidden { 592 | display: none; 593 | } 594 | 595 | .md\:min-h-screen { 596 | min-height: 100vh; 597 | } 598 | 599 | .md\:w-1\/2 { 600 | width: 50%; 601 | } 602 | 603 | .md\:w-x_18 { 604 | width: 18rem; 605 | } 606 | 607 | .md\:w-4\/12 { 608 | width: 33.333333%; 609 | } 610 | 611 | .md\:w-6\/12 { 612 | width: 50%; 613 | } 614 | 615 | .md\:w-auto { 616 | width: auto; 617 | } 618 | } 619 | 620 | 621 | .hide { 622 | display: none; 623 | } 624 | 625 | .show { 626 | display: block; 627 | } -------------------------------------------------------------------------------- /Project/assets/images/avatar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DFMlab/dapp-solidity-smart-contract-training/45bc23656281b02ac0cb2e101879ed2c7c9179e8/Project/assets/images/avatar.png -------------------------------------------------------------------------------- /Project/assets/images/card-main.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DFMlab/dapp-solidity-smart-contract-training/45bc23656281b02ac0cb2e101879ed2c7c9179e8/Project/assets/images/card-main.png -------------------------------------------------------------------------------- /Project/assets/images/double-card.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DFMlab/dapp-solidity-smart-contract-training/45bc23656281b02ac0cb2e101879ed2c7c9179e8/Project/assets/images/double-card.png -------------------------------------------------------------------------------- /Project/assets/images/hands.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DFMlab/dapp-solidity-smart-contract-training/45bc23656281b02ac0cb2e101879ed2c7c9179e8/Project/assets/images/hands.png -------------------------------------------------------------------------------- /Project/assets/images/header.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DFMlab/dapp-solidity-smart-contract-training/45bc23656281b02ac0cb2e101879ed2c7c9179e8/Project/assets/images/header.png -------------------------------------------------------------------------------- /Project/assets/images/icons.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DFMlab/dapp-solidity-smart-contract-training/45bc23656281b02ac0cb2e101879ed2c7c9179e8/Project/assets/images/icons.png -------------------------------------------------------------------------------- /Project/assets/images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DFMlab/dapp-solidity-smart-contract-training/45bc23656281b02ac0cb2e101879ed2c7c9179e8/Project/assets/images/logo.png -------------------------------------------------------------------------------- /Project/assets/images/logo2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DFMlab/dapp-solidity-smart-contract-training/45bc23656281b02ac0cb2e101879ed2c7c9179e8/Project/assets/images/logo2.png -------------------------------------------------------------------------------- /Project/assets/images/tick.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DFMlab/dapp-solidity-smart-contract-training/45bc23656281b02ac0cb2e101879ed2c7c9179e8/Project/assets/images/tick.png -------------------------------------------------------------------------------- /Project/assets/js/index.js: -------------------------------------------------------------------------------- 1 | const btn = document.getElementById('menu-btn') 2 | const nav = document.getElementById('menu') 3 | 4 | btn.addEventListener('click', () => { 5 | btn.classList.toggle('open') 6 | nav.classList.toggle('flex') 7 | nav.classList.toggle('hidden') 8 | }) -------------------------------------------------------------------------------- /Project/contract/abi/tree.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "inputs": [], 4 | "name": "_treeCount", 5 | "outputs": [ 6 | { 7 | "internalType": "uint256", 8 | "name": "", 9 | "type": "uint256" 10 | } 11 | ], 12 | "stateMutability": "view", 13 | "type": "function" 14 | }, 15 | { 16 | "inputs": [ 17 | { 18 | "internalType": "uint256", 19 | "name": "", 20 | "type": "uint256" 21 | } 22 | ], 23 | "name": "_trees", 24 | "outputs": [ 25 | { 26 | "internalType": "uint256", 27 | "name": "id", 28 | "type": "uint256" 29 | }, 30 | { 31 | "internalType": "uint256", 32 | "name": "price", 33 | "type": "uint256" 34 | }, 35 | { 36 | "internalType": "address payable", 37 | "name": "owner", 38 | "type": "address" 39 | }, 40 | { 41 | "internalType": "string", 42 | "name": "image", 43 | "type": "string" 44 | } 45 | ], 46 | "stateMutability": "view", 47 | "type": "function" 48 | }, 49 | { 50 | "inputs": [ 51 | { 52 | "internalType": "uint256", 53 | "name": "price", 54 | "type": "uint256" 55 | }, 56 | { 57 | "internalType": "string", 58 | "name": "image", 59 | "type": "string" 60 | } 61 | ], 62 | "name": "addTree", 63 | "outputs": [], 64 | "stateMutability": "nonpayable", 65 | "type": "function" 66 | }, 67 | { 68 | "inputs": [ 69 | { 70 | "internalType": "uint256", 71 | "name": "id", 72 | "type": "uint256" 73 | } 74 | ], 75 | "name": "buyTree", 76 | "outputs": [], 77 | "stateMutability": "payable", 78 | "type": "function" 79 | } 80 | ] -------------------------------------------------------------------------------- /Project/contract/tree.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity >=0.7.0 <0.9.0; 4 | 5 | contract TreeProject { 6 | 7 | struct Tree { 8 | uint256 id; 9 | uint256 price; 10 | address payable owner; 11 | string image; 12 | } 13 | 14 | mapping(uint256 => Tree) public _trees; 15 | 16 | uint256 public _treeCount; 17 | 18 | function addTree(uint256 price, string memory image) external { 19 | _trees[_treeCount].id = _treeCount; 20 | _trees[_treeCount].price = price; 21 | _trees[_treeCount].owner = payable(msg.sender); 22 | _trees[_treeCount].image = image; 23 | _treeCount++; 24 | } 25 | 26 | function buyTree(uint256 id) external payable { 27 | require(msg.value == _trees[id].price, "invalid amount"); 28 | _trees[id].owner.transfer(msg.value); 29 | _trees[id].owner = payable(msg.sender); 30 | _trees[id].price += _trees[id].price / 5; 31 | } 32 | 33 | } -------------------------------------------------------------------------------- /Project/index.js: -------------------------------------------------------------------------------- 1 | let path = require("path"); 2 | let webpack = require("webpack"); 3 | let webpackDevServer = require("webpack-dev-server"); 4 | let webpackConfig = require("./webpack.config"); 5 | 6 | let webpackDevServerOptions = { 7 | publicPath: "/", 8 | contentBase: path.join(process.cwd(), "dist"), 9 | historyApiFallback: true, 10 | hot: true, 11 | host: "0.0.0.0" 12 | }; 13 | 14 | webpackDevServer.addDevServerEntrypoints(webpackConfig, webpackDevServerOptions); 15 | let webpackCompiler = webpack(webpackConfig); 16 | 17 | let app = new webpackDevServer(webpackCompiler, webpackDevServerOptions); 18 | 19 | let port = process.env.PORT || 3000; 20 | app.listen(port, () => console.log(`App listening on ${port}`)); 21 | -------------------------------------------------------------------------------- /Project/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "main": "index.js", 3 | "dependencies": { 4 | "@celo/contractkit": "^1.0.2", 5 | "arrive": "^2.4.1", 6 | "bignumber.js": "^9.0.1", 7 | "sweetalert2": "^11.4.23" 8 | }, 9 | "devDependencies": { 10 | "friendly-errors-webpack-plugin": "1.7.0", 11 | "html-webpack-plugin": "3.2.0", 12 | "copy-webpack-plugin": "5.1.1", 13 | "webpack": "4.29.6", 14 | "webpack-cli": "^3.1.2", 15 | "webpack-dev-server": "^3.11.2" 16 | }, 17 | "scripts": { 18 | "dev": "node index.js", 19 | "build": "webpack" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Project/public/assets/avatar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DFMlab/dapp-solidity-smart-contract-training/45bc23656281b02ac0cb2e101879ed2c7c9179e8/Project/public/assets/avatar.png -------------------------------------------------------------------------------- /Project/public/assets/card-main.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DFMlab/dapp-solidity-smart-contract-training/45bc23656281b02ac0cb2e101879ed2c7c9179e8/Project/public/assets/card-main.png -------------------------------------------------------------------------------- /Project/public/assets/css/style.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | font-family: "Clash Display", sans-serif; 4 | } 5 | 6 | nav { 7 | display: flex; 8 | padding: 20px; 9 | color: white; 10 | 11 | margin: 0px 20px; 12 | justify-content: space-between; 13 | } 14 | [hidden] { 15 | display: none; 16 | } 17 | 18 | nav > div > a { 19 | text-decoration: none; 20 | color: white; 21 | margin-left: 10px; 22 | } 23 | 24 | .main-paragraph { 25 | font-weight: 400; 26 | font-size: 14px; 27 | 28 | text-transform: uppercase; 29 | line-height: 14.76px; 30 | } 31 | 32 | .links { 33 | display: flex; 34 | justify-content: space-between; 35 | } 36 | 37 | p { 38 | margin: 0; 39 | } 40 | 41 | .card { 42 | width: 320px; 43 | margin: 10px; 44 | background-color: #000000; 45 | } 46 | 47 | .card-body { 48 | padding: 15px 35px; 49 | } 50 | .img-holder { 51 | margin-top: 15px; 52 | } 53 | 54 | .card-img { 55 | width: 240px; 56 | height: 160px; 57 | } 58 | .top-creator { 59 | display: flex; 60 | margin-top: 5%; 61 | position: relative; 62 | flex-direction: column; 63 | justify-content: center; 64 | text-align: center; 65 | } 66 | 67 | .top-header { 68 | font-size: 48px; 69 | line-height: 83px; 70 | } 71 | 72 | .top-body { 73 | color: #676767; 74 | font-size: 16px; 75 | line-height: 32px; 76 | } 77 | .overflow { 78 | width: 120%; 79 | overflow-x: hidden; 80 | } 81 | 82 | .top-card { 83 | display: flex; 84 | justify-content: flex-start; 85 | align-items: center; 86 | margin: 10px; 87 | border: 1px solid #000000; 88 | text-align: left; 89 | border-radius: 50px; 90 | width: 315px; 91 | height: 80px; 92 | } 93 | .top-card > img { 94 | width: 49px; 95 | margin-left: 10px; 96 | height: 49px; 97 | } 98 | .top-card-user { 99 | font-size: 16px; 100 | line-height: 19px; 101 | font-weight: 500; 102 | } 103 | .top-card-item { 104 | color: #676767; 105 | font-size: 14px; 106 | line-height: 18px; 107 | } 108 | 109 | .avatar-div { 110 | display: flex; 111 | background-color: #fff; 112 | padding: 5px 18px; 113 | color: black; 114 | margin-top: 10%; 115 | border-radius: 20px; 116 | width: 92px; 117 | height: 24px; 118 | } 119 | 120 | .avatar-div > p { 121 | font-weight: 500; 122 | margin-left: 10px; 123 | } 124 | 125 | .card:hover { 126 | background: linear-gradient( 127 | 159.38deg, 128 | #181187 9.6%, 129 | #e85556 39.44%, 130 | #1166f1 64.66%, 131 | #ca2c74 86.91% 132 | ); 133 | } 134 | 135 | .header { 136 | font-size: 62px; 137 | text-transform: capitalize; 138 | margin: 10px 0px; 139 | line-height: 83px; 140 | } 141 | 142 | .header-body { 143 | font-size: 16px; 144 | line-height: 32px; 145 | font-weight: 400; 146 | } 147 | 148 | .featured { 149 | color: #000000; 150 | padding: 20px; 151 | margin-top: 10%; 152 | } 153 | 154 | .featured-header { 155 | font-size: 48px; 156 | font-weight: 400; 157 | margin-bottom: 20px; 158 | } 159 | 160 | .hero-section { 161 | display: grid; 162 | background-color: black; 163 | color: white; 164 | 165 | padding: 20px; 166 | grid-template-columns: 50% 20%; 167 | gap: 10%; 168 | } 169 | 170 | .absolute { 171 | position: absolute; 172 | } 173 | 174 | #menu > a { 175 | text-decoration: none; 176 | color: black; 177 | } 178 | 179 | .main { 180 | padding: 20px; 181 | margin-top: 75px; 182 | } 183 | 184 | .main > button { 185 | background-color: white; 186 | color: black; 187 | width: 192px; 188 | height: 57px; 189 | margin: 20px 0px; 190 | border: 0; 191 | font-weight: 500; 192 | line-height: 17.22px; 193 | } 194 | 195 | .supportedBy { 196 | text-transform: uppercase; 197 | } 198 | 199 | .about { 200 | padding: 5px 10px; 201 | display: grid; 202 | grid-template-columns: 50% 40%; 203 | } 204 | .get-started { 205 | margin-top: 30%; 206 | color: white; 207 | background: linear-gradient( 208 | 99.09deg, 209 | #000000 90.12%, 210 | rgba(0, 0, 0, 0) 88.59% 211 | ); 212 | } 213 | .started-div { 214 | display: flex; 215 | padding-left: 5%; 216 | justify-content: space-between; 217 | align-items: center; 218 | } 219 | .started-button { 220 | background-color: #fff; 221 | width: 201px; 222 | height: 57px; 223 | border: none; 224 | } 225 | .started-button > p { 226 | font-weight: 600; 227 | font-weight: 14px; 228 | } 229 | .started-header { 230 | font-size: 48px; 231 | line-height: 60px; 232 | font-weight: 500; 233 | } 234 | .aboutText { 235 | color: #676767; 236 | margin-top: 10px; 237 | text-transform: uppercase; 238 | font-size: 12px; 239 | line-height: 15px; 240 | } 241 | 242 | .aboutHeader { 243 | font-size: 64px; 244 | margin-top: 10px; 245 | color: #000000; 246 | } 247 | 248 | .aboutBody { 249 | color: #676767; 250 | margin-top: 10px; 251 | 252 | font-size: 16px; 253 | line-height: 32px; 254 | } 255 | 256 | .imgAbout { 257 | background-image: url("/assets/double-card.png"); 258 | background-position: center; 259 | background-size: contain; 260 | background-repeat: no-repeat; 261 | margin-top: 20%; 262 | } 263 | 264 | .hr { 265 | margin: 30px 0px; 266 | width: 100%; 267 | height: 1px; 268 | background: white; 269 | } 270 | 271 | .support-header { 272 | font-weight: 500; 273 | font-size: 48px; 274 | line-height: 83px; 275 | } 276 | 277 | .support { 278 | display: flex; 279 | margin-top: 10px; 280 | align-items: center; 281 | justify-content: space-between; 282 | width: 75%; 283 | } 284 | 285 | .support > img { 286 | width: 67px; 287 | height: 65px; 288 | } 289 | 290 | .card-title { 291 | font-size: 20px; 292 | line-height: 24px; 293 | margin-top: 10px; 294 | font-weight: 500; 295 | color: white; 296 | } 297 | .card-subtitle { 298 | margin-top: 40px; 299 | font-size: 10px; 300 | color: white; 301 | 302 | font-weight: 500; 303 | } 304 | .card-price { 305 | font-size: 20px; 306 | color: white; 307 | 308 | font-weight: 600; 309 | line-height: 24px; 310 | } 311 | .card-money { 312 | font-size: 12px; 313 | color: white; 314 | line-height: 14px; 315 | } 316 | .button-wrapper { 317 | margin-top: 20%; 318 | display: flex; 319 | justify-content: space-between; 320 | align-items: center; 321 | } 322 | .buyNow { 323 | background-color: #fff; 324 | width: 140px; 325 | height: 40px; 326 | border: none; 327 | font-weight: 500; 328 | margin-right: 10px; 329 | color: #000000; 330 | display: flex; 331 | align-items: center; 332 | justify-content: center; 333 | } 334 | .viewContract { 335 | width: 140px; 336 | height: 40px; 337 | font-weight: 500; 338 | background-color: #000000; 339 | border: 1px solid white; 340 | color: white; 341 | display: flex; 342 | align-items: center; 343 | justify-content: center; 344 | } 345 | .imgHeader { 346 | background-image: url("/assets/header.png"); 347 | background-position: center; 348 | background-size: contain; 349 | background-repeat: no-repeat; 350 | width: 500px; 351 | height: 800px; 352 | } 353 | 354 | .nav-button { 355 | border: 1px solid white; 356 | color: white; 357 | background-color: black; 358 | padding: 15px 30px; 359 | } 360 | .hamburger { 361 | cursor: pointer; 362 | width: 24px; 363 | height: 24px; 364 | transition: all 0.25s; 365 | background-color: #000000; 366 | border: none; 367 | position: relative; 368 | } 369 | 370 | .hamburger-top, 371 | .hamburger-middle, 372 | .hamburger-bottom { 373 | position: absolute; 374 | width: 24px; 375 | top: 0; 376 | left: 0; 377 | height: 1.5px; 378 | background-color: #fff; 379 | transform: rotate(0); 380 | transition: all 0.5s; 381 | } 382 | 383 | .hamburger-middle { 384 | width: 20px; 385 | margin-left: 4px; 386 | } 387 | 388 | .hamburger-middle { 389 | transform: translateY(7px); 390 | } 391 | 392 | .hamburger-bottom { 393 | transform: translateY(14px); 394 | } 395 | 396 | .hidden { 397 | display: none; 398 | } 399 | 400 | .open { 401 | /* transform: rotate(90deg); */ 402 | transform: translateY(0px); 403 | } 404 | 405 | .open .hamburger-top { 406 | transform: rotate(45deg) translateY(6px) translate(6px); 407 | } 408 | 409 | .open .hamburger-middle { 410 | display: none; 411 | } 412 | 413 | .open .hamburger-bottom { 414 | transform: rotate(-45deg) translateY(6px) translate(-6px); 415 | } 416 | 417 | .hero { 418 | background-color: black; 419 | color: white; 420 | } 421 | .img-wrapper { 422 | display: flex; 423 | justify-content: space-between; 424 | align-items: center; 425 | width: 40%; 426 | } 427 | .footer-wrapper { 428 | display: flex; 429 | margin-top: 10%; 430 | padding: 20px; 431 | align-items: center; 432 | justify-content: space-between; 433 | } 434 | .footer-links > a { 435 | color: black; 436 | font-size: 14px; 437 | font-weight: 500; 438 | margin-left: 40px; 439 | text-decoration: none; 440 | } 441 | .email-wrapper { 442 | display: flex; 443 | flex-direction: column; 444 | align-items: flex-end; 445 | margin-right: 40px; 446 | } 447 | .card-wrapper { 448 | display: flex; 449 | align-items: center; 450 | justify-content: center; 451 | flex-wrap: wrap; 452 | } 453 | .card-wrapper-rounded { 454 | display: flex; 455 | flex-wrap: wrap; 456 | } 457 | 458 | .email-wrapper > p { 459 | text-align: right; 460 | } 461 | .footer-hr { 462 | border-top: 1px solid rgba(0, 0, 0, 0.3); 463 | width: 100%; 464 | height: 1px; 465 | } 466 | .footer-body { 467 | padding: 40px; 468 | display: flex; 469 | align-items: center; 470 | justify-content: space-between; 471 | } 472 | .footer-body > p { 473 | font-size: 12px; 474 | } 475 | 476 | @media (max-width: 800px) { 477 | .support { 478 | width: 100%; 479 | justify-content: space-between; 480 | } 481 | .hero-section { 482 | display: block; 483 | } 484 | .header { 485 | text-align: center; 486 | } 487 | .imgHeader { 488 | width: 100%; 489 | height: 100%; 490 | } 491 | 492 | .started-div { 493 | display: flex; 494 | flex-direction: column; 495 | padding: 0; 496 | justify-content: center; 497 | } 498 | .footer-wrapper { 499 | justify-content: center; 500 | padding: 0px; 501 | width: 100%; 502 | flex-direction: column; 503 | } 504 | .img-wrapper { 505 | flex-direction: column; 506 | width: 100%; 507 | } 508 | .footer-links { 509 | display: flex; 510 | margin: 20px 0px; 511 | width: 100%; 512 | } 513 | .email-wrapper { 514 | align-items: center; 515 | margin-left: 10%; 516 | margin-top: 5%; 517 | margin-bottom: 5%; 518 | } 519 | 520 | .get-started { 521 | background-color: #000000; 522 | width: 100%; 523 | 524 | padding: 10px 0px; 525 | } 526 | .top-card { 527 | padding: 10px 6%; 528 | } 529 | .card-wrapper-rounded { 530 | justify-content: center; 531 | align-items: center; 532 | flex-wrap: nowrap; 533 | } 534 | 535 | .started-div > p { 536 | font-size: 25px; 537 | margin-bottom: 20px; 538 | } 539 | .started-div > button { 540 | margin-bottom: 20px; 541 | height: 40px; 542 | } 543 | .started-div > img { 544 | width: 300px; 545 | margin-top: 40px; 546 | } 547 | .main { 548 | display: flex; 549 | flex-direction: column; 550 | align-items: center; 551 | justify-content: center; 552 | } 553 | .aboutHeader { 554 | font-size: 35px; 555 | } 556 | } 557 | 558 | @media (max-width: 500px) { 559 | .support-header { 560 | font-size: 28px; 561 | } 562 | .header { 563 | font-size: 40px; 564 | } 565 | .header-body { 566 | text-align: center; 567 | } 568 | .support > img { 569 | width: 40px; 570 | height: 40px; 571 | } 572 | .imgAbout { 573 | height: 500px; 574 | } 575 | .about { 576 | display: flex; 577 | flex-direction: column; 578 | } 579 | } 580 | 581 | @media (min-width: 768px) { 582 | .md\:m-4 { 583 | margin: 1rem; 584 | } 585 | 586 | .md\:mb-0 { 587 | margin-bottom: 0px; 588 | } 589 | 590 | .md\:mt-0 { 591 | margin-top: 0px; 592 | } 593 | 594 | .md\:block { 595 | display: block; 596 | } 597 | 598 | .md\:flex { 599 | display: flex; 600 | } 601 | 602 | .md\:hidden { 603 | display: none; 604 | } 605 | 606 | .md\:min-h-screen { 607 | min-height: 100vh; 608 | } 609 | 610 | .md\:w-1\/2 { 611 | width: 50%; 612 | } 613 | 614 | .md\:w-x_18 { 615 | width: 18rem; 616 | } 617 | 618 | .md\:w-4\/12 { 619 | width: 33.333333%; 620 | } 621 | 622 | .md\:w-6\/12 { 623 | width: 50%; 624 | } 625 | 626 | .md\:w-auto { 627 | width: auto; 628 | } 629 | } -------------------------------------------------------------------------------- /Project/public/assets/double-card.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DFMlab/dapp-solidity-smart-contract-training/45bc23656281b02ac0cb2e101879ed2c7c9179e8/Project/public/assets/double-card.png -------------------------------------------------------------------------------- /Project/public/assets/hands.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DFMlab/dapp-solidity-smart-contract-training/45bc23656281b02ac0cb2e101879ed2c7c9179e8/Project/public/assets/hands.png -------------------------------------------------------------------------------- /Project/public/assets/header.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DFMlab/dapp-solidity-smart-contract-training/45bc23656281b02ac0cb2e101879ed2c7c9179e8/Project/public/assets/header.png -------------------------------------------------------------------------------- /Project/public/assets/icons.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DFMlab/dapp-solidity-smart-contract-training/45bc23656281b02ac0cb2e101879ed2c7c9179e8/Project/public/assets/icons.png -------------------------------------------------------------------------------- /Project/public/assets/images/avatar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DFMlab/dapp-solidity-smart-contract-training/45bc23656281b02ac0cb2e101879ed2c7c9179e8/Project/public/assets/images/avatar.png -------------------------------------------------------------------------------- /Project/public/assets/images/card-main.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DFMlab/dapp-solidity-smart-contract-training/45bc23656281b02ac0cb2e101879ed2c7c9179e8/Project/public/assets/images/card-main.png -------------------------------------------------------------------------------- /Project/public/assets/images/double-card.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DFMlab/dapp-solidity-smart-contract-training/45bc23656281b02ac0cb2e101879ed2c7c9179e8/Project/public/assets/images/double-card.png -------------------------------------------------------------------------------- /Project/public/assets/images/hands.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DFMlab/dapp-solidity-smart-contract-training/45bc23656281b02ac0cb2e101879ed2c7c9179e8/Project/public/assets/images/hands.png -------------------------------------------------------------------------------- /Project/public/assets/images/header.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DFMlab/dapp-solidity-smart-contract-training/45bc23656281b02ac0cb2e101879ed2c7c9179e8/Project/public/assets/images/header.png -------------------------------------------------------------------------------- /Project/public/assets/images/icons.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DFMlab/dapp-solidity-smart-contract-training/45bc23656281b02ac0cb2e101879ed2c7c9179e8/Project/public/assets/images/icons.png -------------------------------------------------------------------------------- /Project/public/assets/images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DFMlab/dapp-solidity-smart-contract-training/45bc23656281b02ac0cb2e101879ed2c7c9179e8/Project/public/assets/images/logo.png -------------------------------------------------------------------------------- /Project/public/assets/images/logo2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DFMlab/dapp-solidity-smart-contract-training/45bc23656281b02ac0cb2e101879ed2c7c9179e8/Project/public/assets/images/logo2.png -------------------------------------------------------------------------------- /Project/public/assets/images/tick.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DFMlab/dapp-solidity-smart-contract-training/45bc23656281b02ac0cb2e101879ed2c7c9179e8/Project/public/assets/images/tick.png -------------------------------------------------------------------------------- /Project/public/assets/js/index.js: -------------------------------------------------------------------------------- 1 | const btn = document.getElementById('menu-btn') 2 | const nav = document.getElementById('menu') 3 | 4 | btn.addEventListener('click', () => { 5 | btn.classList.toggle('open') 6 | nav.classList.toggle('flex') 7 | nav.classList.toggle('hidden') 8 | }) -------------------------------------------------------------------------------- /Project/public/assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DFMlab/dapp-solidity-smart-contract-training/45bc23656281b02ac0cb2e101879ed2c7c9179e8/Project/public/assets/logo.png -------------------------------------------------------------------------------- /Project/public/assets/logo2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DFMlab/dapp-solidity-smart-contract-training/45bc23656281b02ac0cb2e101879ed2c7c9179e8/Project/public/assets/logo2.png -------------------------------------------------------------------------------- /Project/public/assets/tick.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DFMlab/dapp-solidity-smart-contract-training/45bc23656281b02ac0cb2e101879ed2c7c9179e8/Project/public/assets/tick.png -------------------------------------------------------------------------------- /Project/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 13 | 14 | Tree view 15 | 16 | 17 | 18 | 19 |
20 | 41 |
42 | 43 |
44 | 49 |
50 |
51 |
52 | 53 | 54 |
55 |
56 |

All New Smart Contract Marketplace

57 |

integrate a 58 | smart contract 59 | into a web application

60 |

Lorem ipsum dolor sit amet, consectetur adipiscing elit. In placerat urna.
Lorem 61 | ipsum dolor sit 62 | amet, 63 | consectetur 64 | adipiscing elit. In placerat urna.

65 | 66 |
67 |

Supported By

68 |
69 | 70 |
71 |

215.7K

72 |

Total Contract

73 |
74 |
75 |

137.3K

76 |

Total Users

77 |
78 |
79 |
80 |
81 | 82 |
83 | 84 |
85 |
86 |
87 |

About the three Project

88 | 89 |

Why We are 90 | Different from others

91 |

We are first martplace that allowa users to sell their own smart contract. you can buy 92 | and sell your 93 | smart contract with 94 | the best deal here. place your Bid and start your trade.

95 | 96 |
97 | 98 |
99 | 100 | 342 | 343 |
344 |

Top Creator

345 |

Discover the best smart contract collections in the world on our site.

346 |
347 |
348 |
349 | 350 |
351 |

@Alexander cage

352 |

10.043+ item

353 |
354 |
355 |
356 | 357 |
358 |

@Alexander cage

359 |

10.043+ item

360 |
361 |
362 |
363 | 364 |
365 |

@Alexander cage

366 |

10.043+ item

367 |
368 |
369 |
370 | 371 |
372 |

@Alexander cage

373 |

10.043+ item

374 |
375 |
376 |
377 | 378 |
379 |

@Alexander cage

380 |

10.043+ item

381 |
382 |
383 |
384 | 385 |
386 |

@Alexander cage

387 |

10.043+ item

388 |
389 |
390 |
391 | 392 |
393 |

@Alexander cage

394 |

10.043+ item

395 |
396 |
397 |
398 | 399 |
400 |

@Alexander cage

401 |

10.043+ item

402 |
403 |
404 |
405 | 406 |
407 |

@Alexander cage

408 |

10.043+ item

409 |
410 |
411 | 412 |
413 |
414 | 415 | 416 |
417 | 418 |
419 |
420 |

Get Free Collection
421 | for first transaction

422 | 425 | 426 |
427 |
428 | 429 |
430 | 446 | 447 | 451 |
452 | 453 | 454 | 455 | 456 | -------------------------------------------------------------------------------- /Project/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 13 | 14 | Tree view 15 | 16 | 17 | 18 | 19 |
20 | 44 |
45 | 46 |
47 | 52 |
53 |
54 |
55 | 56 | 57 |
58 |
59 |

All New Smart Contract Marketplace

60 |

integrate a 61 | smart contract 62 | into a web application

63 |

Lorem ipsum dolor sit amet, consectetur adipiscing elit. In placerat urna.
Lorem 64 | ipsum dolor sit 65 | amet, 66 | consectetur 67 | adipiscing elit. In placerat urna.

68 | 69 |
70 |

Supported By

71 |
72 | 73 |
74 |

215.7K

75 |

Total Contract

76 |
77 |
78 |

137.3K

79 |

Total Users

80 |
81 |
82 |
83 |
84 | 85 |
86 | 87 |
88 |
89 |
90 |

About the three Project

91 | 92 |

Why We are 93 | Different from others

94 |

We are first martplace that allowa users to sell their own smart contract. you can buy 95 | and sell your 96 | smart contract with 97 | the best deal here. place your Bid and start your trade.

98 | 99 |
100 | 101 |
102 | 103 | 111 | 112 |
113 |
114 |

Get Free Collection
115 | for first transaction

116 | 119 | 120 |
121 |
122 | 123 |
124 | 140 | 141 | 145 |
146 | 147 | 148 | 149 | 150 | -------------------------------------------------------------------------------- /Project/src/main.js: -------------------------------------------------------------------------------- 1 | import Web3 from "web3"; 2 | import { newKitFromWeb3 } from "@celo/contractkit"; 3 | import BigNumber from "bignumber.js"; 4 | import Swal from 'sweetalert2' 5 | import ContractAbi from "./../contract/abi/tree.json"; 6 | 7 | const ContractAddress = "0x297C6FEc94A741818A5F3854E6C48d4C52E0379D" 8 | const WEI = 18 9 | 10 | /************************************************************** VARIABLE *************************************************************************/ 11 | 12 | let kit; 13 | let contract; 14 | let trees = []; 15 | 16 | /************************************************************** VARIABLE END *************************************************************************/ 17 | 18 | /************************************************************** EVENT LISTENER *************************************************************************/ 19 | 20 | const ConnectButton = document.getElementById("connectButton") 21 | const DisconnectButton = document.getElementById("disconnectButton") 22 | const AddNewTreeButton = document.getElementById("addNewTree") 23 | 24 | ConnectButton.addEventListener('click', async () => { 25 | await connect() 26 | ConnectButton.classList.add("hide") 27 | ConnectButton.classList.remove("show") 28 | DisconnectButton.classList.add("show") 29 | DisconnectButton.classList.remove("hide") 30 | }) 31 | 32 | DisconnectButton.addEventListener('click', async () => { 33 | await disconnect() 34 | ConnectButton.classList.add("show") 35 | ConnectButton.classList.remove("hide") 36 | DisconnectButton.classList.add("hide") 37 | DisconnectButton.classList.remove("show") 38 | }) 39 | 40 | AddNewTreeButton.addEventListener('click', async () => { 41 | await addTreeWidget() 42 | }) 43 | 44 | window.addEventListener("load", async () => { 45 | await connect() 46 | 47 | 48 | await getTrees() 49 | addEventListenerToBuyButton() 50 | RenderTreeCardsTemplate() 51 | }) 52 | 53 | /************************************************************** EVENT LISTENER *************************************************************************/ 54 | 55 | /************************************************************** FUNCTION *************************************************************************/ 56 | 57 | 58 | async function connect() { 59 | console.log("connecting to wallet"); 60 | if (window.celo && window.celo.isConnected) { 61 | try { 62 | window.celo.enable() 63 | const web3 = new Web3(window.celo); 64 | kit = newKitFromWeb3(web3); 65 | 66 | const accounts = await kit.web3.eth.getAccounts(); 67 | kit.defaultAccount = accounts[0]; 68 | 69 | contract = new kit.web3.eth.Contract(ContractAbi, ContractAddress); 70 | 71 | 72 | } catch (e) { 73 | notifyError(e); 74 | } 75 | } 76 | 77 | } 78 | 79 | 80 | function addEventListenerToBuyButton() { 81 | const BuyButtons = document.querySelectorAll(".buyButton") 82 | 83 | BuyButtons.forEach(BuyButton => { 84 | BuyButton.addEventListener("click", async () => { 85 | const id = BuyButton.getAttribute("tree-id") 86 | const price = BuyButton.getAttribute("tree-price") 87 | await buyTree(parseInt(id), parseInt(price)) 88 | }) 89 | }) 90 | } 91 | 92 | 93 | async function getTrees() { 94 | 95 | const treeCount = await contract.methods._treeCount().call(); 96 | 97 | for(let i = 0; i 149 |
150 | avatar 151 |

@${owner.substring(0, 8)}...

152 |
153 |
154 | card 155 |
156 |
157 |

158 | Tree Project #${id} 159 |

160 |

161 | Current Bid 162 |

163 |

164 | ${new BigNumber(price).shiftedBy(-WEI).toString()} CELO 165 |

166 |
167 |
168 | 169 |
170 | 171 | ` 172 | 173 | return cardTemplate 174 | } 175 | 176 | 177 | /************************************************************** TEMPLATE END *************************************************************************/ 178 | 179 | 180 | 181 | /************************************************************** RENDERERS *************************************************************************/ 182 | 183 | 184 | function RenderTreeCardsTemplate() { 185 | const treesTemplate = document.getElementById("treeList") 186 | treesTemplate.innerHTML = "" 187 | 188 | trees.forEach(tree => { 189 | const treeTemplate = TreeCardTemplate(tree["id"], tree["price"], tree["image"], tree["owner"]) 190 | 191 | treesTemplate.appendChild(treeTemplate) 192 | }) 193 | 194 | addEventListenerToBuyButton() 195 | 196 | } 197 | 198 | 199 | /************************************************************** RENDERERS END *************************************************************************/ 200 | 201 | 202 | /************************************************************** NOTIFICATION *************************************************************************/ 203 | 204 | // initialize sweet alert toast message 205 | 206 | const Toast = Swal.mixin({ 207 | toast: true, 208 | position: 'top-end', 209 | showConfirmButton: false, 210 | timer: 3000, 211 | timerProgressBar: true, 212 | didOpen: (toast) => { 213 | toast.addEventListener('mouseenter', Swal.stopTimer) 214 | toast.addEventListener('mouseleave', Swal.resumeTimer) 215 | } 216 | }) 217 | 218 | // to be used to notify of success 219 | 220 | async function notifySuccess(message) { 221 | const Toast = Swal.mixin({ 222 | toast: true, 223 | position: 'top-end', 224 | showConfirmButton: false, 225 | timer: 3000, 226 | timerProgressBar: true, 227 | didOpen: (toast) => { 228 | toast.addEventListener('mouseenter', Swal.stopTimer) 229 | toast.addEventListener('mouseleave', Swal.resumeTimer) 230 | } 231 | }) 232 | await Toast.fire({ 233 | icon: 'success', 234 | title: message 235 | }) 236 | } 237 | 238 | async function notifyError(message) { 239 | const Toast = Swal.mixin({ 240 | toast: true, 241 | position: 'top-end', 242 | showConfirmButton: false, 243 | timer: 3000, 244 | timerProgressBar: true, 245 | didOpen: (toast) => { 246 | toast.addEventListener('mouseenter', Swal.stopTimer) 247 | toast.addEventListener('mouseleave', Swal.resumeTimer) 248 | } 249 | }) 250 | await Toast.fire({ 251 | icon: 'error', 252 | title: message 253 | }) 254 | } 255 | 256 | async function addTreeWidget() { 257 | new Swal({ 258 | title: 'Multiple inputs', 259 | html: 260 | '' + 261 | '', 262 | preConfirm: function () { 263 | return new Promise(function (resolve) { 264 | resolve([ 265 | document.getElementById("swal-input1").value, 266 | document.getElementById("swal-input2").value 267 | ]) 268 | }) 269 | }, 270 | }).then(async function (result) { 271 | const { value } = result; 272 | await addTree(parseInt(value[1]), value[0]) 273 | }).catch(Swal.noop) 274 | } 275 | 276 | 277 | /************************************************************** NOTIFICATION END *************************************************************************/ -------------------------------------------------------------------------------- /Project/webpack.config.js: -------------------------------------------------------------------------------- 1 | const path = require("path"); 2 | const webpack = require("webpack"); 3 | const CopyWebpackPlugin = require('copy-webpack-plugin'); 4 | 5 | const FriendlyErrorsWebpackPlugin = require("friendly-errors-webpack-plugin"); 6 | const HtmlWebpackPlugin = require("html-webpack-plugin"); 7 | 8 | module.exports = { 9 | mode: "development", 10 | devtool: "cheap-module-eval-source-map", 11 | entry: { 12 | main: path.resolve(process.cwd(), "src", "main.js") 13 | }, 14 | output: { 15 | path: path.resolve(process.cwd(), "public"), 16 | publicPath: "" 17 | }, 18 | node: { 19 | fs: "empty", 20 | net: "empty" 21 | }, 22 | watchOptions: { 23 | // ignored: /node_modules/, 24 | aggregateTimeout: 300, // After seeing an edit, wait .3 seconds to recompile 25 | poll: 500 // Check for edits every 5 seconds 26 | }, 27 | plugins: [ 28 | new FriendlyErrorsWebpackPlugin(), 29 | new webpack.ProgressPlugin(), 30 | new HtmlWebpackPlugin({ 31 | template: path.resolve(process.cwd(), "src", "index.html") 32 | }), 33 | new CopyWebpackPlugin([ 34 | { from: './assets', to: 'assets' } 35 | ]), 36 | ] 37 | } 38 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # dapp-solidity-smart-contract-training- -------------------------------------------------------------------------------- /boilerplate/.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | lerna-debug.log* 8 | 9 | # Diagnostic reports (https://nodejs.org/api/report.html) 10 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 11 | 12 | # Runtime data 13 | pids 14 | *.pid 15 | *.seed 16 | *.pid.lock 17 | 18 | # Directory for instrumented libs generated by jscoverage/JSCover 19 | lib-cov 20 | 21 | # Coverage directory used by tools like istanbul 22 | coverage 23 | *.lcov 24 | 25 | # nyc test coverage 26 | .nyc_output 27 | 28 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 29 | .grunt 30 | 31 | # Bower dependency directory (https://bower.io/) 32 | bower_components 33 | 34 | # node-waf configuration 35 | .lock-wscript 36 | 37 | # Compiled binary addons (https://nodejs.org/api/addons.html) 38 | build/Release 39 | 40 | # Dependency directories 41 | node_modules/ 42 | jspm_packages/ 43 | 44 | # TypeScript v1 declaration files 45 | typings/ 46 | 47 | # TypeScript cache 48 | *.tsbuildinfo 49 | 50 | # Optional npm cache directory 51 | .npm 52 | 53 | # Optional eslint cache 54 | .eslintcache 55 | 56 | # Microbundle cache 57 | .rpt2_cache/ 58 | .rts2_cache_cjs/ 59 | .rts2_cache_es/ 60 | .rts2_cache_umd/ 61 | 62 | # Optional REPL history 63 | .node_repl_history 64 | 65 | # Output of 'npm pack' 66 | *.tgz 67 | 68 | # Yarn Integrity file 69 | .yarn-integrity 70 | 71 | # dotenv environment variables file 72 | .env 73 | .env.test 74 | 75 | # parcel-bundler cache (https://parceljs.org/) 76 | .cache 77 | 78 | # Next.js build output 79 | .next 80 | 81 | # Nuxt.js build / generate output 82 | .nuxt 83 | dist 84 | 85 | # Gatsby files 86 | .cache/ 87 | # Comment in the public line in if your project uses Gatsby and *not* Next.js 88 | # https://nextjs.org/blog/next-9-1#public-directory-support 89 | # public 90 | 91 | # vuepress build output 92 | .vuepress/dist 93 | 94 | # Serverless directories 95 | .serverless/ 96 | 97 | # FuseBox cache 98 | .fusebox/ 99 | 100 | # DynamoDB Local files 101 | .dynamodb/ 102 | 103 | # TernJS port file 104 | .tern-port 105 | -------------------------------------------------------------------------------- /boilerplate/contract/tree.sol: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DFMlab/dapp-solidity-smart-contract-training/45bc23656281b02ac0cb2e101879ed2c7c9179e8/boilerplate/contract/tree.sol -------------------------------------------------------------------------------- /boilerplate/index.js: -------------------------------------------------------------------------------- 1 | let path = require("path"); 2 | let webpack = require("webpack"); 3 | let webpackDevServer = require("webpack-dev-server"); 4 | let webpackConfig = require("./webpack.config"); 5 | 6 | let webpackDevServerOptions = { 7 | publicPath: "/", 8 | contentBase: path.join(process.cwd(), "dist"), 9 | historyApiFallback: true, 10 | hot: true, 11 | host: "0.0.0.0" 12 | }; 13 | 14 | webpackDevServer.addDevServerEntrypoints(webpackConfig, webpackDevServerOptions); 15 | let webpackCompiler = webpack(webpackConfig); 16 | 17 | let app = new webpackDevServer(webpackCompiler, webpackDevServerOptions); 18 | 19 | let port = process.env.PORT || 3000; 20 | app.listen(port, () => console.log(`App listening on ${port}`)); 21 | -------------------------------------------------------------------------------- /boilerplate/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "main": "index.js", 3 | "dependencies": { 4 | "@celo/contractkit": "^1.0.2", 5 | "arrive": "^2.4.1", 6 | "bignumber.js": "^9.0.1", 7 | "sweetalert2": "^11.4.23" 8 | }, 9 | "devDependencies": { 10 | "friendly-errors-webpack-plugin": "1.7.0", 11 | "html-webpack-plugin": "3.2.0", 12 | "copy-webpack-plugin": "5.1.1", 13 | "webpack": "4.29.6", 14 | "webpack-cli": "^3.1.2", 15 | "webpack-dev-server": "^3.11.2" 16 | }, 17 | "scripts": { 18 | "dev": "node index.js", 19 | "build": "webpack" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /boilerplate/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 13 | 14 | Tree view 15 | 16 | 17 | 18 | 19 |
20 | 41 |
42 | 43 |
44 | 49 |
50 |
51 |
52 | 53 | 54 |
55 |
56 |

All New Smart Contract Marketplace

57 |

integrate a 58 | smart contract 59 | into a web application

60 |

Lorem ipsum dolor sit amet, consectetur adipiscing elit. In placerat urna.
Lorem 61 | ipsum dolor sit 62 | amet, 63 | consectetur 64 | adipiscing elit. In placerat urna.

65 | 66 |
67 |

Supported By

68 |
69 | 70 |
71 |

215.7K

72 |

Total Contract

73 |
74 |
75 |

137.3K

76 |

Total Users

77 |
78 |
79 |
80 |
81 | 82 |
83 | 84 |
85 |
86 |
87 |

About the three Project

88 | 89 |

Why We are 90 | Different from others

91 |

We are first martplace that allowa users to sell their own smart contract. you can buy 92 | and sell your 93 | smart contract with 94 | the best deal here. place your Bid and start your trade.

95 | 96 |
97 | 98 |
99 | 100 | 342 | 343 |
344 |

Top Creator

345 |

Discover the best smart contract collections in the world on our site.

346 |
347 |
348 |
349 | 350 |
351 |

@Alexander cage

352 |

10.043+ item

353 |
354 |
355 |
356 | 357 |
358 |

@Alexander cage

359 |

10.043+ item

360 |
361 |
362 |
363 | 364 |
365 |

@Alexander cage

366 |

10.043+ item

367 |
368 |
369 |
370 | 371 |
372 |

@Alexander cage

373 |

10.043+ item

374 |
375 |
376 |
377 | 378 |
379 |

@Alexander cage

380 |

10.043+ item

381 |
382 |
383 |
384 | 385 |
386 |

@Alexander cage

387 |

10.043+ item

388 |
389 |
390 |
391 | 392 |
393 |

@Alexander cage

394 |

10.043+ item

395 |
396 |
397 |
398 | 399 |
400 |

@Alexander cage

401 |

10.043+ item

402 |
403 |
404 |
405 | 406 |
407 |

@Alexander cage

408 |

10.043+ item

409 |
410 |
411 | 412 |
413 |
414 | 415 | 416 |
417 | 418 |
419 |
420 |

Get Free Collection
421 | for first transaction

422 | 425 | 426 |
427 |
428 | 429 |
430 | 446 | 447 | 451 |
452 | 453 | 454 | 455 | 456 | -------------------------------------------------------------------------------- /boilerplate/src/main.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DFMlab/dapp-solidity-smart-contract-training/45bc23656281b02ac0cb2e101879ed2c7c9179e8/boilerplate/src/main.js -------------------------------------------------------------------------------- /boilerplate/webpack.config.js: -------------------------------------------------------------------------------- 1 | const path = require("path"); 2 | const webpack = require("webpack"); 3 | const CopyWebpackPlugin = require('copy-webpack-plugin'); 4 | 5 | const FriendlyErrorsWebpackPlugin = require("friendly-errors-webpack-plugin"); 6 | const HtmlWebpackPlugin = require("html-webpack-plugin"); 7 | 8 | module.exports = { 9 | mode: "development", 10 | devtool: "cheap-module-eval-source-map", 11 | entry: { 12 | main: path.resolve(process.cwd(), "src", "main.js") 13 | }, 14 | output: { 15 | path: path.resolve(process.cwd(), "public"), 16 | publicPath: "" 17 | }, 18 | node: { 19 | fs: "empty", 20 | net: "empty" 21 | }, 22 | watchOptions: { 23 | // ignored: /node_modules/, 24 | aggregateTimeout: 300, // After seeing an edit, wait .3 seconds to recompile 25 | poll: 500 // Check for edits every 5 seconds 26 | }, 27 | plugins: [ 28 | new FriendlyErrorsWebpackPlugin(), 29 | new webpack.ProgressPlugin(), 30 | new HtmlWebpackPlugin({ 31 | template: path.resolve(process.cwd(), "src", "index.html") 32 | }), 33 | new CopyWebpackPlugin([ 34 | { from: './assets', to: 'assets' } 35 | ]), 36 | ] 37 | } 38 | --------------------------------------------------------------------------------