[
  {
    "path": "EtherJS/index.js",
    "content": "const ethers = require(\"ethers\");\r\nconst dotenv = require(\"dotenv\");\r\n\r\ndotenv.config();\r\n\r\nasync function main() {\r\n  const provider = new ethers.providers.JsonRpcProvider(\r\n    \"RPC_PROVIDER_URL\"\r\n  );\r\n\r\n  // provider\r\n\r\n  // console.log(await provider.getBlockNumber());\r\n\r\n  // const bal = await provider.getBalance(\r\n  //   \"0xbcFA8eAB1fCe576F1Ef71772E46519e0ADC06623\"\r\n  // );\r\n\r\n  // console.log(ethers.utils.formatEther(bal));\r\n\r\n  // console.log(await provider.getBlock());\r\n\r\n  // signer\r\n\r\n  // console.log();\r\n\r\n  const signer = new ethers.Wallet(process.env.PRIVATE_KEY, provider);\r\n\r\n  // let tx = {\r\n  //   to: \"0xbcFA8eAB1fCe576F1Ef71772E46519e0ADC06623\",\r\n  //   value: ethers.utils.parseEther(\"0.01\"),\r\n  // };\r\n\r\n  // // 2.22\r\n\r\n  // let TX = await signer.sendTransaction(tx);\r\n\r\n  // await TX.wait();\r\n  // console.log(TX);\r\n\r\n  // contract\r\n\r\n  const contract_address = \"0x35595cc6DD5CF938c24f393b6F7282109253C84A\";\r\n  const ABI = [\r\n    {\r\n      inputs: [],\r\n      stateMutability: \"nonpayable\",\r\n      type: \"constructor\",\r\n    },\r\n    {\r\n      inputs: [\r\n        {\r\n          internalType: \"address\",\r\n          name: \"addr\",\r\n          type: \"address\",\r\n        },\r\n      ],\r\n      name: \"NotAnOwner\",\r\n      type: \"error\",\r\n    },\r\n    {\r\n      inputs: [\r\n        {\r\n          internalType: \"uint256\",\r\n          name: \"_id\",\r\n          type: \"uint256\",\r\n        },\r\n      ],\r\n      name: \"TaskNotCompleted\",\r\n      type: \"error\",\r\n    },\r\n    {\r\n      inputs: [\r\n        {\r\n          internalType: \"uint256\",\r\n          name: \"_id\",\r\n          type: \"uint256\",\r\n        },\r\n      ],\r\n      name: \"TaskNotExist\",\r\n      type: \"error\",\r\n    },\r\n    {\r\n      anonymous: false,\r\n      inputs: [\r\n        {\r\n          indexed: false,\r\n          internalType: \"uint256\",\r\n          name: \"reward\",\r\n          type: \"uint256\",\r\n        },\r\n      ],\r\n      name: \"TaskComplete\",\r\n      type: \"event\",\r\n    },\r\n    {\r\n      anonymous: false,\r\n      inputs: [\r\n        {\r\n          indexed: false,\r\n          internalType: \"uint256\",\r\n          name: \"id\",\r\n          type: \"uint256\",\r\n        },\r\n        {\r\n          indexed: false,\r\n          internalType: \"string\",\r\n          name: \"work\",\r\n          type: \"string\",\r\n        },\r\n        {\r\n          indexed: false,\r\n          internalType: \"bool\",\r\n          name: \"status\",\r\n          type: \"bool\",\r\n        },\r\n      ],\r\n      name: \"TaskCreated\",\r\n      type: \"event\",\r\n    },\r\n    {\r\n      anonymous: false,\r\n      inputs: [\r\n        {\r\n          indexed: false,\r\n          internalType: \"uint256\",\r\n          name: \"id\",\r\n          type: \"uint256\",\r\n        },\r\n        {\r\n          indexed: false,\r\n          internalType: \"string\",\r\n          name: \"work\",\r\n          type: \"string\",\r\n        },\r\n        {\r\n          indexed: false,\r\n          internalType: \"bool\",\r\n          name: \"status\",\r\n          type: \"bool\",\r\n        },\r\n      ],\r\n      name: \"TaskStatusChange\",\r\n      type: \"event\",\r\n    },\r\n    {\r\n      stateMutability: \"payable\",\r\n      type: \"fallback\",\r\n    },\r\n    {\r\n      inputs: [],\r\n      name: \"TodosCompleted\",\r\n      outputs: [],\r\n      stateMutability: \"payable\",\r\n      type: \"function\",\r\n    },\r\n    {\r\n      inputs: [\r\n        {\r\n          internalType: \"string\",\r\n          name: \"_work\",\r\n          type: \"string\",\r\n        },\r\n      ],\r\n      name: \"createTask\",\r\n      outputs: [],\r\n      stateMutability: \"payable\",\r\n      type: \"function\",\r\n    },\r\n    {\r\n      inputs: [],\r\n      name: \"getBalance\",\r\n      outputs: [\r\n        {\r\n          internalType: \"uint256\",\r\n          name: \"\",\r\n          type: \"uint256\",\r\n        },\r\n      ],\r\n      stateMutability: \"view\",\r\n      type: \"function\",\r\n    },\r\n    {\r\n      inputs: [],\r\n      name: \"getRevenue\",\r\n      outputs: [\r\n        {\r\n          internalType: \"uint256\",\r\n          name: \"\",\r\n          type: \"uint256\",\r\n        },\r\n      ],\r\n      stateMutability: \"view\",\r\n      type: \"function\",\r\n    },\r\n    {\r\n      inputs: [],\r\n      name: \"getReward\",\r\n      outputs: [\r\n        {\r\n          internalType: \"uint256\",\r\n          name: \"\",\r\n          type: \"uint256\",\r\n        },\r\n      ],\r\n      stateMutability: \"view\",\r\n      type: \"function\",\r\n    },\r\n    {\r\n      inputs: [],\r\n      name: \"getTasks\",\r\n      outputs: [\r\n        {\r\n          components: [\r\n            {\r\n              internalType: \"string\",\r\n              name: \"work\",\r\n              type: \"string\",\r\n            },\r\n            {\r\n              internalType: \"bool\",\r\n              name: \"status\",\r\n              type: \"bool\",\r\n            },\r\n          ],\r\n          internalType: \"struct ToDo.task[]\",\r\n          name: \"\",\r\n          type: \"tuple[]\",\r\n        },\r\n      ],\r\n      stateMutability: \"view\",\r\n      type: \"function\",\r\n    },\r\n    {\r\n      inputs: [\r\n        {\r\n          internalType: \"address\",\r\n          name: \"_owner\",\r\n          type: \"address\",\r\n        },\r\n      ],\r\n      name: \"setOwner\",\r\n      outputs: [],\r\n      stateMutability: \"nonpayable\",\r\n      type: \"function\",\r\n    },\r\n    {\r\n      inputs: [\r\n        {\r\n          internalType: \"uint256\",\r\n          name: \"_id\",\r\n          type: \"uint256\",\r\n        },\r\n      ],\r\n      name: \"toggleTask\",\r\n      outputs: [],\r\n      stateMutability: \"nonpayable\",\r\n      type: \"function\",\r\n    },\r\n    {\r\n      inputs: [],\r\n      name: \"withDraw\",\r\n      outputs: [],\r\n      stateMutability: \"nonpayable\",\r\n      type: \"function\",\r\n    },\r\n    {\r\n      stateMutability: \"payable\",\r\n      type: \"receive\",\r\n    },\r\n  ];\r\n\r\n  const contract = new ethers.Contract(contract_address, ABI, signer);\r\n\r\n  // const creatTask_tx = await contract.createTask(\"clean the window\", {\r\n  //   value: ethers.utils.parseEther(\"0.1\"),\r\n  // });\r\n\r\n  // await creatTask_tx.wait();\r\n\r\n  // console.log(creatTask_tx);\r\n\r\n  // const toggleTask_tx = await contract.toggleTask(0);\r\n\r\n  // await toggleTask_tx.wait();\r\n\r\n  // console.log(toggleTask_tx);\r\n\r\n  // console.log(await contract.getTasks());\r\n\r\n  // console.log(ethers.utils.formatEther(await contract.getReward()));\r\n\r\n  const TodosCompleted_tx = await contract.TodosCompleted();\r\n  await TodosCompleted_tx.wait();\r\n\r\n  console.log(TodosCompleted_tx);\r\n}\r\n\r\nmain();\r\n"
  },
  {
    "path": "EtherJS/package.json",
    "content": "{\n  \"name\": \"ethjs-tutorial\",\n  \"version\": \"1.0.0\",\n  \"description\": \"\",\n  \"main\": \"index.js\",\n  \"scripts\": {\n    \"test\": \"echo \\\"Error: no test specified\\\" && exit 1\"\n  },\n  \"keywords\": [],\n  \"author\": \"\",\n  \"license\": \"ISC\",\n  \"dependencies\": {\n    \"dotenv\": \"^16.0.3\",\n    \"ethers\": \"^5.7.2\"\n  }\n}\n"
  },
  {
    "path": "README.md",
    "content": "# Blockchain-Engineer-Course\n\n\n\n## MODULE : 1 Introduction to Blockchain\n\n1. Introduction to Course\nhttps://youtu.be/t0Bb7Tl6bw4\n\n2. How to get Most out from this Course\nhttps://youtu.be/g4sF_PCgXT4\n\n3. What is Blockchain\nhttps://youtu.be/v40mFP6BR3I\n\n4. How Blockchain Works\nhttps://youtu.be/3WUHewOsABk\n\n* Proof of Work Demo\nhttps://andersbrownworth.com/blockchain/hash\n\n* How people of Yapis use Blockchain\nhttps://www.youtube.com/watch?v=oNhpm9NMVXs&t=1s\n\n* How Proof of Stack Works\nhttps://www.youtube.com/watch?v=M3EFi_POhps\n\n5. Why Web3 | Perpouse of Smart Contracts\nhttps://youtu.be/J_Lyx4fx4Nw\n\n* Vitalik Buterin\nhttps://vitalik.ca/\n\n* Satoshi White Paper\nhttps://github.com/nehal2210/Blockchain-Engineer-Course/blob/main/Satoshi%20white%20paper.pdf\n\n* Ethereum White paper\nhttps://ethereum.org/en/whitepaper/\n\n* Ethereum Yellow Paper\nhttps://github.com/nehal2210/Blockchain-Engineer-Course/blob/main/ethereum%20yello%20paper.pdf\n\n\n## MODULE : 2 Development of Smart Contracts\n\n* Smart Contracts\nhttps://github.com/nehal2210/Blockchain-Engineer-Course/tree/main/SmartContracts\n\n* Smart Contract By Example\nhttps://solidity-by-example.org/\n\n\n\n\n## MODULE : 3 Dapps\n\n* Ether JS\nhttps://github.com/nehal2210/Blockchain-Engineer-Course/tree/main/EtherJS\n\n* Decentalize Todo List\nhttps://github.com/nehal2210/D-Todo\n\n* Assignment Smart Contract Lottery\nhttps://youtu.be/aFI_XPll_mg\n\n* Token Vendor Machine\nhttps://github.com/nehal2210/Token-Vendor-Machine\n\n\n* Base64 Encoding\nhttps://www.youtube.com/watch?v=wdeZIOJjjdE\n\n## MODULE : 6 Applications (PARALLEL MODULE)\n\n* Coin VS Toke By Muhammad Nouman\nhttps://github.com/nehal2210/Blockchain-Engineer-Course/blob/main/Coin%20vs%20Theory.pptx\n\n\n\n\n\n\n\n## Learning Resources\n\n* Speed Run Ethereum https://speedrunethereum.com/\n* BuildSpace https://buildspace.so/p/mint-nft-collection\n* Patrick Collins https://www.youtube.com/watch?v=gyMwXuJrbJQ&t=7238s\n* Chainlink Services Overview By Hari https://youtu.be/nHn7u9wSHZs?list=PLVP9aGDn-X0Q1L67bV_AbDd75qTY6Ylxw\n\n## GitHub\n\n* How to create PR\nhttps://firstcontributions.github.io/\n\n* How to create Github Issues\nhttps://www.youtube.com/watch?v=TJlYiMp8FuY\n\n**Note: PR Format branch name your-name/feature-you have change/add**\n**e.g. nehal/module2-doc**\n\n\n# Assignment\n* https://github.com/nehal2210/Blockchain-Engineer-Course/blob/main/BLockchain%20Engineer%20Course%20Assignment.pdf\n\n# Submitted Assignmets By Blockchain Ninjas\n\n* FullName  (url)\n\n\n\n## OUR COLLABORATORS\n\n<div align=\"center\">\n  \n| <img src=\"https://avatars.githubusercontent.com/u/41861195?v=4\" alt=\"Haseeb Ahmed\" style=\"border-radius: 50%; width: 100px;\"> | <img src=\"https://avatars.githubusercontent.com/u/41865951?v=4\" alt=\"Nehal Ahmed\" style=\"border-radius: 50%; width: 100px;\"> | <img src=\"https://media.licdn.com/dms/image/C5603AQG3sW8M7vYYWw/profile-displayphoto-shrink_400_400/0/1568832728611?e=1683158400&v=beta&t=IZcuosff9v87v24QfKkyPKB3jhphXXW0gc-7qNlL1U0\" alt=\"Muhammad Nouman\" style=\"border-radius: 50%; width: 100px;\"> |\n|:---:|:---:|:---:|\n| Haseeb Ahmed | Nehal Ahmed | Muhammad Nouman |\n\n</div>\n"
  },
  {
    "path": "SmartContracts/1_Storage.sol",
    "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.7;\n\n/**\n * @title Storage\n * @dev Store & retrieve value in a variable\n * @custom:dev-run-script ./scripts/deploy_with_ethers.ts\n */\ncontract Storage {\n\n    uint256 number;\n\n    /**\n     * @dev Store value in variable\n     * @param num value to store\n     */\n    function store(uint256 num) public {\n        number = num;\n    }\n\n    /**\n     * @dev Return value \n     * @return value of 'number'\n     */\n    function retrieve() public view returns (uint256){\n        return number;\n    }\n}"
  },
  {
    "path": "SmartContracts/AccessModifier.sol",
    "content": "\r\n// SPDX-License-Identifier: MIT\r\npragma solidity 0.8.7;\r\n\r\n\r\n// Access Modifiers: scope accessiblity\r\n// internal : can access only inside the contract and derive contract\r\n// external : can access only from outside of contract\r\n// public : can access from every where\r\n// private : can access only inside the contract\r\n\r\n\r\n// By default variables are internal\r\n\r\n// only use in state variables and functions\r\n\r\n// external can only be used with functions\r\n\r\n\r\ncontract A{\r\n\r\nuint internal a = 5;\r\n\r\nfunction access() external view returns(uint){\r\n    return a;\r\n}\r\n\r\n// function accessExternal() public view returns(uint){\r\n//     return access();\r\n// }\r\n}\r\n\r\ncontract B  is A{\r\n uint public b = a;\r\n\r\n}\r\n\r\n"
  },
  {
    "path": "SmartContracts/Array.sol",
    "content": "// SPDX-License-Identifier: MIT\r\npragma solidity ^0.8.7;\r\n\r\n\r\n// Array\r\n// Array can have a compile-time fixed size or a dynamic size.\r\n\r\n// get ,add, update, delete\r\n\r\n// Compile-time : when we write code\r\n// Run-time : when code is running\r\n\r\ncontract Array {\r\n    // Several ways to initialize an array\r\n    uint[] public arr;\r\n    uint[] public arr2 = [1, 2, 3];\r\n    // Fixed sized array, all elements initialize to 0\r\n    uint[10] public myFixedSizeArr;//[0,0,0,0,0,0,0..]\r\n\r\n    function get(uint i) public view returns (uint) {\r\n        return arr[i];\r\n    }\r\n\r\n    // Solidity can return the entire array.\r\n    // But this function should be avoided for\r\n    // arrays that can grow indefinitely in length.\r\n    function getArr() public view returns (uint[] memory) {\r\n        return arr;\r\n    }\r\n\r\n    function push(uint i) public {\r\n        // Append to array\r\n        // This will increase the array length by 1.\r\n        arr.push(i);//[1,2,3,10]\r\n    }\r\n\r\n    function pop() public {\r\n        // Remove last element from array\r\n        // This will decrease the array length by 1\r\n        arr.pop();\r\n    }\r\n\r\n    function getLength() public view returns (uint) {\r\n        return arr.length;\r\n    }\r\n\r\n    function remove(uint index) public {\r\n        // Delete does not change the array length.\r\n        // It resets the value at index to it's default value,\r\n        // in this case 0\r\n        delete arr[index];\r\n    }\r\n\r\n    function examples() pure external {\r\n        // create array in memory, only fixed size can be created\r\n        uint[] memory b = new uint[](5);\r\n\r\n    }\r\n}\r\n"
  },
  {
    "path": "SmartContracts/Constant.sol",
    "content": "// SPDX-License-Identifier: MIT\r\npragma solidity 0.8.7;\r\n\r\n\r\n// contsant variable values never change;\r\n// they must be initialize before the deployment of contract\r\n// it saves gas cost\r\n\r\ncontract Constant{\r\n//\t23471 gas \r\n    uint256 public vari_num = 10;\r\n   \r\n   //21393 gas\r\n    uint256 public constant MY_NUM = 10;\r\n\r\n}"
  },
  {
    "path": "SmartContracts/Constructors.sol",
    "content": "// SPDX-License-Identifier: MIT\r\npragma solidity ^0.8.7;\r\n\r\n\r\n// A constructor is an optional function that is executed upon contract creation.\r\n// Here are examples of how to pass arguments to constructors.\r\n\r\n// Base contract X\r\ncontract X {\r\n    string public name;\r\n\r\n    constructor(string memory _name) {\r\n        name = _name;\r\n    }\r\n}\r\n\r\n// // Base contract Y\r\ncontract Y {\r\n    string public text;\r\n\r\n    constructor(string memory _text) {\r\n        text = _text;\r\n    }\r\n}\r\n\r\n\r\n\r\ncontract C is X, Y {\r\n    // Pass the parameters here in the constructor,\r\n    // similar to function modifiers.\r\n    constructor(string memory _name, string memory _text) X(_name) Y(_text) {}\r\n}\r\n\r\n// // Parent constructors are always called in the order of inheritance\r\n// // regardless of the order of parent contracts listed in the\r\n// // constructor of the child contract.\r\n\r\n// // Order of constructors called:\r\n// // 1. X\r\n// // 2. Y\r\n// // 3. D\r\ncontract D is X, Y {\r\n    constructor() X(\"X was called\") Y(\"Y was called\") {}\r\n}\r\n"
  },
  {
    "path": "SmartContracts/DataLocations.sol",
    "content": "// SPDX-License-Identifier: MIT\r\npragma solidity ^0.8.7;\r\n\r\n\r\n// Variables are declared as either storage, memory or calldata to explicitly specify the location of the data.\r\n\r\n// mostly use explicitly in bytes,string, array and mapping,struct\r\n\r\n// storage - variable is a state variable (store on blockchain)\r\n// memory - variable is in memory and it exists while a function is being called,However, they are mutable within that function.\r\n// calldata - Calldata is an immutable, temporary location where function arguments are stored, and behaves mostly like memory.\r\n// special data location that contains function arguments\r\n\r\ncontract DataLocation{\r\n\r\n    struct Todo {\r\n        string text;\r\n        bool completed;\r\n    }\r\n\r\n\r\n\r\n\r\n    // An array of 'Todo' structs\r\n    Todo[] public todos;\r\n\r\n    function create(string calldata _text) public  {\r\n\r\n     todos.push(Todo(_text, false));\r\n\r\n    }\r\n\r\n    // Solidity automatically created a getter for 'todos' so\r\n    // you don't actually need this function.\r\n    function get(uint _index) public view returns (string memory text, bool completed) {\r\n        Todo storage todo = todos[_index];\r\n        return (todo.text, todo.completed);\r\n    }\r\n\r\n    // update text\r\n    function updateText(uint _index, string calldata _text) public {\r\n        Todo storage todo = todos[_index];\r\n        todo.text = _text;\r\n    }\r\n\r\n\r\n\r\n}"
  },
  {
    "path": "SmartContracts/EncodeDecode.sol",
    "content": "pragma solidity 0.8.7;\r\n\r\n\r\n// abi.encode encodes data into bytes.\r\n// abi.decode decodes bytes back into data.\r\n\r\n\r\ncontract EncodeDecode{\r\n\r\n    function encode(uint x,address addr) external pure returns (bytes memory) {\r\n        return abi.encode(x, addr);\r\n    }\r\n\r\n    function decode(bytes calldata data) external pure returns (uint n, address adr)\r\n    {\r\n       (n,adr) =abi.decode(data,(uint,address));\r\n    }\r\n\r\n\r\n    function hash(\r\n        uint num,\r\n        address addr\r\n    ) public pure returns (bytes32) {\r\n        return keccak256(abi.encode(num, addr));\r\n    }\r\n\r\n    function verifyHash(\r\n        uint num,\r\n        address addr,\r\n        bytes32  _hash\r\n    ) public pure returns (bool) {\r\n        return keccak256(abi.encode(num, addr)) == _hash;\r\n    }\r\n\r\n\r\n\r\n\r\n}"
  },
  {
    "path": "SmartContracts/Enum.sol",
    "content": "// SPDX-License-Identifier: MIT\r\npragma solidity ^0.8.7;\r\n\r\n\r\n// Enum\r\n// Solidity supports enumerables and they are useful to model choice and keep track of state.\r\n// Enums can be declared outside of a contract.\r\n// enums are also called custom data type\r\n\r\ncontract Enum {\r\n    // Enum representing shipping status\r\n    enum Status {\r\n        Pending,\r\n        Shipped,\r\n        Accepted,\r\n        Rejected,\r\n        Canceled\r\n    }\r\n\r\n    // Default value is the first element listed in\r\n    // definition of the type, in this case \"Pending\"\r\n    Status public status;\r\n    // Status public status = Status.Pending;\r\n\r\n    // Returns uint\r\n    // Pending  - 0\r\n    // Shipped  - 1\r\n    // Accepted - 2\r\n    // Rejected - 3\r\n    // Canceled - 4\r\n    function get() public view returns (Status) {\r\n        // status = Status.Shipped;\r\n        return status;\r\n    }\r\n\r\n    // Update status by passing uint into input\r\n    function set(Status _status) public {\r\n        // require(_status==Status.Pending,\"error\");\r\n        status = _status;\r\n    }\r\n\r\n    // You can update to a specific enum like this\r\n    function cancel() public {\r\n        status = Status.Canceled;\r\n    }\r\n\r\n    // delete resets the enum to its first value, 0\r\n    function reset() public {\r\n        delete status;\r\n    }\r\n}\r\n"
  },
  {
    "path": "SmartContracts/Errors.sol",
    "content": "\r\n\r\n// Error\r\n// An error will undo all changes made to the state during a transaction.\r\n\r\n// You can throw an error by calling require, revert or assert.\r\n\r\n// require is used to validate inputs and conditions before execution.\r\n// revert is similar to require. See the code below for details.\r\n// assert is used to check for code that should never be false. Failing assertion probably means that there is a bug.\r\n\r\n// Use custom error to save gas.\r\n\r\n\r\n// SPDX-License-Identifier: MIT\r\n\r\n\r\n\r\n// Proposed Solidity best practice:\r\n\r\n// Use the name of the smart contract as a prefix for custom errors.\r\n\r\n// This helps end users identify which contract reverted a failed tx, which is especially useful for complex txs that involve multiple contracts.\r\n\r\n\r\npragma solidity ^0.8.7;\r\n\r\n\r\n\r\n\r\ncontract Error {\r\n\r\n    error Error__GreaterThanTen(uint amount);\r\n\r\n    function testRequire(uint _i) public pure returns(uint) {\r\n        // Require should be used to validate conditions such as:\r\n        // - inputs\r\n        // - conditions before execution\r\n        // - return values from calls to other functions\r\n        require(_i > 10, \"Input must be greater than 10\");\r\n        return _i;\r\n    }\r\n\r\n    function testRevert(uint _i) public pure returns(uint) {\r\n        // Revert is useful when the condition to check is complex.\r\n        // This code does the exact same thing as the example above\r\n        if (_i <= 10) {\r\n            revert Error__GreaterThanTen({amount:_i});\r\n        }\r\n        return _i;\r\n    }\r\n\r\n}\r\n"
  },
  {
    "path": "SmartContracts/EtherUnits.sol",
    "content": "// SPDX-License-Identifier: MIT\r\npragma solidity 0.8.7;\r\n\r\n\r\n\r\n// Ether and Wei\r\n// Transactions are paid with ether.\r\n\r\n// Similar to how one dollar is equal to 100 cent, one ether is equal to 10^18 wei.\r\n\r\ncontract EtherUnits {\r\n    // uint n = 1;\r\n    uint public oneWei = 1 wei;\r\n    // 1 wei is equal to 1\r\n    bool public isOneWei = 1 wei == 1;\r\n\r\n    uint public oneEther = 1 ether;\r\n    // 1 ether is equal to 10^18 wei\r\n    bool public isOneEther = 1 ether == 1e18;\r\n}\r\n"
  },
  {
    "path": "SmartContracts/Events.sol",
    "content": "\r\n// SPDX-License-Identifier: MIT\r\npragma solidity ^0.8.7;\r\n\r\n\r\n\r\n// Events allow logging to the Ethereum blockchain. Some use cases for events are:\r\n// Listening for events and updating user interface\r\n// A cheap form of storage\r\n\r\n\r\ncontract Event {\r\n    // Event declaration\r\n    // Up to 3 parameters can be indexed.\r\n    // Indexed parameters helps you filter the logs by the indexed parameter\r\n    event Log(address indexed sender, string message);\r\n    event AnotherLog();\r\n\r\n    function test() public {\r\n        emit Log(msg.sender, \"Hello World!\");\r\n        emit Log(msg.sender, \"Hello EVM!\");\r\n        emit AnotherLog();\r\n    }\r\n}\r\n"
  },
  {
    "path": "SmartContracts/FunctionModifier.sol",
    "content": "// SPDX-License-Identifier: MIT\r\npragma solidity 0.8.7;\r\n\r\n\r\n// Function Modifier\r\n// Modifiers can be used to:\r\n\r\n// Restrict access\r\n// Validate inputs\r\n// Guard against reentrancy hack\r\n\r\n// modifier is used to reuse the code,\r\n// it can be used by three ways\r\n//  without argument\r\n// with argument\r\n// sandwhich\r\n\r\n\r\ncontract FunctionModifier{\r\n\r\n address public owner = 0x5B38Da6a701c568545dCfcB03FcB875f56beddC4;\r\n\r\n    modifier onlyOwner(){\r\n        require(msg.sender==owner,\"you are not an owner\");\r\n_; //jis function se aae ho us function me jaao\r\n    }\r\n\r\n\r\nmodifier validateNumber(uint num){\r\n        require(num==10,\"not 10\");\r\n_; //jis function se aae ho us function me jaao\r\n    }\r\n\r\nfunction secret(uint num) external view onlyOwner validateNumber(num) returns(address){\r\n    \r\n    return owner;\r\n}\r\n\r\n\r\n\r\n\r\n}"
  },
  {
    "path": "SmartContracts/Functions.sol",
    "content": "// SPDX-License-Identifier: MIT\r\npragma solidity 0.8.7;\r\n\r\n// Function:\r\n// A piece of code which may or may not take some input, do some coputation and return output\r\n// Once a function is defined, it can be used over and over and over again\r\n\r\n// In solidity there are many ways to write function in terms of output.\r\n// 1. return single value\r\n// 2. return multiple values\r\n// 3. return multiple values without return statement(by declaring return values in the definition of function)\r\n\r\n\r\n// Use destructuring assignment when calling another\r\n// function that returns multiple values.\r\n\r\ncontract Functions{\r\n\r\n    uint public x = 5;\r\n\r\n\r\n    function SingleValue(uint num) public view returns(uint){\r\n\r\n        return num + x;\r\n    }\r\n    \r\n    function useSingleValue() public view returns(uint){\r\n    \r\n    uint y = SingleValue(8);\r\n    return y;\r\n    \r\n    }\r\n\r\nfunction MultipleValues()public pure returns(uint,bool,int){\r\n    uint u =5;\r\n    bool y = true;\r\n    int z = 10;\r\n    // return (5,true,10)\r\n    return (u,y,z);\r\n}\r\n\r\n\r\n\r\nfunction MultipleValuesDec()public pure returns(uint u,bool y,int z){\r\n     u = 5;\r\n     y = true;\r\n    //  z = 10;\r\n    // return (5,true,10)\r\n    // return (u,y,z);\r\n}\r\n\r\n\r\nfunction Destructuring() public pure returns(uint){\r\n\r\n    (uint a, uint b,uint c) = (5,6,7);\r\n\r\n    return a+b+c;\r\n\r\n}\r\n\r\nfunction useMultibleValues() public pure returns(uint,bool,int){\r\n\r\n    (uint a,bool b,int c) = MultipleValues();\r\n\r\n    return (a,b,c);\r\n\r\n}\r\n\r\n\r\n}\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n"
  },
  {
    "path": "SmartContracts/Gas.sol",
    "content": "// Gas\r\n// How much ether do you need to pay for a transaction?\r\n// You pay gas spent * gas price amount of ether, where\r\n\r\n// gas is a unit of computation\r\n// gas spent is the total amount of gas used in a transaction\r\n// gas price is how much ether you are willing to pay per gas\r\n// Transactions with higher gas price have higher priority to be included in a block.\r\n\r\n// Unspent gas will be refunded.\r\n\r\n// Gas Limit\r\n// There are 2 upper bounds to the amount of gas you can spend\r\n\r\n// gas limit (max amount of gas you're willing to use for your transaction, set by you)\r\n// block gas limit (max amount of gas allowed in a block, set by the network)\r\n\r\n\r\n\r\n\r\n\r\n"
  },
  {
    "path": "SmartContracts/GasOpt.sol",
    "content": "// SPDX-License-Identifier: MIT\r\npragma solidity ^0.8.7;\r\n\r\n\r\ncontract GasOpt {\r\n    // start - 50992 gas\r\n    // use calldata - 49163 gas\r\n    // load state variables to memory - 48952  gas\r\n    // short circuit -  48634 gas\r\n    // loop increments - 48244 gas\r\n    // cache array length - 48201  gas\r\n    // load array elements to memory - 48039 gas\r\n    // uncheck i overflow/underflow - 47301 gas\r\n\r\n\r\n\r\n    uint public total;\r\n    // [1, 2, 3, 4, 5, 100]\r\n\r\n    function sumIfEvenAndLessThan99(uint[] calldata nums) external {\r\n        \r\n        uint _total;\r\n        uint l = nums.length;\r\n        for (uint i = 0; i < l;) {\r\n        uint n = nums[i]; \r\n            if (n % 2 == 0 && n < 99) {\r\n                _total += n;\r\n            }\r\n        \r\n        unchecked{\r\n            ++i;\r\n        } \r\n        }\r\n\r\n\r\n        total = _total;\r\n    }\r\n\r\n \r\n}"
  },
  {
    "path": "SmartContracts/GlobalVariables.sol",
    "content": "// SPDX-License-Identifier: MIT\r\n\r\npragma solidity 0.8.7;\r\n\r\n\r\n// Global Variables − \r\n// Special variables exists in the global namespace used to get information about the blockchain.\r\n\r\n// e.g.\r\n// block.chainid (uint): current chain id\r\n\r\n// block.difficulty (uint): current block difficulty\r\n\r\n// block.number (uint): current block number\r\n\r\n// c (uint): current block timestamp as seconds since unix epoch\r\n\r\n// msg.data (bytes calldata): complete calldata\r\n\r\n// msg.sender (address): sender of the message (current call)\r\n\r\n// msg.sig (bytes4): first four bytes of the calldata (i.e. function identifier)\r\n\r\n// msg.value (uint): number of wei sent with the message\r\n\r\n\r\ncontract GlobalVariables{\r\n\r\n\r\nfunction global() external view returns(address,uint,uint){\r\n    address sender = msg.sender;\r\n    uint blockNum = block.number;\r\n    uint blockDiff = block.difficulty;\r\n\r\n    return(sender,blockNum,blockDiff);\r\n}\r\n\r\n\r\n}\r\n"
  },
  {
    "path": "SmartContracts/HelloWorld.sol",
    "content": "// SPDX-License-Identifier: MIT\r\n\r\n// pragma solidity >0.8.0 < 0.9.9\r\n// pragma solidity ^0.8.0;\r\npragma solidity 0.8.7;\r\n\r\n\r\ncontract HelloWorld{\r\n\r\nstring public greet = \"Hello World\";\r\n\r\n}"
  },
  {
    "path": "SmartContracts/IfElse.sol",
    "content": "// SPDX-License-Identifier: MIT\r\npragma solidity 0.8.7;\r\n\r\n// Operators\r\n//  == equal to\r\n// < less than\r\n//  > greater than\r\n//  <= less than equal to\r\n//  >= greater than equal to \r\n//  != not equals to\r\n\r\n// Logical Operators:\r\n// AND (cond1 && cond2) True when both conditions are true\r\n// OR (cond1 || cond2) True when any one condition is true\r\n\r\n// require(condition,\"error msg\")\r\n// if true continue execution otherwise print return error msg and stop excecution\r\n\r\ncontract IfElse{\r\n    \r\n    function grade(uint num) external pure returns(uint){\r\n        require(num>10,\"num is less than 10\");\r\n    return num;\r\n\r\n    }\r\n\r\n\r\nfunction gradeIfElse(uint num) external pure returns(uint){\r\n    if(num > 10){\r\n        return 90;\r\n    }\r\n   \r\n    else{\r\n        return 70;\r\n    }\r\n}\r\n\r\n\r\nfunction ternary(uint num) external pure returns(uint){\r\n    // condition ? when true : when false\r\n    return num>10 ? 90 : 70;\r\n}\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n}"
  },
  {
    "path": "SmartContracts/Immutable.sol",
    "content": "// SPDX-License-Identifier: MIT\r\npragma solidity 0.8.7;\r\n\r\n\r\ncontract Immutable{\r\n \r\n\r\nuint public constant MY_NUM = 10;\r\naddress public immutable IMM_OWNER;\r\n\r\n\r\n\r\n// contsant variable values never change;\r\n// they must be initialize during the deployment of contract\r\n// it saves gas cost\r\n\r\nconstructor (address _owner){\r\nIMM_OWNER = _owner;\r\n\r\n}\r\n\r\n\r\n}"
  },
  {
    "path": "SmartContracts/Import.sol",
    "content": "// SPDX-License-Identifier: MIT\r\npragma solidity 0.8.7;\r\n\r\nimport \"./HelloWorld.sol\";\r\nimport \"https://github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v4.5/contracts/token/ERC20/ERC20.sol\";\r\n\r\ncontract IMport is ERC20  {\r\n\r\n\r\n// HelloWorld h = new HelloWorld();\r\n\r\n//  string public hello = h.greet();\r\n   constructor(string memory name_, string memory symbol_) ERC20(name_,symbol_) {}\r\n\r\n}"
  },
  {
    "path": "SmartContracts/Inharitance.sol",
    "content": "\r\n// SPDX-License-Identifier: MIT\r\npragma solidity 0.8.7;\r\n\r\n\r\n// Solidity supports multiple inheritance. Contracts can inherit other contract by using the \"is\" keyword.\r\n// Function that is going to be overridden by a child contract must be declared as virtual.\r\n// Function that is going to override a parent function must use the keyword override.\r\n// Order of inheritance is important.\r\n\r\n// H.W : What is Multiple Inharitace and Multilevel Inharitance\r\n\r\n\r\ncontract A {\r\n    function foo() public pure virtual returns (string memory) {\r\n        return \"A\";\r\n    }\r\n}\r\n\r\n// Contracts inherit other contracts by using the keyword 'is'.\r\ncontract B is A {\r\n    // Override A.foo()\r\n    function foo() public pure virtual override  returns (string memory) {\r\n        return \"B\";\r\n    }\r\n\r\n}\r\n\r\n\r\ncontract C is B {\r\n    // Override A.foo()\r\n    function foo() public pure override  returns (string memory) {\r\n        return \"C\";\r\n    }\r\n\r\n}"
  },
  {
    "path": "SmartContracts/LocalVariables.sol",
    "content": "// SPDX-License-Identifier: MIT\r\npragma solidity 0.8.7;\r\n\r\n\r\n\r\n// Local Variable\r\n// Variables whose values are available only within a function where it is defined. \r\n// Function parameters are always local to that function.\r\n// Always declare or initilaize inside a function\r\n\r\n\r\ncontract LocalVariables{\r\n\r\n\r\n    uint public num; //state Variable\r\n\r\n    // write\r\n    function setNum(uint number) external{\r\n        num = number;   \r\n\r\n    }\r\n\r\nfunction add(uint _a, uint _b ) external pure  returns(uint){\r\n     // local variabels\r\n\r\n    uint  a =_a;\r\n    uint b = _b;\r\nreturn a+b;\r\n\r\n}\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n}\r\n"
  },
  {
    "path": "SmartContracts/Loops.sol",
    "content": "// SPDX-License-Identifier: MIT\r\npragma solidity 0.8.7;\r\n\r\n\r\n// For and While Loop\r\n// Solidity supports for, while, and do while loops.\r\n// Don't write loops that are unbounded as this can hit the gas limit, causing your transaction to fail.\r\n// For the reason above, while and do while loops are rarely used.\r\n\r\n\r\ncontract Loops{\r\n  function Forloop() public  pure returns(uint) {\r\n        // for loop\r\n        // i++ => i = i + 1\r\n        uint c = 0;\r\n        for (uint i = 0; i < 10; i++) {\r\n            if (i == 3) {\r\n                // Skip to next iteration with continue\r\n                continue;\r\n            }\r\n            if (i == 5) {\r\n                // Exit loop with break\r\n                break;\r\n            }\r\n            c+=1; // c = 4\r\n        }\r\n        return c;\r\n  }\r\n    \r\n     function Whileloop() public pure returns(uint) {\r\n\r\n        // while loop\r\n        uint j;//0\r\n        while (true) {\r\n            j++;//j = j + 1\r\n        }\r\n        return j;\r\n\r\n     }\r\n\r\n}"
  },
  {
    "path": "SmartContracts/Mappings.sol",
    "content": "// SPDX-License-Identifier: MIT\r\npragma solidity 0.8.7;\r\n\r\n\r\n// Mapping\r\n// Maps are created with the syntax mapping(keyType => valueType).\r\n// The keyType can be any built-in value type, bytes, string, or any contract.\r\n// valueType can be any type including another mapping or an array.\r\n// Mappings are not iterable.\r\n\r\n\r\ncontract Mapping{\r\n \r\n    // Mapping from address to uint\r\n    mapping(address => uint) public myMap; \r\n\r\n    function get(address _addr) public view returns (uint) {\r\n        // Mapping always returns a value.\r\n        // If the value was never set, it will return the default value.\r\n        return myMap[_addr];\r\n    }\r\n\r\n    function set(address _addr, uint _i) public {\r\n        // Update the value at this address\r\n        myMap[_addr] = _i;\r\n    }\r\n\r\n    function remove(address _addr) public {\r\n        // Reset the value to the default value.\r\n        delete myMap[_addr];\r\n    }\r\n\r\n\r\n}\r\n\r\n\r\ncontract NestedMapping {\r\n    // Nested mapping (mapping from address to another mapping)\r\n    mapping(address => mapping(uint => bool)) public nested;\r\n\r\n    function get(address _addr1, uint _i) public view returns (bool) {\r\n        // You can get values from a nested mapping\r\n        // even when it is not initialized\r\n        return nested[_addr1][_i];\r\n    }\r\n\r\n    function set(\r\n        address _addr1,\r\n        uint _i,\r\n        bool _boo\r\n    ) public {\r\n        nested[_addr1][_i] = _boo;\r\n    }\r\n\r\n    function remove(address _addr1, uint _i) public {\r\n        delete nested[_addr1][_i];\r\n    }\r\n}"
  },
  {
    "path": "SmartContracts/MathLib.sol",
    "content": "// SPDX-License-Identifier: MIT\r\npragma solidity 0.8.7;\r\n\r\n\r\n\r\n// Library\r\n// Libraries are similar to contracts, but you can't declare any state variable and you can't send ether.\r\n\r\n// A library is embedded into the contract if all library functions are internal.\r\n\r\n// Otherwise the library must be deployed and then linked before the contract is deployed.\r\n\r\n\r\nlibrary Math{\r\n\r\n    function add(uint a, uint b) internal pure  returns(uint){\r\n        return a+b;\r\n    }\r\n}"
  },
  {
    "path": "SmartContracts/Payable.sol",
    "content": "\r\n\r\n\r\n// Payable\r\n// Functions and addresses declared payable can receive ether into the \r\n// contract.\r\n\r\n\r\n// SPDX-License-Identifier: MIT\r\npragma solidity ^0.8.7;\r\n\r\ncontract Payable {\r\n    // Payable address can receive Ether\r\n    address payable public owner;\r\n\r\n    // Payable constructor can receive Ether\r\n    constructor() payable {\r\n        owner = payable(msg.sender);\r\n    }\r\n\r\n    // Function to deposit Ether into this contract.\r\n    // Call this function along with some Ether.\r\n    // The balance of this contract will be automatically updated.\r\n    function deposit() public payable {}\r\n\r\n    // Call this function along with some Ether.\r\n    // The function will throw an error since this function is not payable.\r\n    function notPayable() public {}\r\n\r\n    // Function to withdraw all Ether from this contract.\r\n    function getBalance() public view returns(uint) {\r\n        // get the amount of Ether stored in this contract\r\n        uint amount = address(this).balance;\r\n\r\n   return amount;\r\n    }\r\n\r\n\r\n}\r\n"
  },
  {
    "path": "SmartContracts/SendEther.sol",
    "content": "// How to send Ether?\r\n// You can send Ether to other contracts by\r\n\r\n// transfer (2300 gas, throws error)\r\n// send (2300 gas, returns bool)\r\n// call (forward all gas or set gas, returns bool)\r\n// How to receive Ether?\r\n// A contract receiving Ether must have at least one of the functions below\r\n\r\n// receive() external payable\r\n// fallback() external payable\r\n// receive() is called if msg.data is empty, otherwise fallback() is called.\r\n\r\n// Which method should you use?\r\n// call in combination with re-entrancy guard is the recommended method to use after December 2019.\r\n\r\n\r\n\r\n// SPDX-License-Identifier: MIT\r\npragma solidity 0.8.7;\r\n\r\ncontract ReceiveEther {\r\n    /*\r\n    Which function is called, fallback() or receive()?\r\n\r\n           send Ether\r\n               |\r\n         msg.data is empty?\r\n              / \\\r\n            yes  no\r\n            /     \\\r\nreceive() exists?  fallback()\r\n         /   \\\r\n        yes   no\r\n        /      \\\r\n    receive()   fallback()\r\n    */\r\n\r\n// 0x5e17b14ADd6c386305A32928F985b29bbA34Eff5\r\n    // Function to receive Ether. msg.data must be empty\r\n    receive() external payable { }\r\n\r\n    // Fallback function is called when msg.data is not empty\r\n    fallback() external payable {}\r\n\r\n    \r\n    function getBalance() public view returns (uint) {\r\n        return address(this).balance;\r\n    }\r\n}\r\n\r\ncontract SendEther {\r\n    function sendViaTransfer(address payable _to) public payable {\r\n        // This function is no longer recommended for sending Ether.\r\n        _to.transfer(msg.value);\r\n    }\r\n\r\n    function sendViaSend(address payable _to) public payable {\r\n        // Send returns a boolean value indicating success or failure.\r\n        // This function is not recommended for sending Ether.\r\n        bool sent = _to.send(msg.value);\r\n        require(sent, \"Failed to send Ether\");\r\n    }\r\n\r\n    function sendViaCall(address payable _to) public payable {\r\n        // Call returns a boolean value indicating success or failure.\r\n        // This is the current recommended method to use.\r\n        (bool sent, bytes memory data) = _to.call{value: msg.value}(\"\");\r\n        require(sent, \"Failed to send Ether\");\r\n    }\r\n}\r\n"
  },
  {
    "path": "SmartContracts/SimpleStorage.sol",
    "content": "// SPDX-License-Identifier: MIT\r\npragma solidity 0.8.7;\r\n\r\n\r\n// STATE VARIABLES \r\n//  AND\r\n// LOCAL VARIABLES\r\n\r\n\r\ncontract SimpleStorage{\r\n\r\n}"
  },
  {
    "path": "SmartContracts/StateVariable.sol",
    "content": "// SPDX-License-Identifier: MIT\r\npragma solidity 0.8.7;\r\n\r\n\r\n// State Variables − Variables whose values are permanently stored in a contract storage.\r\n// Write State Variable cost gas fee\r\n// Read State Variables are free\r\n//  always declare outside of function\r\n\r\n\r\ncontract StateVariable{\r\n\r\n uint public num;\r\n\r\n// write\r\nfunction setNum(uint number) external{\r\n    num = number;   \r\n}\r\n\r\n// read\r\nfunction getNum() external view returns(uint){\r\n    return num;\r\n}\r\n\r\n\r\n}"
  },
  {
    "path": "SmartContracts/Struct.sol",
    "content": "// SPDX-License-Identifier: MIT\r\npragma solidity ^0.8.7;\r\n\r\n\r\n\r\n// Structs\r\n// You can define your own type by creating a struct.\r\n\r\n// They are useful for grouping together related data.\r\n\r\n// Structs can be declared outside of a contract and imported in another contract.\r\n\r\n\r\ncontract Todos {\r\n    \r\n    struct Todo {\r\n        string text;\r\n        bool completed;\r\n    }\r\n\r\n// Todo public myTodo = Todo(\"greeting\",false);\r\n// Todo public _Todo = Todo({text : \"greeting\",completed : false});\r\n\r\n\r\n    // An array of 'Todo' structs\r\n    Todo[] public todos;\r\n\r\n    function create(string calldata _text) public {\r\n        // 3 ways to initialize a struct\r\n        // - calling it like a function\r\n        todos.push(Todo(_text, false));\r\n\r\n        // key value mapping\r\n        todos.push(Todo({text: _text, completed: false}));\r\n\r\n        // initialize an empty struct and then update it\r\n        Todo memory todo;\r\n        todo.text = _text;\r\n        // todo.completed = false;\r\n        // todo.completed initialized to false\r\n\r\n        todos.push(todo);\r\n    }\r\n\r\n    // Solidity automatically created a getter for 'todos' so\r\n    // you don't actually need this function.\r\n    function get(uint _index) public view returns (string memory text, bool completed) {\r\n        Todo storage todo = todos[_index];\r\n        return (todo.text, todo.completed);\r\n    }\r\n\r\n    // update text\r\n    function updateText(uint _index, string calldata _text) public {\r\n        Todo storage todo = todos[_index];\r\n        todo.text = _text;\r\n    }\r\n\r\n    // update completed\r\n    function toggleCompleted(uint _index) public {\r\n        Todo storage todo = todos[_index];\r\n        todo.completed = !todo.completed;\r\n    }\r\n}\r\n"
  },
  {
    "path": "SmartContracts/UseMathLib.sol",
    "content": "// SPDX-License-Identifier: MIT\r\npragma solidity 0.8.7;\r\n\r\nimport \"./MathLib.sol\";\r\n\r\ncontract UseMath {\r\n\r\nuint public  a  = Math.add(2,4);\r\n\r\n    \r\n}"
  },
  {
    "path": "SmartContracts/Variables.sol",
    "content": "// SPDX-License-Identifier: MIT\r\npragma solidity 0.8.7;\r\n\r\n\r\n\r\n\r\ncontract Variable{\r\n    //boolean\r\n    //integer\r\n    //unsign integer\r\n    //string\r\n    //bytes\r\n    //address\r\n\r\n//  range of uint8 0 - (2**8)-1\r\n\r\n// uint8 public pos_number = 255; \r\n// int8 public number = 15;\r\nbool public han = true; // false\r\naddress public hmoe = 0x5B38Da6a701c568545dCfcB03FcB875f56beddC4; // 0x00000\r\nstring public greet = \"hello Blockchain people\";// \"\"\r\nuint8 constant  pos_number = 255; \r\nint8 constant number = 15;\r\n\r\n// uint = uint256\r\nuint public num; //0\r\n\r\n}"
  },
  {
    "path": "SmartContracts/ViewPure.sol",
    "content": "// SPDX-License-Identifier: MIT\r\npragma solidity 0.8.7;\r\n\r\n\r\n// View and Pure Functions\r\n\r\n// In View function: we can only read state variable and not write.\r\n// in Pure function: we can neither read nor write state variables.\r\n// In transaction function: we can write state variable.\r\n\r\ncontract ViewPure{\r\n\r\n    uint public x = 5;\r\n\r\n\r\n    function ViewFunc(uint _num) public view returns(uint){\r\n\r\n        return x + _num;\r\n    }\r\n\r\n    function PureFunc(uint a , uint b) public pure returns(uint){\r\n\r\n    return a+b;\r\n    \r\n    }\r\n\r\n    function TraFunc() public returns(uint){\r\n        x = 10;\r\n        return x;\r\n    }\r\n\r\n\r\n}"
  }
]