├── .gitignore ├── LICENSE ├── README.md ├── chronological-issues-from-video.md └── img └── youtube_thumbnail.jpeg /.gitignore: -------------------------------------------------------------------------------- 1 | .vscode 2 | .env 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 SmartContract 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | _Big Update_: [New Sepolia Faucet Located Here](https://sepoliafaucet.com/). 2 | \Kovan, Ropsten, and Rinkeby have been deprecated. Goerli Still works but we highly recommend Sepolia as its proof of stake based. 3 | 4 | You'll need to verify via Twitter to get ETH & LINK. 5 | You can find [Backup Faucets here](https://docs.chain.link/docs/link-token-contracts/#goerli). 6 | 7 | Additionally, lesson 7 uses Chainlink VRF v1 instead of v2, [you can find the docs for Chainlink VRFv1 here](https://docs.chain.link/vrf/v1/examples/get-a-random-number). 8 | 9 | [YouTube Video](https://www.youtube.com/watch?v=M576WGiDBdQ) 10 | 11 |
12 |

13 | 14 | Solidity, Blockchain, and Smart Contract Course – Beginner to Expert Python Tutorial 15 | 16 |

17 |
18 | 19 | Welcome to the repository for the Ultimate Solidity, Blockchain, and Smart Contract - Beginner to Expert Full Course | Python Edition FreeCodeCamp course! 20 | 21 | # Table of Contents 22 | 23 | - [Table of Contents](#table-of-contents) 24 | - [Resources For This Course](#resources-for-this-course) 25 | - [Questions](#questions) 26 | - [Windows Support](#windows-support) 27 | - [Hiccups/Issues from the Video](#hiccupsissues-from-the-video) 28 | - [Lesson 0: Welcome To Blockchain](#lesson-0-welcome-to-blockchain) 29 | - [What is a Blockchain?](#what-is-a-blockchain) 30 | - [Making Your First Transaction](#making-your-first-transaction) 31 | - [How Do Blockchains Work?](#how-do-blockchains-work) 32 | - [Consensus](#consensus) 33 | - [The Future](#the-future) 34 | - [Miscellaneous](#miscellaneous) 35 | - [Lesson 1: Welcome to Remix! Simple Storage](#lesson-1-welcome-to-remix-simple-storage) 36 | - [Everything in this section can be read about in the Solidity Documentation](#everything-in-this-section-can-be-read-about-in-the-solidity-documentation) 37 | - [Remix](#remix) 38 | - [Basic Solidity](#basic-solidity) 39 | - [Deploying to a "Live" network](#deploying-to-a-live-network) 40 | - [Lesson 2: Storage Factory](#lesson-2-storage-factory) 41 | - [Inheritance, Factory Pattern, and Interacting with External Contracts](#inheritance-factory-pattern-and-interacting-with-external-contracts) 42 | - [Lesson 3: Fund Me](#lesson-3-fund-me) 43 | - [Payable, msg.sender, msg.value, Units of Measure](#payable-msgsender-msgvalue-units-of-measure) 44 | - [Chainlink Oracles](#chainlink-oracles) 45 | - [Importing from NPM and Advanced Solidity](#importing-from-npm-and-advanced-solidity) 46 | - [Lesson 4: Web3.py Simple Storage](#lesson-4-web3py-simple-storage) 47 | - [Installing VSCode, Python, and Web3](#installing-vscode-python-and-web3) 48 | - [Our First Python Script with Web3.py - Deploying a Contract](#our-first-python-script-with-web3py---deploying-a-contract) 49 | - [Interacting with Our Contract in Python & Web3.py](#interacting-with-our-contract-in-python--web3py) 50 | - [Lesson 5: Brownie Simple Storage](#lesson-5-brownie-simple-storage) 51 | - [Brownie Introduction](#brownie-introduction) 52 | - [Installing Brownie](#installing-brownie) 53 | - [Brownie Simple Storage Project](#brownie-simple-storage-project) 54 | - [Testing Basics](#testing-basics) 55 | - [[Brownie console]](#brownie-console) 56 | - [Lesson 6: Brownie Fund Me](#lesson-6-brownie-fund-me) 57 | - [Introduction](#introduction) 58 | - [Dependencies, Deploying, and Networks](#dependencies-deploying-and-networks) 59 | - [Funding and Withdrawing Python Scripts](#funding-and-withdrawing-python-scripts) 60 | - [Testing across networks](#testing-across-networks) 61 | - [Git](#git) 62 | - [Compatibility with Ganache UI](#compatibility-with-ganache-ui) 63 | - [Lesson 7: SmartContract Lottery](#lesson-7-smartcontract-lottery) 64 | - [Introduction](#introduction-1) 65 | - [`Lottery.sol`](#lotterysol) 66 | - [Testing Lottery.sol](#testing-lotterysol) 67 | - [Lottery.sol Testnet Deployment](#lotterysol-testnet-deployment) 68 | - [Lesson 8: Chainlink Mix](#lesson-8-chainlink-mix) 69 | - [Brownie Mixes](#brownie-mixes) 70 | - [Lesson 9: ERC20s, EIPs, and Token Standards](#lesson-9-erc20s-eips-and-token-standards) 71 | - [Lesson 10: Defi & Aave](#lesson-10-defi--aave) 72 | - [Defi Intro](#defi-intro) 73 | - [Aave UI](#aave-ui) 74 | - [Programmatic Interactions with Aave](#programmatic-interactions-with-aave) 75 | - [Testing](#testing) 76 | - [Lesson 11: NFTs](#lesson-11-nfts) 77 | - [Non-Technical Explainer](#non-technical-explainer) 78 | - [Simple NFT](#simple-nft) 79 | - [SimpleCollectible Testing](#simplecollectible-testing) 80 | - [Advanced NFT](#advanced-nft) 81 | - [Advanced deploy_and_create](#advanced-deploy_and_create) 82 | - [Creating Metadata & IPFS](#creating-metadata--ipfs) 83 | - [Lesson 12: Upgrades](#lesson-12-upgrades) 84 | - [Introduction to upgrading smart contracts](#introduction-to-upgrading-smart-contracts) 85 | - [Upgrades-mix and code](#upgrades-mix-and-code) 86 | - [Testing Upgrades](#testing-upgrades) 87 | - [Upgrades on a testnet](#upgrades-on-a-testnet) 88 | - [Bonus Lesson 13: Full Stack Defi](#bonus-lesson-13-full-stack-defi) 89 | - [Defi Stake Yield Brownie Scripts & Tests](#defi-stake-yield-brownie-scripts--tests) 90 | - [Testing our Defi Stake Yield Brownie Dapp](#testing-our-defi-stake-yield-brownie-dapp) 91 | - [Front End / Full Stack](#front-end--full-stack) 92 | - [Closing and Summary](#closing-and-summary) 93 | - [Security](#security) 94 | - [Where do I go now?](#where-do-i-go-now) 95 | - [Learning More](#learning-more) 96 | - [Community](#community) 97 | - [Hackathons](#hackathons) 98 | - [Vyper](#vyper) 99 | 100 | # Resources For This Course 101 | 102 | ### Questions 103 | 104 | - [Github Discussions](https://github.com/smartcontractkit/full-blockchain-solidity-course-py/discussions) 105 | - Ask questions and chat about the course here! 106 | - [Stack Exchange Ethereum](https://ethereum.stackexchange.com/) 107 | - Great place for asking technical questions about Ethereum 108 | - [StackOverflow](https://stackoverflow.com/) 109 | - Great place for asking technical questions overall 110 | 111 | ### Windows Support 112 | 113 | - [Setup your windows environment](https://medium.com/@cromewar/how-to-setup-windows-10-11-for-smart-contract-development-and-brownie-e7d8d13555b3) 114 | - Learn how to install all the tools you will need for this course on a windows machine 115 | 116 | ### Hiccups/Issues from the Video 117 | 118 | - [Chronological Issues from the Video](https://github.com/smartcontractkit/full-blockchain-solidity-course-py/blob/main/chronological-issues-from-video.md) 119 | - A list of known hiccups/issues you may encounter while implementing the content from the video 120 | 121 | # Lesson 0: Welcome To Blockchain 122 | 123 | ## What is a Blockchain? 124 | 125 | - [Bitcoin Whitepaper](https://bitcoin.org/bitcoin.pdf) 126 | - [Ethereum Whitepaper](https://ethereum.org/en/whitepaper/) 127 | - [Hybrid Smart Contracts](https://blog.chain.link/hybrid-smart-contracts-explained/) 128 | - [Blockchain Oracles](https://betterprogramming.pub/what-is-a-blockchain-oracle-f5ccab8dbd72?source=friends_link&sk=d921a38466df8a9176ed8dd767d8c77d) 129 | - [What is a blockchain](https://www.investopedia.com/terms/b/blockchain.asp) 130 | 131 | ## Making Your First Transaction 132 | 133 | - [Metamask](https://metamask.io/) 134 | - [Etherscan](https://etherscan.io/) 135 | - [Goerli Etherscan](https://goerli.etherscan.io/) 136 | - [Kovan Etherscan](https://kovan.etherscan.io/) 137 | - [Goerli Faucet](https://faucets.chain.link/goerli) 138 | - [Sepolia Faucet](https://sepoliafaucet.com/) 139 | - [Sepolia Etherscan](https://sepolia.etherscan.io/) 140 | 141 | - Rinkeby Faucet (Check the [link token contracts page](https://docs.chain.link/docs/link-token-contracts/#rinkeby)) 142 | - NOTE: You can always find the most up to date faucets at [faucets.chain.link](https://faucets.chain.link/). 143 | - OR, use the [Kovan ETH Faucet](https://faucets.chain.link/), just be sure to swap your metamask to kovan! 144 | - [Gas and Gas Fees](https://ethereum.org/en/developers/docs/gas/) 145 | - [Wei, Gwei, and Ether Converter](https://eth-converter.com/) 146 | - [ETH Gas Station](https://ethgasstation.info/) 147 | 148 | ## How Do Blockchains Work? 149 | 150 | - [Blockchain Demo](https://andersbrownworth.com/blockchain/) 151 | - [Public / Private Keys](https://andersbrownworth.com/blockchain/public-private-keys/keys) 152 | - [Layer 2 and Rollups](https://ethereum.org/en/developers/docs/scaling/layer-2-rollups/) 153 | - [Decentralized Blockchain Oracles](https://blog.chain.link/what-is-the-blockchain-oracle-problem/) 154 | - [Block Rewards](https://www.investopedia.com/terms/b/block-reward.asp) 155 | - [Run Your Own Ethereum Node](https://geth.ethereum.org/docs/getting-started) 156 | 157 | ### Consensus 158 | 159 | - [Consensus](https://wiki.polkadot.network/docs/learn-consensus) 160 | - [Proof of Stake](https://ethereum.org/en/developers/docs/consensus-mechanisms/pos/) 161 | - [Proof of Work](https://ethereum.org/en/developers/docs/consensus-mechanisms/pow/) 162 | - [Nakamoto Consensus](https://blockonomi.com/nakamoto-consensus/) 163 | 164 | ## The Future 165 | 166 | - [Ethereum 2](https://ethereum.org/en/eth2/) 167 | 168 | ## Miscellaneous 169 | 170 | - [DAOs](https://www.investopedia.com/tech/what-dao/) 171 | 172 | # Lesson 1: [Welcome to Remix! Simple Storage](https://github.com/PatrickAlphaC/simple_storage) 173 | 174 | 💻 Code: https://github.com/PatrickAlphaC/simple_storage 175 | 176 | ### Everything in this section can be read about in the [Solidity Documentation](https://docs.soliditylang.org/en/v0.8.6/index.html) 177 | 178 | ### [Remix](https://remix.ethereum.org/) 179 | 180 | ### Basic Solidity 181 | 182 | - Versioning 183 | - Compiling 184 | - Contract Declaration 185 | - [Types & Declaring Variables](https://docs.soliditylang.org/en/v0.8.6/types.html) 186 | - `uint256`, `int256`, `bool`, `string`, `address`, `bytes32` 187 | - Default Initializations 188 | - Comments 189 | - Functions 190 | - Deploying a Contract 191 | - Calling a public state-changing Function 192 | - [Visibility](https://docs.soliditylang.org/en/v0.7.3/contracts.html#visibility-and-getters) 193 | - Scope 194 | - View & Pure Functions 195 | - Structs 196 | - Intro to Storage 197 | - Arrays - Dynamic & Fixed sized 198 | - Compiler Errors and Warnings 199 | - Memory 200 | - Mappings 201 | - SPDX License 202 | - Recap 203 | 204 | ### Deploying to a "Live" network 205 | 206 | - A testnet or mainnet 207 | - [Find a faucet here](https://faucets.chain.link/) 208 | - Connecting Metamask 209 | - Interacting with Deployed Contracts 210 | - The EVM 211 | 212 | # Lesson 2: [Storage Factory](https://github.com/PatrickAlphaC/storage_factory) 213 | 214 | 💻 Code: https://github.com/PatrickAlphaC/storage_factory 215 | 216 | ### Inheritance, Factory Pattern, and Interacting with External Contracts 217 | 218 | - Factory Pattern 219 | - Imports 220 | - Deploy a Contract From a Contract 221 | - Interact With a Deployed Contract 222 | - Recap 223 | 224 | # Lesson 3: [Fund Me](https://github.com/PatrickAlphaC/fund_me) 225 | 226 | 💻 Code: https://github.com/PatrickAlphaC/fund_me 227 | 228 | ### Payable, msg.sender, msg.value, Units of Measure 229 | 230 | - Payable 231 | - [Wei/Gwei/Eth Converter](https://eth-converter.com/) 232 | - msg.sender & msg.value 233 | 234 | ### Chainlink Oracles 235 | 236 | - Decentralized Oracle Network Chainlink 237 | - Blockchains can't make API calls 238 | - Centralized Nodes are Points of Failure 239 | - [data.chain.link](https://data.chain.link/) 240 | - Getting External Data with Chainlink Oracles 241 | - [Chainlink](https://docs.chain.link/) 242 | - [Faucets and Contract Addresses](https://docs.chain.link/docs/link-token-contracts/) 243 | - [Kovan](https://docs.chain.link/docs/link-token-contracts/#kovan) 244 | - [Getting Price Information](https://docs.chain.link/docs/get-the-latest-price/) 245 | 246 | ### Importing from NPM and Advanced Solidity 247 | 248 | - Decimals/Floating Point Numbers in Solidity 249 | - latestRoundData 250 | - Importing from NPM in Remix 251 | - Interfaces 252 | - Introduction to ABIs 253 | - [Getting Price Feed Addresses](https://docs.chain.link/docs/reference-contracts/) 254 | - getPrice 255 | - Tuples 256 | - Unused Tuple Variables 257 | - Matching Units (WEI/GWEI/ETH) 258 | - getConversionRate 259 | - Matching Units (Continued) 260 | - SafeMath & Integer Overflow 261 | - using keyword 262 | - [Libraries](https://docs.soliditylang.org/en/v0.8.6/contracts.html#libraries) 263 | - SafeMath PSA 264 | - Setting a Threshold 265 | - Require 266 | - Revert 267 | - Withdraw Function 268 | - Transfer 269 | - Balance 270 | - this 271 | - Contract Owners 272 | - Constructor 273 | - == 274 | - Modifiers 275 | - Resetting 276 | - for loop 277 | - Array Length 278 | - Forcing a Transaction 279 | - Recap 280 | 281 | # Lesson 4: [Web3.py Simple Storage](https://github.com/PatrickAlphaC/web3_py_simple_storage) 282 | 283 | 💻 Code: https://github.com/PatrickAlphaC/web3_py_simple_storage 284 | 285 | ### Installing VSCode, Python, and Web3 286 | 287 | - [Developer Bootcamp Setup Instructions (metamask, vscode, python, nodejs..)](https://chain.link/bootcamp/brownie-setup-instructions) 288 | - [VSCode](https://code.visualstudio.com/download) 289 | - [VSCode Crash Course](https://www.youtube.com/watch?v=WPqXP_kLzpo) 290 | - Extensions 291 | - Short Cuts: 292 | - [VSCode Shortcuts](https://code.visualstudio.com/docs/getstarted/keybindings) 293 | - [VSCode MacOS Shortcuts](https://code.visualstudio.com/shortcuts/keyboard-shortcuts-macos.pdf) 294 | - [Python](https://www.python.org/downloads/) 295 | - Install Troubleshooting 296 | - Terminal 297 | - Making a directory/Folder 298 | - Opening the folder up with VSCode 299 | - Creating a new file 300 | - Syntax Highlights 301 | - Remember to save! 302 | - Setting linting compile version 303 | - VSCode Solidity Settings 304 | - Formatting & Format on Save 305 | - Solidity Prettier 306 | - [Python Black](https://pypi.org/project/black/) 307 | - [pip](https://pypi.org/project/pip/) 308 | 309 | ### Our First Python Script with Web3.py - Deploying a Contract 310 | 311 | - Reading our solidity file 312 | - Running a Python Script in the Terminal 313 | - [MaxOS Shortcuts](https://code.visualstudio.com/shortcuts/keyboard-shortcuts-macos.pdf) 314 | - [Windows Shortcuts](https://code.visualstudio.com/shortcuts/keyboard-shortcuts-windows.pdf) 315 | - [Linux Shortcuts](https://code.visualstudio.com/shortcuts/keyboard-shortcuts-linux.pdf) 316 | - Compiling in Python 317 | - [py-solc-x](https://pypi.org/project/py-solc-x/) 318 | - compile_standard 319 | - Colorized Brackets 320 | - JSON ABI 321 | - Saving Compiled Code 322 | - Formatting JSON 323 | - Deploying in Python 324 | 1. Get Bytecode 325 | 2. Get ABI 326 | 3. Choose Blockchain to Deploy To 327 | - Local Ganache Chain 328 | - [Ganache UI](https://www.trufflesuite.com/ganache) 329 | - [Ganache Command Line](https://github.com/trufflesuite/ganache-cli) 330 | - [Web3.py](https://web3py.readthedocs.io/en/stable/) 331 | - HTTP / RPC Provider 332 | - Private Keys MUST start with "0x" 333 | - Contract Object 334 | - Building a Transaction 335 | - Account Nonce 336 | - Calling "Constructor" 337 | - Transaction Parameters 338 | - Signing the Transaction 339 | - NEVER put your private key directly in your code 340 | - [Setting Environment Variables (Windows, Linux, MacOS)](https://www.twilio.com/blog/2017/01/how-to-set-environment-variables.html) 341 | - [More on Windows Environment Variables](https://www.youtube.com/watch?v=tqWDiu8a4gc&t=40s) 342 | - Exported Environment Variables Only Last the Duration of the Shell/Terminal 343 | - Private Key PSA 344 | - .env file 345 | - .gitignore 346 | - Loading .env File in Python 347 | - [python-dotenv](https://pypi.org/project/python-dotenv/) 348 | - Viewing our Transaction / Deployment in Ganache 349 | - Waiting for Block Confirmations 350 | 351 | ### Interacting with Our Contract in Python & Web3.py 352 | 353 | - 2 Things you always need 354 | 1. Contract Address 355 | 2. Contract ABI 356 | - Getting address from transaction receipt 357 | - Calling a view function with web3.py 358 | - Call vs Transact 359 | - Updating State with Web3.py 360 | - [ganache-cli](https://github.com/trufflesuite/ganache-cli) 361 | - Installing Ganache 362 | - [Install Nodejs](https://nodejs.org/en/) 363 | - [Install Yarn](https://classic.yarnpkg.com/en/docs/install) 364 | - Working with ganache-cli 365 | - Open a new terminal in the same window 366 | - Deploying to a testnet 367 | - [Infura](https://infura.io/) 368 | - [Alchemy](https://www.alchemy.com/) 369 | - Using Infura RPC URL / HTTP Provider 370 | - [Chain Ids](https://chainlist.org/) 371 | - Wow this seems like a lot of work... Is there a better way? 372 | 373 | # Lesson 5: [Brownie Simple Storage](https://github.com/PatrickAlphaC/brownie_simple_storage) 374 | 375 | 💻 Code: https://github.com/PatrickAlphaC/brownie_simple_storage 376 | 377 | ### Brownie Introduction 378 | 379 | - Some Users: 380 | - https://yearn.finance/ 381 | - https://curve.fi/ 382 | - https://badger.finance/ 383 | 384 | ### Installing Brownie 385 | 386 | - [Installing Brownie](https://eth-brownie.readthedocs.io/en/stable/install.html) 387 | - Install pipx 388 | - pipx install eth-brownie 389 | - Testing Successful Install 390 | 391 | ### Brownie Simple Storage Project 392 | 393 | - A new Brownie project with `brownie init` 394 | - Project Basic Explanation 395 | - Adding `SimpleStorage.sol` to the `contracts` folder 396 | - Compiling with `brownie compile` 397 | - Brownie deploy script 398 | - `def main` is brownie's entry point 399 | - brownie defaults to a `development` `ganache` chain that it creates 400 | - Placing functions outside of the `main` function 401 | - brownie `accounts` 402 | - 3 Ways to Add Accounts 403 | 1. `accounts[0]`: Brownie's "default" ganache accounts 404 | - Only works for local ganache 405 | 2. `accounts.load("...")`: Brownie's encrypted command line (MOST SECURE) 406 | - Run `brownie accounts new ` and enter your private key and a password 407 | 3. `accounts.add(config["wallets"]["from_key"])`: Storing Private Keys as an environment variable, and pulling from our `brownie-config.yaml` 408 | - You'll need to add `dotenv: .env` to your `brownie-config.yaml` and have a `.env` file 409 | - Importing a Contract 410 | - Contract.Deploy 411 | - View Function Call in Brownie 412 | - State-Changing Function Call in Brownie / Contract Interaction 413 | - `transaction.wait(1)` 414 | 415 | ### Testing Basics 416 | 417 | - `test_simple_storage.py` 418 | - Arrange, Act, Assert 419 | - [`assert`](https://docs.pytest.org/en/6.2.x/assert.html) 420 | - `brownie test` 421 | - `test_updating_storage` 422 | - [Pytest / Brownie Test Tips](https://docs.pytest.org/en/6.2.x/) 423 | - Deploy to a Testnet 424 | - `brownie networks list` 425 | - Development vs Ethereum 426 | - Development is temporary 427 | - Ethereum networks persist 428 | - RPC URL / HTTP Provider in Brownie 429 | - The network flag 430 | - `list index out of range` 431 | - `get_account()` 432 | - `networks.show_active()` 433 | - build/deployments 434 | - Accessing previous deployments 435 | - Interacting with contracts deployed in our brownie project 436 | 437 | ### [Brownie console] 438 | 439 | - `brownie console` 440 | 441 | # Lesson 6: [Brownie Fund Me](https://github.com/PatrickAlphaC/brownie_fund_me) 442 | 443 | 💻 Code: https://github.com/PatrickAlphaC/brownie_fund_me 444 | 445 | ### Introduction 446 | 447 | - Setup 448 | 449 | ### Dependencies, Deploying, and Networks 450 | 451 | - Dependencies 452 | - [chainlink-brownie-contracts](https://github.com/smartcontractkit/chainlink-brownie-contracts) 453 | - remappings 454 | - Deploy Script (V1) 455 | - `helpful_scripts.py` 456 | - `__init__.py` 457 | - Deploy to Rinkeby 458 | - Contract Verification (`publish_source`) 459 | - The Manual Way 460 | - "Flattening" 461 | - The Programmatic Way 462 | - Getting an [Etherscan API Key](https://etherscan.io/apis) 463 | - `ETHERSCAN_TOKEN` 464 | - Interacting with Etherscan 465 | - Deploying to Local Chains 466 | - Introduction to Mocking 467 | - Constructor Parameters 468 | - `networks` in our `brownie-config.yaml` 469 | - Copying [Mock Contracts from chainlink-mix](https://github.com/smartcontractkit/chainlink-mix) 470 | - Deploying and using our mock 471 | - Refactoring 472 | - Deploying to a persistent ganache 473 | - brownie attach 474 | - Adding a persistent brownie network 475 | - resetting a network build 476 | 477 | ### Funding and Withdrawing Python Scripts 478 | 479 | - Whoops! Let's fix an issue... 480 | - Fund Script 481 | - Withdraw Script 482 | 483 | ### Testing across networks 484 | 485 | - `test_can_fund_and_withdraw` 486 | - default networks 487 | - pytest `pip install pytest` 488 | - pytest.skip 489 | - brownie exceptions 490 | - `mainnet-fork` 491 | - Custom mainnet fork 492 | - Adding a development brownie network 493 | - `brownie networks add development mainnet-fork-dev cmd=ganache-cli host=http://127.0.0.1 fork='https://infura.io/v3/$WEB3_INFURA_PROJECT_ID' accounts=10 mnemonic=brownie port=8545` 494 | - [Alchemy](https://www.alchemy.com/) 495 | - `brownie test --network mainnet-fork` 496 | - brownie ganache vs local ganache vs mainnet-fork vs testnet... 497 | 498 | ### Git 499 | 500 | - [Installing Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) 501 | - Creating a repository 502 | - [First time with git](https://git-scm.com/book/en/v2/Getting-Started-First-Time-Git-Setup) 503 | - [Adding our project to github](https://docs.github.com/en/github/importing-your-projects-to-github/importing-source-code-to-github/adding-an-existing-project-to-github-using-the-command-line) 504 | - Tweet it out! 505 | 506 | ### Compatibility with Ganache UI 507 | 508 | - `test_only_owner_can_withdraw()` gives below error if the selected network is Ganache UI:: 509 | 510 | ``` 511 | E ValueError: Execution reverted during call: 'VM Exception while processing transaction: revert'. This transaction will likely revert. If you wish to broadcast, include `allow_revert:True` as a transaction parameter. 512 | ``` 513 | 514 | [More information here.](https://ethereum.stackexchange.com/questions/114889/deploying-ganache-local-w-brownie-vm-exception-while-processing-transaction-in) 515 | 516 | # Lesson 7: [SmartContract Lottery](https://github.com/PatrickAlphaC/smartcontract-lottery) 517 | 518 | 💻 Code: https://github.com/PatrickAlphaC/smartcontract-lottery 519 | 520 | [Chainlink VRF v1 docs](https://docs.chain.link/vrf/v1/examples/get-a-random-number) 521 | 522 | ### Introduction 523 | 524 | - Add a `README.md` 525 | - Defining the project 526 | - Is it decentralized? 527 | 528 | ### `Lottery.sol` 529 | 530 | - basic setup 531 | - Main Functions 532 | - address payable[] 533 | - getEntranceFee & Setup 534 | - [Chainlink Price Feed](https://docs.chain.link/docs/get-the-latest-price/) 535 | - brownie-config 536 | - SPDX 537 | - Matching Units of Measure 538 | - Can't just divide 539 | - Test early and often 540 | - Quick Math Sanity Check 541 | - deleting networks 542 | - [Alchemy](https://www.alchemy.com/) again 543 | - Enum 544 | - `startLottery` 545 | - [Openzeppelin](https://openzeppelin.com/contracts/)... Is this the first openzeppelin reference? 546 | - [Openzeppelin Contracts Github](https://github.com/OpenZeppelin/openzeppelin-contracts) 547 | - Randomness 548 | - Pseudorandomness 549 | - `block` keyword 550 | - `block.difficulty` 551 | - `block.timestamp` 552 | - `keccack256` 553 | - [True Randomness with Chainlink VRF](https://docs.chain.link/docs/get-a-random-number/) 554 | - [VRFConsumerBase.sol](https://github.com/smartcontractkit/chainlink/blob/develop/contracts/src/v0.8/vrf/VRFConsumerBase.sol) 555 | - Chainlink VRF Remix Version 556 | - Inheriting Constructors 557 | - Oracle Gas & Transaction Gas 558 | - [Why didn't we pay gas on the price feeds?](https://ethereum.stackexchange.com/questions/87473/is-chainlinks-price-reference-data-free-to-consume) 559 | - Chainlink Node Fees 560 | - [Request And Receive Introduction](https://docs.chain.link/docs/architecture-request-model/) 561 | - [Kovan Faucets](https://docs.chain.link/docs/link-token-contracts/#kovan) 562 | - Funding Chainlink Contracts 563 | - [Request And Receive Explanation](https://docs.chain.link/docs/architecture-request-model/) 564 | - A Clarification 565 | - `endLottery` 566 | - `returns (type variableName)` 567 | - `fulfillRandomness` 568 | - `override` 569 | - Modulo Operation (Mod Operation %) 570 | - Paying the lottery winner 571 | - Resetting the lottery 572 | 573 | ### Testing Lottery.sol 574 | 575 | - `deploy_lottery.py` 576 | - `get_account()` refactored 577 | - `get_contract` 578 | - `contract_to_mock` 579 | - `Contract.from_abi` 580 | - Adding the parameters to deploying to lottery 581 | - `vrfCoordinatorMock` and adding mocks 582 | - `LinkToken` and Mocks 583 | - Successful Ganache Deployment! 584 | - Python Lottery Scripts/Functions 585 | - `start_lottery` 586 | - Brownie tip: Remember to `tx.wait(1)` your last transaction 587 | - `enter_lottery` 588 | - `end_lottery` 589 | - Funding with LINK 590 | - brownie interfaces 591 | - Waiting for callback 592 | - Integration Tests & Unit Tests 593 | - Test all lines of code 594 | - `test_get_entrance_fee` 595 | - `pytest.skip` (again) 596 | - `test_cant_enter_unless_started` 597 | - `test_can_start_and_enter_lottery` 598 | - `test_can_pick_winner_correctly` 599 | - Events and Logs 600 | - `callBackWithRandomness` 601 | 602 | ### Lottery.sol Testnet Deployment 603 | 604 | - `topics` 605 | - [conftest.py](https://stackoverflow.com/questions/34466027/in-pytest-what-is-the-use-of-conftest-py-files) 606 | 607 | # Lesson 8: [Chainlink Mix](https://github.com/smartcontractkit/chainlink-mix) 608 | 609 | 💻 Code: https://github.com/smartcontractkit/chainlink-mix 610 | 611 | ## [Brownie Mixes](https://github.com/brownie-mix) 612 | 613 | # Lesson 9: [ERC20s, EIPs, and Token Standards](https://github.com/PatrickAlphaC/erc20-brownie-py) 614 | 615 | 💻 Code: https://github.com/PatrickAlphaC/erc20-brownie-py 616 | 617 | - [ERC20/EIP20 Standard](https://eips.ethereum.org/EIPS/eip-20) 618 | - What is an ERC20? 619 | - Creating an ERC20 620 | - [OpenZeppelin ERC20](https://docs.openzeppelin.com/contracts/2.x/api/token/erc20) 621 | - [Solidity 0.8](https://docs.soliditylang.org/en/breaking/080-breaking-changes.html) 622 | - I Challenge you to code this yourself! 623 | - `deploy_token.py` 624 | - Copy paste `helpful_scripts.py` 625 | - Viewing our token in metamask 626 | - Adding to an exchange 627 | 628 | # Lesson 10: [Defi & Aave](https://github.com/PatrickAlphaC/aave_brownie_py_freecode) 629 | 630 | \*NOTE: This repo is now archived as kovan is no longer supported. You can still follow along with the learning, but know the code may not work the same on a different testnet. 631 | 632 | 💻 Code: https://github.com/PatrickAlphaC/aave_brownie_py_freecode 633 | 634 | ### Defi Intro 635 | 636 | - [Defipulse](https://defipulse.com/) 637 | - [Defillama](https://defillama.com/) 638 | - [Aave Testnet Site](https://staging.aave.com/) 639 | - [Paraswap](https://paraswap.io/) 640 | - Decentralized Exchange 641 | 642 | ### Aave UI 643 | 644 | - [Kovan ETH](https://docs.chain.link/docs/link-token-contracts/#kovan) 645 | - What is Aave? 646 | - Borrowing and Lending 647 | - Connecting to Aave 648 | - Depositing Tokens / Lending 649 | - Checking your transaction is correct 650 | - WETH Gateway 651 | - Interest Bearing Token (aToken) 652 | - Collateral 653 | - [DAI](https://makerdao.com/en/) 654 | - [Stablecoin](https://www.investopedia.com/terms/s/stablecoin.asp) 655 | - [Wrapped Bitcoin (wBTC)](https://www.gemini.com/cryptopedia/wrapped-bitcoin-what-can-you-do) 656 | - [Why borrow tokens?](https://docs.aave.com/faq/borrowing) 657 | - [Blockchain Fintech Tutorial](https://blog.chain.link/blockchain-fintech-defi-tutorial-lending-borrowing-python/) 658 | - DISCLAIMER ABOUT BORROWING 659 | - Borrowing Tokens 660 | - [Liquidations](https://docs.aave.com/faq/liquidations) 661 | - Your health factor must be above 1 662 | - [Solvent](https://www.investopedia.com/terms/s/solvency.asp) 663 | - [Stable vs Variable Interest Rate](https://docs.aave.com/faq/borrowing#what-is-the-difference-between-stable-and-variable-rate) 664 | - Repaying our borrows/loans 665 | - Reward token / governance token 666 | - Governance 667 | 668 | ### [Programmatic Interactions with Aave](https://github.com/PatrickAlphaC/aave_brownie_py_freecode) 669 | 670 | - Quant Defi Engineer 671 | - [Aave Documentation](https://docs.aave.com/developers/) 672 | - Setup 673 | - Converting ETH -> WETH 674 | - `get_weth.py` 675 | - [IWETH](https://github.com/PatrickAlphaC/aave_brownie_py/blob/main/interfaces/WethInterface.sol) 676 | - [Kovan WETH Token Address: 0xd0a1e359811322d97991e03f863a0c30c2cf029c](https://kovan.etherscan.io/token/0xd0a1e359811322d97991e03f863a0c30c2cf029c) 677 | - [Mainnet WETH Token Address: 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2](https://etherscan.io/token/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2) 678 | - Converting WETH -> ETH with `withdraw` 679 | - `aave_borrow.py` 680 | - [LendingPool](https://docs.aave.com/developers/the-core-protocol/lendingpool) 681 | - [LendingPoolAddressProvider](https://docs.aave.com/developers/the-core-protocol/addresses-provider) 682 | - [LendingPool and LendingPoolAddressProvider Addresses](https://docs.aave.com/developers/deployed-contracts/deployed-contracts) 683 | - Fixing import dependencies 684 | - [Aave Github](https://github.com/aave/protocol-v2) 685 | - [ERC20 Approve Function](https://medium.com/ethex-market/erc20-approve-allow-explained-88d6de921ce9) 686 | - [IERC20 from Patrick's repo](https://github.com/PatrickAlphaC/aave_brownie_py/blob/main/interfaces/IERC20.sol) 687 | - `deposit` 688 | - [getUserAccountData](https://docs.aave.com/developers/the-core-protocol/lendingpool#getuseraccountdata) 689 | - Liquidation Threshold 690 | - [Risk Parameters](https://docs.aave.com/risk/asset-risk/risk-parameters) 691 | - Borrowing DAI 692 | - Getting DAI Conversion Rate 693 | - [Chainlink Price Feeds](https://docs.chain.link/docs/reference-contracts/) 694 | - [AggregatorV3Interface](https://github.com/PatrickAlphaC/aave_brownie_py/blob/main/interfaces/AggregatorV3Interface.sol) 695 | - [borrow](https://docs.aave.com/developers/the-core-protocol/lendingpool#borrow) 696 | - [Mainnet DAI Address: 0x6b175474e89094c44da98b954eedeac495271d0f](https://etherscan.io/token/0x6b175474e89094c44da98b954eedeac495271d0f) 697 | - [Aave Testnet Token Addresses](https://aave.github.io/aave-addresses/kovan.json) 698 | - Repaying 699 | - Kovan Run 700 | - Viewing the transactions 701 | 702 | ### Testing 703 | 704 | # Lesson 11: [NFTs](https://github.com/PatrickAlphaC/nft-demo) 705 | 706 | 💻 Code: https://github.com/PatrickAlphaC/nft-demo 707 | 708 | ### Non-Technical Explainer 709 | 710 | - [End-to-end article](https://www.freecodecamp.org/news/how-to-make-an-nft-and-render-on-opensea-marketplace/) 711 | - What is an NFT? 712 | - [ERC721](https://eips.ethereum.org/EIPS/eip-721) 713 | - Token URI 714 | - [Token Metadata Example](https://docs.opensea.io/docs/2-adding-metadata) 715 | - [IPFS](https://ipfs.io/) 716 | 717 | ### Simple NFT 718 | 719 | - [brownie mix](https://github.com/PatrickAlphaC/nft-mix) 720 | - Initial Setup 721 | - `SimpleCollectible.sol` 722 | - [OpenZeppelin ERC721](https://docs.openzeppelin.com/contracts/3.x/) 723 | - [Pug Image](https://github.com/PatrickAlphaC/nft-mix/blob/main/img/pug.png) 724 | - NFT Constructor 725 | - NFT is a type of factory pattern 726 | - `createCollectible` 727 | - `_safeMint` 728 | - TokenURI & Metadata 729 | - Opensea listing example 730 | - Is this decentralized? 731 | - Ethereum Size and dStorage 732 | - [Ethereum Size](https://ycharts.com/indicators/ethereum_chain_full_sync_data_size) 733 | - [dStorage Solutions](https://ethereum.org/en/developers/docs/storage/) 734 | - [IPFS](https://www.ipfs.com/) 735 | - You need to have your NFT attributes both on-chain and inside your tokenURI metadata 736 | - `deploy_and_create.py` 737 | - [TokenURI used for the demo: https://ipfs.io/ipfs/Qmd9MCGtdVz2miNumBHDbvj8bigSgTwnr4SbyH6DNnpWdt?filename=0-PUG.json](https://ipfs.io/ipfs/Qmd9MCGtdVz2miNumBHDbvj8bigSgTwnr4SbyH6DNnpWdt?filename=0-PUG.json) 738 | - [IPFS Companion](https://chrome.google.com/webstore/detail/ipfs-companion/nibjojkomfdiaoajekhjakgkdhaomnch?hl=en) 739 | - Rinkeby Deployment 740 | - [Opensea Example](https://testnets.opensea.io/assets/0x8acb7ca932892eb83e4411b59309d44dddbc4cdf/0) 741 | 742 | ### SimpleCollectible Testing 743 | 744 | - What else with NFTs? 745 | 746 | ### Advanced NFT 747 | 748 | - `AdvancedCollectible.sol` 749 | - [Dungeons and Dragons Example](https://github.com/PatrickAlphaC/dungeons-and-dragons-nft) 750 | - Double Inherited Constructors 751 | - `createCollectible` (Advanced) 752 | - `tokenIdToBreed` 753 | - Working with in-flight Chainlink VRF requests 754 | - Download the NFT images from the [nft-mix](https://github.com/PatrickAlphaC/nft-mix) 755 | - `setTokenURI` 756 | - `_isApprovedOrOwner` 757 | - Emit events when you update mappings 758 | - [`indexed` event keyword](https://ethereum.stackexchange.com/questions/8658/what-does-the-indexed-keyword-do/8659) 759 | 760 | ### Advanced deploy_and_create 761 | 762 | - Move `OPENSEA_URL` to `helpful_scripts` 763 | - Deploying AdvancedCollectible 764 | - Opensea testnet is only compatible with Rinkeby 765 | - [Rinkeby Chainlink VRF Contract Addresses](https://docs.chain.link/docs/vrf-contracts/#rinkeby) 766 | - Speeding through adding functions from previous projects 767 | - Deploy to Rinkeby 768 | - `create_collectible.py` 769 | - A quick unit test 770 | - A quick integration test 771 | 772 | ### Creating Metadata & IPFS 773 | 774 | - `create_metadata.py` 775 | - `get_breed` 776 | - Metadata Folder 777 | - `metadata_template` 778 | - NFT Metadata Attributes 779 | - Checking if Metadata file already exists 780 | - Uploading to IPFS 781 | - `upload_to_ipfs` 782 | - [Download IPFS Command Line](https://docs.ipfs.io/install/command-line/) 783 | - [Download IPFS Desktop](https://docs.ipfs.io/install/ipfs-desktop/) 784 | - [HTTP IPFS Docs](https://docs.ipfs.io/reference/http/api/) 785 | - `ipfs daemon` 786 | - [Pinata](https://app.pinata.cloud/) 787 | - [Pinata Docs](https://docs.pinata.cloud/) 788 | - Refactoring to not re-upload to IPFS 789 | - Setting the TokenURI 790 | - End-To-End Manual Testnet Test 791 | - Viewing on Opensea 792 | 793 | # Lesson 12: [Upgrades](https://github.com/PatrickAlphaC/upgrades-mix) 794 | 795 | 💻 Code: https://github.com/PatrickAlphaC/upgrades-mix 796 | 797 | ### Introduction to upgrading smart contracts 798 | 799 | - [Original Video](https://www.youtube.com/watch?v=bdXJmWajZRY) 800 | - Smart Contracts can be upgraded! 801 | - Does this mean they are not immutable? 802 | - [Trail of Bits on Upgradeable Smart Contracts](https://blog.trailofbits.com/2018/09/05/contract-upgrade-anti-patterns/) 803 | - The "Not Really Upgrading" / Parameterization Method 804 | - The Social Yeet / Migration Method 805 | - [Contract Migration](https://blog.trailofbits.com/2018/10/29/how-contract-migration-works/) 806 | - Proxies 807 | - DelegateCall 808 | - Terminology: 809 | - Implementation Contract 810 | - Proxy Contract 811 | - User 812 | - Admin 813 | - Gotchas: 814 | - Storage Clashes 815 | - Function Selector 816 | - Function Selector Clashes 817 | - Proxy Patterns: 818 | - [Transparent Proxy Pattern](https://blog.openzeppelin.com/the-transparent-proxy-pattern/) 819 | - [Universal Upgrade Proxy Standard](https://eips.ethereum.org/EIPS/eip-1822) 820 | - [Diamond/Multi-Facet Proxy](https://eips.ethereum.org/EIPS/eip-2535) 821 | 822 | ### Upgrades-mix and code 823 | 824 | - Setup 825 | - `Box.sol` 826 | - `BoxV2.sol` 827 | - Getting the proxy contracts 828 | - [Openzeppelin Proxy Github](https://github.com/OpenZeppelin/openzeppelin-contracts/tree/master/contracts/proxy/transparent) 829 | - `01_deploy_box.py` 830 | - Hooking up a proxy to our implementation contract 831 | - (Optional) [Creating a Gnosis Safe](https://help.gnosis-safe.io/en/articles/3876461-create-a-safe) 832 | - Initializers 833 | - Encoding Initializer Function 834 | - Assigning ABI to a proxy 835 | - Running the script 836 | - Upgrade Python Function 837 | 838 | ### Testing Upgrades 839 | 840 | - Testing our proxy 841 | - Testing our upgrades 842 | 843 | ### Upgrades on a testnet 844 | 845 | # Bonus Lesson 13: [Full Stack Defi](https://github.com/PatrickAlphaC/defi-stake-yield-brownie-freecode) 846 | 847 | _Note: This section is archived as kovan is now deprecated. If you're looking to learn more Full-stack, check out the full stack portions of the hardhat/javascript video._ 848 | 849 | _Link to hardhat/javascript video with more full-stack examples: https://github.com/smartcontractkit/full-blockchain-solidity-course-js_ 850 | 851 | 💻 Code: https://github.com/PatrickAlphaC/defi-stake-yield-brownie-freecode 852 | 853 | - [FreeCodeCamp React](https://www.freecodecamp.org/news/tag/react/) 854 | - What are we building? 855 | - Setup 856 | - `DappToken.sol` 857 | - `TokenFarm.sol` 858 | - `tokenIsAllowed` 859 | - `addAllowedTokens` 860 | - mapping of a mapping 861 | - `stakeTokens` 862 | - `issueTokens` 863 | - `getUserTotalValue` 864 | - `getUserSingleTokenValue` 865 | - `getTokenValue` 866 | - `setPriceFeedContract` 867 | - `unStakeTokens` 868 | - Can this be reentrancy attacked? 869 | 870 | ### Defi Stake Yield Brownie Scripts & Tests 871 | 872 | - `deploy.py` 873 | - Deploying DappToken 874 | - Deploying TokenFarm 875 | - Adding allowed tokens 876 | - [ERC20 Kovan Faucet](https://erc20faucet.com/) 877 | - If the link above does not work, you can get another ERC20 token using this faucet: [Weenus ERC20 Faucet](https://github.com/bokkypoobah/WeenusTokenFaucet) 878 | - Mocking our ERC20s 879 | 880 | ### Testing our Defi Stake Yield Brownie Dapp 881 | 882 | - `test_set_price_feed_contract` 883 | - `test_stake_tokens` 884 | - Fixtures 885 | - `test_issue_tokens` 886 | - Now you try on tests! 887 | 888 | ### Front End / Full Stack 889 | 890 | - Front End Introduction 891 | - Typescript 892 | - [React](https://reactjs.org/) 893 | - [useDapp](https://usedapp.readthedocs.io/en/latest/) 894 | - [npx](https://www.npmjs.com/package/npx) 895 | - [yarn](https://classic.yarnpkg.com/en/docs/install/) 896 | - `create-react-app` 897 | - Layout 898 | - [Testing Front End](https://www.freecodecamp.org/news/testing-react-hooks/) 899 | - yarn && yarn start 900 | - Connecting our wallets 901 | - Install useDapp 902 | - Header Component 903 | - Connect Button 904 | - [Material-UI](https://material-ui.com/) 905 | - Making our button nicer 906 | - `Main.tsx` 907 | - Sending `brownie-config` & `build` folder to our UI 908 | - Helper Config 909 | - TypeScript error suppression 910 | - Getting addresses 911 | - [Ethers](https://docs.ethers.io/v5/) 912 | - Only support kovan 913 | - `YourWallet` 914 | - `supportedTokens` 915 | - State Hooks 916 | - Showing tokens 917 | - `WalletBalance` 918 | - [`ethersproject/units`](https://www.npmjs.com/package/@ethersproject/units) 919 | - `BalanceMsg` 920 | - Stake Form 921 | - Calling `approve` 922 | - `useContractFunction` 923 | - `useEffect` 924 | - Notifications 925 | - Make it pretty 926 | - Alerts 927 | 928 | Shoutout to [Matt](https://twitter.com/mdurkin92) for the help on the front end! 929 | 930 | # Closing and Summary 931 | 932 | ## Security 933 | 934 | - [Best Practices](https://consensys.github.io/smart-contract-best-practices/) 935 | - [Attacks](https://consensys.github.io/smart-contract-best-practices/attacks/) 936 | - [Oracle Attacks](https://hackernoon.com/how-dollar100m-got-stolen-from-defi-in-2021-price-oracle-manipulation-and-flash-loan-attacks-explained-3n6q33r1) 937 | - [Re-entrancy Attacks](https://quantstamp.com/blog/what-is-a-re-entrancy-attack) 938 | - [Damn Vulnerable Defi](https://www.damnvulnerabledefi.xyz/) 939 | - [Ethernaut](https://ethernaut.openzeppelin.com/) 940 | - Some Auditors 941 | - [OpenZeppelin](https://openzeppelin.com/) 942 | - [SigmaPrime](https://sigmaprime.io/) 943 | - [Trail of Bits](https://www.trailofbits.com/) 944 | 945 | ## Where do I go now? 946 | 947 | ### Learning More 948 | 949 | - [CryptoZombies](https://cryptozombies.io/) 950 | - [Dapp University](https://www.youtube.com/channel/UCY0xL8V6NzzFcwzHCgB8orQ) 951 | - [ChainShot](https://www.chainshot.com/courses) 952 | - [Ivan on Tech](https://academy.ivanontech.com/) 953 | - [Eat the Blocks](https://www.youtube.com/channel/UCZM8XQjNOyG2ElPpEUtNasA) 954 | - [Patrick Collins](https://www.youtube.com/channel/UCn-3f8tw_E1jZvhuHatROwA) 955 | - [Austin Griffith](https://www.youtube.com/channel/UC_HI2i2peo1A-STdG22GFsA) 956 | - [Nader Dabit](https://www.youtube.com/user/boyindasouth) 957 | - [Ethereum.org](https://ethereum.org/en/) 958 | 959 | ### Community 960 | 961 | - Twitter 962 | - [Brownie Discord](https://discord.gg/9zk7snTfWe) 963 | - [Ethereum Discord](https://ethereum.org/en/) 964 | - [Chainlink Discord](https://discord.gg/2YHSAey) 965 | - [Reddit ethdev](https://www.reddit.com/r/ethdev/) 966 | 967 | ### Hackathons 968 | 969 | - [CL Hackathon](https://chain.link/hackathon) 970 | - [ETH Global](https://ethglobal.co/) 971 | - [ETH India](https://twitter.com/ETHIndiaco) 972 | 973 | Be sure to check out project grant programs! 974 | 975 | ### Vyper 976 | 977 | [From solidity course to vyper](https://github.com/chalex-eth/From-solidity-course-to-vyper-py) 978 | 979 | And make today an amazing day! 980 | -------------------------------------------------------------------------------- /chronological-issues-from-video.md: -------------------------------------------------------------------------------- 1 | # About 2 | 3 | This file will list issues/updates by timestamp. If you have an issue that you don't see here, please make an issue on this repo. 4 | 5 | ## Faucet Issues 6 | - If you have any issues with a faucet, please try another testnet. You'll have to update some contract addresses based on the testnet you're working on. You can find the [most up to date faucets here.](https://docs.chain.link/docs/link-token-contracts/) 7 | - If the Rinkeby faucet isn't working, you can use a kovan faucet, just be sure to use Kovan Etherscan and Kovan in your Metamask! 8 | - *Big Update*: [New Rinkeby Faucet Located Here](https://faucets.chain.link/rinkeby) 9 | - You can find [Backup Faucets here](https://docs.chain.link/docs/link-token-contracts/#rinkeby) 10 | 11 | ## Linting issues 12 | 13 | If you see something along the lines of: 14 | 15 | ``` 16 | ParserError: Source "OpenZeppelin/openzeppelin-contracts@3.4.0/contracts/access/Ownable.sol" not found: File not found. 17 | import "@openzeppelin/contracts/access/Ownable.sol"; 18 | ``` 19 | 20 | In your vscode, these and be safely ignored. However you can also add to your settings to ignore these. 21 | 1. Create a `.vscode` folder at the root of your project. 22 | 2. Create a file called `settings.json` 23 | 3. Add the following code: 24 | 25 | ```json 26 | { 27 | "solidity.remappings": [ 28 | "@chainlink/=/Users/patrick/.brownie/packages/smartcontractkit/chainlink-brownie-contracts@0.2.2", 29 | "@openzeppelin/=/Users/patrick/.brownie/packages/OpenZeppelin/openzeppelin-contracts@4.3.2" 30 | ] 31 | } 32 | ``` 33 | 34 | 35 | Or whatever version your `@chainlink` and `@openzeppelin` contracts need. For example: 36 | Screen Shot 2021-10-05 at 6 01 45 PM 37 | 38 | **Note:** remember this is an example, you must provide the actual location on which your `.brownie` folder is located. For more info on on this please refer [here](https://n4n0b1t3.medium.com/how-to-make-vsc-solidity-lint-recognize-your-chainlink-and-openzeppelin-libraries-73775129261c). 39 | 40 | ## Integration Testing Issues 41 | - In some integration tests, we do something like `time.sleep(60)`. Sometimes, you'll have to do much longer, we've had reports go up to `time.sleep(300)`. So, if you want to try that, go get a coffee break while your integration test runs! 42 | 43 | ## Python related issues 44 | - In some environments Web3.py may not work due to the **Cytools** error, which means your computer lacks some `C` language libraries in order to execute. 45 | 46 | [Here](https://medium.com/@cromewar/the-mighty-cytools-error-at-web3-smart-contract-development-with-brownie-63335d50f230) you can find a detailed guide about how to solve the problem. 47 | 48 | 49 | ## Lesson 3: 50 | - [2:37:05](https://youtu.be/M576WGiDBdQ?t=9425) Kovan vs Rinkeby 51 | - Our `FundMe.sol` needs to be deployed to the *rinkeby* chain to work, but if you go to try the price feeds from the Chainlink docs using the remix link, that one has the *kovan* price feeds in it, so needs to be deployed to kovan. 52 | - If you want to test the price feeds from the video using the Chainlink docs remix link, you'll need to follow the steps to [get kovan ETH](https://docs.chain.link/docs/link-token-contracts/#kovan). 53 | 54 | ## Lesson 4: 55 | - [3:43:52](https://youtu.be/M576WGiDBdQ?t=13432) Installing solcx version 0.6.0 56 | - In the video, we forgot to do 2 things in order to compile our solidity code: 57 | - Import `install_solc`, so we need to change this line: 58 | - `from solcx import compile_standard` 59 | - To this line: 60 | - `from solcx import compile_standard, install_solc` 61 | - And then, we need to add a line right before we run the `compile_standard` code: 62 | - `install_solc("0.6.0")` 63 | - [4:00:00](https://www.youtube.com/watch?v=M576WGiDBdQ&t=14423s) Issue with ganache and web3.py 64 | - As of `5.25.0` of [web3.py](https://github.com/ethereum/web3.py/tags), we now need to add gasPrice to our transactions with a local ganache chain. 65 | - Adding `"gasPrice": w3.eth.gas_price,` should fix your issue in the transactions. 66 | 67 | Full Example: 68 | ```python 69 | transaction = SimpleStorage.constructor().buildTransaction( 70 | { 71 | "chainId": chain_id, 72 | "gasPrice": w3.eth.gas_price, 73 | "from": my_address, 74 | "nonce": nonce, 75 | } 76 | ) 77 | ``` 78 | - [3:56:20](https://youtu.be/M576WGiDBdQ?t=13372) Colorized Brackets. 79 | * The referenced extension has been deprecated due to VS code adding native functionality. To enable the new setting search for `bracket` and check the checkbox below: 80 | `Editor > Bracket Pair Colorization:` **Enabled** 81 | 82 | ![image](https://user-images.githubusercontent.com/2119741/147293025-4dec848b-747b-4da7-9009-3f9174198b54.png) 83 | 84 | - [3:55:09](https://youtu.be/M576WGiDBdQ?t=14109) Confusing network ID and chain ID 85 | - In the video the network ID is copied instead of the chain id. 86 | Whenever the terms Network ID and Chain ID are used without distinction, it should be noted that both IDs can be different for a server such as Ganache. As you can see here, Ganache can be using different IDs. 87 | 88 | ``` 89 | >>> from web3 import Web3 90 | >>> w3 = Web3(Web3.HTTPProvider("http://127.0.0.1:8545")) 91 | >>> w3.eth.chain_id 92 | 1337 93 | >>> w3.net.version 94 | '5777' 95 | >>> 96 | ``` 97 | 98 | 99 | ## Lesson 6 100 | - [5:44:00](https://youtu.be/M576WGiDBdQ?t=20640) 101 | - In the video, the getEntranceFee() function returns `(minimumUSD * precision) / price` 102 | - Integer divisions are rounded towards 0 in Solidity, so this function will almost always return an amount worth slightly less than our minimum price. It makes it unusable with the fund() function because the transaction will revert everytime. 103 | - To fix it we can round up the result 104 | - getEntranceFee() function should return `((minimumUSD * precision) / price) + 1` 105 | - This fix has been [merged](https://github.com/PatrickAlphaC/brownie_fund_me/pull/32/files) and you can read more explanation about the issue [here](https://github.com/PatrickAlphaC/brownie_fund_me/issues/10#issuecomment-1041602057) 106 | 107 | ## Lesson 7 108 | **In the video, we use Chainlink VRF v1 and the documentation has been updated to V2. You can view the [V1 documentation here](https://docs.chain.link/docs/get-a-random-number/v1/)** 109 | 110 | - Looking for the VRF Coordinator contract by yourself will probably bring you to the v2 address of it. Make sure to use the v1 VRF Coordinator contract in the brownie-config.yaml file, because it won't work with the v2 contract. The repository has already the correct contract address. 111 | 112 | - [8:06:54ish](https://youtu.be/M576WGiDBdQ?t=29214) 113 | - In the video, we use events exclusivly to test our contracts, however, we could have also used `tx.return_value` to get the return value of a function. 114 | - However, it's still best practice to learn how to use events, especially when updating mappings! 115 | 116 | - [8:10:20ish](https://youtu.be/M576WGiDBdQ?t=29423) 117 | - In the video, `starting_balance_of_account` and `balance_of_lottery` are retrieved AFTER `lottery.endLottery()` 118 | - For correctness those 2 statements should be run BEFORE `lottery.endLottery()` 119 | - The tests pass because `starting_balance_of_account == account.balance()` (L81) and `lottery.balance()` is already 0 120 | - This is a subtle bug in the test, which also showcases a problem with tests - we have no one to test the tests ;) Still, having tests is better than not having them, just don't put all your assurances into them 121 | 122 | 123 | ## Lesson 10 124 | - The Aave testnet site has moved from `https://testnet.aave.com` to `https://staging.aave.com` and some of the functionality is lost :( 125 | - For our `repay_all` function, we originally had: 126 | ```python 127 | repay_all(AMOUNT, lending_pool, account) 128 | ``` 129 | 130 | But it should be: 131 | 132 | ``` 133 | repay_all(Web3.toWei(amount_dai_to_borrow, "ether"), lending_pool, account) 134 | ``` 135 | We want to pay back the DAI not the ETH! Just remember, you'll still have a vveerrrryyyy small amount of DAI borrowed because of interest. If you see something with an `E` in it, you did it right! 136 | -------------------------------------------------------------------------------- /img/youtube_thumbnail.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smartcontractkit/full-blockchain-solidity-course-py/626a33ad7e3e22c64d79c9ad54ec236e334f8c8a/img/youtube_thumbnail.jpeg --------------------------------------------------------------------------------