Coder Social home page Coder Social logo

smartcontractkit / full-blockchain-solidity-course-js Goto Github PK

View Code? Open in Web Editor NEW
11.5K 225.0 2.8K 4.1 MB

Learn Blockchain, Solidity, and Full Stack Web3 Development with Javascript

blockchain chainlink ethereum javascript moralis smart-contracts solidity thegraphprotocol typescript alchemy

full-blockchain-solidity-course-js's Introduction

Web3, Full Stack Solidity, Smart Contract & Blockchain - Beginner to Expert ULTIMATE Course | Javascript Edition


Solidity, Blockchain, and Smart Contract Course – Beginner to Expert Javascript Tutorial


Welcome to the repository for the Ultimate Web3, Full Stack Solidity, and Smart Contract - Beginner to Expert Full Course | Javascript Edition FreeCodeCamp Course!

All code references have both a javascript and a typescript edition.

Recommended Testnet: Sepolia

We have updated the repos to work with Sepolia due to Rinkeby and Kovan being sunset, and Goerli being a disaster. Let us know if any of the changes break stuff!

Main Faucet: https://faucets.chain.link Backup Faucet: https://sepoliafaucet.com/

⚠️ All code associated with this course is for demo purposes only. They have not been audited and should not be considered production ready. Please use at your own risk.

Resources For This Course

Questions

Table of Contents

Resources
  1. Testnet Faucets
  2. Resources For This Course
  3. Table of Contents
Lesson 0: The Edge of the Rabbit Hole
  1. Welcome to the course!
  2. Best Practices
Lesson 1: Blockchain Basics
  1. What is a Blockchain? What does a blockchain do?
  2. The Purpose Of Smart Contracts
  3. Other Blockchain Benefits
  4. What have Smart Contracts done so far?
  5. Making Your First Transaction
  6. Gas I: Introduction to Gas
  7. How Do Blockchains Work?
  8. Signing Transactions
  9. Gas II
  10. High-Level Blockchain Fundamentals
Lesson 2: Welcome to Remix! Simple Storage
  1. Introduction
  2. Setting Up Your First Contract
  3. Basic Solidity: Types
  4. Basic Solidity: Functions
  5. Basic Solidity: Arrays & Structs
  6. Basic Solidity: Compiler Errors and Warnings
  7. Memory, Storage, Calldata (Intro)
  8. Mappings
  9. Deploying your First Contract
  10. The EVM & A Recap of Lesson 2
Lesson 3: Remix Storage Factory
  1. Introduction
  2. Basic Solidity: Importing Contracts into other Contracts
  3. Basic Solidity: Interacting with other Contracts
  4. Basic Solidity: Inheritance & Overrides
  5. Lesson 3 Recap
Lesson 4: Remix Fund Me
  1. Introduction
  2. Sending ETH Through a Function & Reverts
  3. Chainlink & Oracles
  4. Review of Sending ETH and working with Chainlink
  5. Interfaces & Price Feeds
  6. Importing from GitHub & NPM
  7. Floating Point Math in Solidity
  8. Basic Solidity: Arrays & Structs II
  9. Review of Interfacs, Importing from GitHub, & Math in Solidity
  10. Libraries
  11. SafeMath, Overflow Checking, and the "unchecked" keywork
  12. Basic Solidity: For Loop
  13. Basic Solidity: Resetting an Array
  14. Sending ETH from a Contract
  15. Basic Solidity: Constructor
  16. Basic Solidity: Modifiers
  17. Testnet Demo
  18. Advanced Solidity
Lesson 5: Ethers.js Simple Storage
  1. Effective Debugging Strategies & Getting Help
  2. Installation & Setup
  3. Local Development Introduction
  4. Tiny Javascript Refresher
  5. Asynchronous Programming in Javascript
  6. Compiling our Solidity
  7. Ganache & Networks
  8. Introduction to Ethers.js
  9. Adding Transaction Overrides
  10. Transaction Receipts
  11. Sending a "raw" Transaction in Ethersjs
  12. Interacting with Contracts in Ethersjs
  13. Environment Variables
  14. Better Private Key Management
  15. Optional Prettier Formatting
  16. Deploying to a Testnet or a Mainnet
  17. Verifying on Block Explorers from the UI
  18. Alchemy Dashboard & The Mempool
  19. Lesson 5 Recap
Lesson 6: Hardhat Simple Storage
  1. Introduction
  2. Hardhat Setup
  3. Hardhat Setup Continued
  4. Deploying SimpleStorage from Hardhat
  5. Networks in Hardhat
  6. Programatic Verification
  7. Interacting with Contracts in Hardhat
  8. Artifacts Troubleshooting
  9. Custom Hardhat Tasks
  10. Hardhat Localhost Node
  11. The Hardhat Console
  12. Hardhat Tests
  13. Hardhat Gas Reporter
  14. Solidity Coverage
  15. Hardhat Waffle
  16. Lesson 6 Recap
Lesson 7: Hardhat Fund Me
  1. Introduction
  2. Hardhat Setup - Fund Me
  3. Linting
  4. Hardhat Setup - Fund Me - Continued
  5. Importing from NPM
  6. Hardhat Deploy
  7. Mocking
  8. Utils Folder
  9. Testnet Demo - Hardhat Fund Me
  10. Solidity Style Guide
  11. Testing Fund Me
  12. Breakpoints & Debugging
  13. Gas III:
  14. console.log & Debugging
  15. Testing Fund Me II
  16. Storage in Solidity
  17. Gas Optimizations using Storage Knowledge
  18. Solidity Chainlink Style Guide
  19. Storage Review
  20. Staging Tests
  21. Running Scripts on a Local Node
  22. Adding Scripts to your package.json
  23. Pushing to GitHub
  24. 🐸🐦 Tweet Me (add your repo in)!
Lesson 8: HTML / Javascript Fund Me (Full Stack / Front End)
  1. Introduction
  2. How Websites work with Web3 Wallets
  3. HTML Setup
  4. Connecting HTML to Metamask
  5. Javascript in it's own file
  6. ES6 vs Nodejs
  7. Sending a transaction from a Website
  8. Resetting an Account in Metamask
  9. Listening for Events and Completed Transactions
  10. Input Forms
  11. Reading from the Blockchain
  12. Withdraw Function
  13. Lesson 8 Recap
Lesson 9: Hardhat Smart Contract Lottery
  1. Introduction
  2. Hardhat Setup - Smart Contract Lottery
  3. Raffle.sol Setup
  4. Introduction to Events
  5. Events in Raffle.sol
  6. Introduction to Chainlink VRF
  7. Implementing Chainlink VRF - Introduction
  8. Implementing Chainlink VRF - The Request
  9. Implementing Chainlink VRF - The FulFill
  10. Introduction to Chainlink Keepers
  11. Implementing Chainlink Keepers - checkUpkeep
  12. Implementing Chainlink Keepers - checkUpkeep continued
  13. Implementing Chainlink Keepers - performUpkeep
  14. Code Cleanup
  15. Deploying Raffle.sol
  16. Raffle.sol Unit Tests
  17. Hardhat Methods & Time Travel
  18. Callstatic
  19. Raffle.sol Staging Tests
  20. Testing on a Testnet
  21. Conclusion
  22. Typescript - Smart Contract Lottery
Lesson 10: NextJS Smart Contract Lottery (Full Stack / Front End)
  1. Introduction
  2. NextJS Setup
  3. Manual Header I
  4. Manual Header II
  5. useEffect Hook
  6. Local Storage
  7. isWeb3EnabledLoading
  8. web3uikit
  9. Introduction to Calling Functions in Nextjs
  10. useState
  11. Calling Functions in NextJS
  12. useNotification
  13. Reading & Displaying Contract Data
  14. A Note about onSuccess
  15. A Challenge to You
  16. Tailwind & Styling
  17. Introduction to Hosting your Site
  18. IPFS
  19. Hosting on IPFS
  20. Hosting on IPFS & Filecoin using Fleek
  21. Filecoin Overview
  22. Lesson 10 Recap
Lesson 11: Hardhat Starter Kit
Lesson 12: Hardhat ERC20s
  1. What is an ERC? What is an EIP?
  2. What is an ERC20?
  3. Manually Creating an ERC20 Token
  4. Creating an ERC20 Token with Openzeppelin
  5. Lesson 12 Recap
Lesson 13: Hardhat DeFi & Aave
  1. What is DeFi?
  2. What is Aave?
  3. Programatic Borrowing & Lending
  4. WETH - Wrapped ETH
  5. Forking Mainnet
  6. Depositing into Aave
  7. Borrowing from Aave
  8. Repaying with Aave
  9. Visualizing the Transactions
  10. Lesson 13 Recap
  11. Happy Bow-Tie Friday with Austin Griffith
Lesson 14: Hardhat NFTs (EVERYTHING you need to know about NFTs)
  1. What is an NFT?
  2. Code Overview
  3. Hardhat Setup
  4. Basic NFT
  5. Random IPFS NFT
  6. Dynamic SVG On-Chain NFT
  7. Advanced: EVM Opcodes, Encoding, and Calling
  8. Deploying the NFTs to a Testnet
  9. Lesson 14 Recap
Lesson 15: NextJS NFT Marketplace (If you finish this lesson, you are a full-stack MONSTER!)
  1. Introduction
  2. Part I: NFT Marketplace Contracts
  3. Reentrancy
  4. Part II: Moralis Front End
  5. Part III: TheGraph Front End
Lesson 16: Hardhat Upgrades
  1. Upgradeable Smart Contracts Overview
  2. Types of Upgrades
  3. Delegatecall
  4. Small Proxy Example
  5. Transparent Upgradeable Smart Contract
Lesson 17: Hardhat DAOs
  1. Introduction
  2. What is a DAO?
  3. How to build a DAO
Lesson 18: Security & Auditing
  1. Introduction
  2. Slither
  3. Fuzzing and Eth Security Toolbox
  4. Closing Thoughts
More Resources

Lesson 0: The Edge of the Rabbit Hole

Welcome to the course!

⌨️ (00:00:00) Lesson 0: Welcome To Blockchain

Best Practices

  • Follow the repository: While going through the course be 100% certain to follow along with the github repository. If you run into in an issue check the chronological-updates in the repo.
  • Be Active in the community: Ask questions and engage with other developers going through the course in the discussions tab, be sure to go and say hello or gm! This space is different from the other industries, you don't have to be secretive; communicate, network and learn with others :)
  • Learn at your own pace: It doesn't matter if it takes you a day, a week, a month or even a year. Progress >>> Perfection
  • Take Breaks: You will exhaust your mind and recall less if you go all out and watch the entire course in one sitting. Suggested Strategy every 25 minutes take a 5 min break, and every 2 hours take a longer 30 min break
  • Refer to Documentation: Things are constantly being updated, so whenever Patrick opens up some documentation, open it your end and maybe even have the code sample next to you.

Lesson 1: Blockchain Basics

⌨️ (00:09:05) Lesson 1: Blockchain Basics

What is a Blockchain? What does a blockchain do?

The Purpose Of Smart Contracts

⌨️ (00:18:27) The Purpose of Smart Contracts

Other Blockchain Benefits

⌨️ (00:30:41) Other Blockchain Benefits

  • Decentralized
  • Transparency & Flexibility
  • Speed & Efficiency
  • Security & Immutability
  • Counterparty Risk Removal
  • Trust Minimized Agreements

What have Smart Contracts done so far?

⌨️ (00:36:36) What have Smart Contracts done so far?

Making Your First Transaction

⌨️ (00:39:17) Making Your First Transaction

Gas I: Introduction to Gas

⌨️ (00:58:59) Gas I: Introduction to Gas

How Do Blockchains Work?

⌨️ (01:05:32) How Do Blockchains Work

Signing Transactions

⌨️ (01:22:55) Signing Transactions

Gas II

⌨️ (01:30:22) Gas II: Block Rewards & EIP 1559

Gas II Summary

⌨️ (01:36:44) Gas II Summary

High-Level Blockchain Fundamentals

[⌨️ (01:39:32) High-Level Blockchain Fundamentals]https://www.youtube.com/watch?v=gyMwXuJrbJQ&t=5972s()

🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊 Completed Blockchain Basics! 🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊

⌨️ (02:01:16) Lesson 2: Welcome to Remix! Simple Storage

💻 Code: https://github.com/PatrickAlphaC/simple-storage-fcc

Introduction

⌨️ (02:03:05) Introduction

Setting Up Your First Contract

⌨️ (02:05:18) Setting Up Your First Contract

Basic Solidity: Types

⌨️ (02:12:28) Basic Solidity Types

Basic Solidity: Functions

⌨️ (02:18:40) Basic Solidity Functions

  • Functions
  • Deploying a Contract
    • Smart Contracts have addresses just like our wallets
  • Calling a public state-changing Function
  • Visibility
  • Gas III | An example
  • Scope
  • View & Pure Functions

Basic Solidity: Arrays & Structs

⌨️ (02:35:30) Basic Solidity Arrays & Structs

  • Structs
  • Intro to Storage
  • Arrays
  • Dynamic & Fixed Sized
  • push array function

Basic Solidity: Compiler Errors and Warnings

⌨️ (02:45:35) Basic Solidity Errors & Warnings

  • Yellow: Warnings are Ok
  • Red: Errors are not Ok

Memory, Storage, Calldata (Intro)

⌨️ (02:46:34) Basic Solidity Memory, Storage, & Calldata (Intro)

  • 6 Places you can store and access data
    • calldata
    • memory
    • storage
    • code
    • logs
    • stack

Mappings

⌨️ (02:50:17) Basic Solidity Mappings

Deploying your First Contract

⌨️ (02:53:38) Deploying your First Contract

  • A testnet or mainnet
  • Connecting Metamask
  • Find a faucet here
  • See the faucets at the top of this readme!
  • Interacting with Deployed Contracts

The EVM & A Recap of Lesson 2

⌨️ (03:03:07) The EVM & A Recap of Lesson 2

  • The EVM

Lesson 3: Remix Storage Factory

⌨️ (03:05:34) Lesson 3: Remix Storage Factory

💻 Code: https://github.com/PatrickAlphaC/storage-factory-fcc

Introduction

⌨️ (03:06:06) Introduction

Basic Solidity: Importing Contracts into other Contracts

⌨️ (03:07:29) Importing Contracts into other Contracts

Basic Solidity: Interacting with other Contracts

⌨️ (03:16:36) Interacting with other contracts

  • To interact, you always need: ABI + Address
  • ABI

Basic Solidity: Inheritance & Overrides

⌨️ (03:25:23) Inheritance & Overrides

Lesson 3 Recap

⌨️ (03:30:29) Lesson 3 Recap

Lesson 4: Remix Fund Me

⌨️ (03:31:55) Lesson 4: Remix Fund Me

💻 Code: https://github.com/PatrickAlphaC/fund-me-fcc

Introduction

Sending ETH Through a Function & Reverts

Chainlink & Oracles

Review of Sending ETH and working with Chainlink

Interfaces & Price Feeds

Importing from GitHub & NPM

Floating Point Math in Solidity

Basic Solidity: Arrays & Structs II

Review of Interfaces, Importing from GitHub, & Math in Solidity

Libraries

SafeMath, Overflow Checking, and the "unchecked" keyword

Basic Solidity: For Loop

  • For Loop
  • /* */ is another way to make comments

Basic Solidity: Resetting an Array

Sending ETH from a Contract

Basic Solidity: Constructor

Basic Solidity: Modifiers

Testnet Demo

Advanced Solidity

Immutable & Constant

Custom Errors

Receive & Fallback Functions

Lesson 4 Recap

🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊 Completed Solidity Basics! 🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊

Lesson 5: Ethers.js Simple Storage

⌨️ (05:30:42) Lesson 5: Ethers.js Simple Storage

💻 Code: https://github.com/PatrickAlphaC/ethers-simple-storage-fcc

🧪 Alchemy: https://alchemy.com/?a=673c802981

Effective Debugging Strategies & Getting Help

⌨️ (5:30:46) Effective Debugging Stategies & Getting Help

  1. Tinker and isolate problem
    1. For this course, take at LEAST 15 minutes to figure out a bug.
  2. Google / Web Search the Exact problem
    1. Go to this GitHub Repo / Discussions
  3. Ask a question on a Forum like Stack Exchange Ethereum or Stack Overflow
    1. Format your questions!!
    2. Use Markdown

How to Debug Anything Video

Installation & Setup

Mac & Linux Setup

Windows Setup

  • WSL
    • When working in WSL, use Linux commands instead of Windows commands
  • TroubleShooting
  • curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash

⚠️ Please use Gitpod as an absolute last resort

Gitpod

  • Gitpod
    • If using this, NEVER share a private key with real money on Gitpod
    • Ideally you figure out the MacOS, Linux, or Windows install though

Local Development Introduction

  • CMD + K or CTRL + K clears the terminal
  • mkdir ethers-simple-storage-fcc
  • code . to open VSCode in a new VSCode window

Optional Javascript Crash Courses

    "[solidity]": {
        "editor.defaultFormatter": "NomicFoundation.hardhat-solidity"
    },
    "[javascript]":{
      "editor.defaultFormatter": "esbenp.prettier-vscode"
    }

In your .vscode/settings.json file.

Tiny Javascript Refresher

Asynchronous Programming in Javascript

Compiling our Solidity

Ganache & Networks

Introduction to Ethers.js

A Note on the await Keyword

Adding Transaction Overrides

Transaction Receipts

Sending a "raw" Transaction in Ethers.js

Interacting with Contracts in Ethers.js

Environment Variables

Better Private Key Management

Optional Prettier Formatting

Deploying to a Testnet or a Mainnet

Verifying on Block Explorers from the UI

Alchemy Dashboard & The Mempool

Lesson 5 Recap

Typescript Ethers Simple Storage

Lesson 6: Hardhat Simple Storage

⌨️ (08:20:17) Lesson 6: Hardhat Simple Storage

💻 Code: https://github.com/PatrickAlphaC/hardhat-simple-storage-fcc

Introduction

⌨️ (08:20:19) Introduction

Hardhat Setup

⌨️ (08:22:47) Hardhat Setup

Troubleshooting Hardhat Setup

⌨️ (08:29:43) Troubleshooting Hardhat Setup

Hardhat Setup Continued

⌨️ (08:31:48) Hardhat Setup Continued

Deploying SimpleStorage from Hardhat

⌨️ (08:33:10) Deploying SimpleStorage from Hardhat

Networks in Hardhat

⌨️ (08:41:44) Networks in Hardhat

Programmatic Verification

⌨️ (08:51:16) Programmatic Verification

Interacting with Contracts in Hardhat

⌨️ (09:06:37) Interacting with Contracts in Hardhat

Artifacts Troubleshooting

⌨️ (09:09:42) Artifacts Troubleshooting

Custom Hardhat Tasks

⌨️ (09:10:52) Custom Hardhat Tasks

Hardhat Localhost Node

⌨️ (09:18:12) Hardhat Localhost Node

The Hardhat Console

⌨️ (09:23:11) The Hardhat Console

Hardhat Tests

⌨️ (09:26:13) Hardhat Tests

Hardhat Gas Reporter

⌨️ (09:38:10) Hardhat Gas Reporter

Solidity Coverage

⌨️ (09:44:40) Solidity Coverage

Hardhat Waffle

⌨️ (09:47:02) Hardhat Waffle

Lesson 6 Recap

⌨️ (09:47:37) Lesson 6 Recap

Typescript Hardhat Simple Storage

⌨️ (09:52:15) Typescript Hardhat Simple Storage

yarn add --dev @typechain/ethers-v5 @typechain/hardhat @types/chai @types/node @types/mocha ts-node typechain typescript

Lesson 7: Hardhat Fund Me

⌨️ (10:00:48) Lesson 7: Hardhat Fund Me

💻 Code: https://github.com/PatrickAlphaC/hardhat-fund-me-fcc

Introduction

⌨️ (10:00:50) Introduction

Hardhat Setup - Fund Me

⌨️ (10:03:41) Hardhat Setup - Fund Me

Linting

⌨️ (10:06:20) Linting

Hardhat Setup - Fund Me - Continued

⌨️ (10:07:47) Hardhat Setup - Fund Me - Continued

Importing from NPM

⌨️ (10:09:38) Importing from NPM

Hardhat Deploy

⌨️ (10:10:43) Hardhat Deploy

Mocking

⌨️ (10:21:05) Mocking

Utils Folder

⌨️ (10:52:51) Utils Folder

Testnet Demo - Hardhat Fund Me

⌨️ (10:55:45) Testnet Demo - Hardhat Fund Me

  • Hardhat Deploy Block Confirmations

TypeScript

  • Code file (TypeScript edition)
  • Define blockConfirmations in the helper-hardhat-config.ts file instead of hardhat-config.js.

Solidity Style Guide

⌨️ (11:00:10) Solidity Style Guide

Testing Fund Me

⌨️ (11:08:36) Testing Fund Me

Breakpoints & Debugging

⌨️ (11:30:39) Breakpoints & Debugging

Gas III

⌨️ (11:33:40) Gas III

console.log & Debugging

⌨️ (11:36:35) console.log & Debugging

Testing Fund Me II

⌨️ (11:37:31) Testing Fund Me II

Storage in Solidity

⌨️ (11:44:34) Storage in Solidity

Gas Optimizations using Storage Knowledge

⌨️ (11:52:38) Gas Optimizations using Storage Knowledge

Solidity Chainlink Style Guide

⌨️ (12:05:29) Solidity Chainlink Style Guide

Storage Review

⌨️ (12:09:59) Storage Review

Staging Tests

⌨️ (12:11:43) Staging Tests

Running Scripts on a Local Node

⌨️ (12:17:58) Running Scripts on a Local Node

Adding Scripts to your package.json

⌨️ (12:22:00) Adding Scripts to your package.json

Pushing to GitHub

⌨️ (12:25:17) Pushing to GitHub

Lesson 8: HTML / Javascript Fund Me (Full Stack / Front End)

⌨️ (12:32:57) Lesson 8: HTML / Javascript Fund Me (Full Stack / Front End)

💻 Code: https://github.com/PatrickAlphaC/html-fund-me-fcc

Introduction

How Websites work with Web3 Wallets

HTML Setup

  • Live Server: ExtensionID: ritwickdey.LiveServer

Connecting HTML to Metamask

Javascript in it's own file

ES6 vs Nodejs

Sending a transaction from a Website

Resetting an Account in Metamask

MetaMask - RPC Error:
[ethjs-query] while formatting ouputs from RPC '{"value":{"code":-32603,"data":{"code":-32000,"message":"Nonce too high. Expected nonce to be 2 but got 4. Note that transactions can't be queued when automining."}}}'

Listening for Events and Completed Transactions

Input Forms

Reading from the Blockchain

Withdraw Function

Lesson 8 Recap

Optional Links:

Lesson 9: Hardhat Smart Contract Lottery

⌨️ (13:41:02) Lesson 9: Hardhat Smart Contract Lottery

💻 Code: https://github.com/PatrickAlphaC/hardhat-smartcontract-lottery-fcc

Introduction

Hardhat Setup - Smart Contract Lottery

⌨️ (13:43:43) Hardhat Setup

  • Install dependencies:
yarn add --dev @nomiclabs/hardhat-ethers@npm:hardhat-deploy-ethers ethers @nomiclabs/hardhat-etherscan @nomiclabs/hardhat-waffle chai ethereum-waffle hardhat hardhat-contract-sizer hardhat-deploy hardhat-gas-reporter prettier prettier-plugin-solidity solhint solidity-coverage dotenv
  • Install dependencies (Typescript version):
yarn add --dev @nomiclabs/hardhat-ethers@npm:hardhat-deploy-ethers ethers @nomiclabs/hardhat-etherscan @nomiclabs/hardhat-waffle chai ethereum-waffle hardhat hardhat-contract-sizer hardhat-deploy hardhat-gas-reporter prettier prettier-plugin-solidity solhint solidity-coverage dotenv @typechain/ethers-v5 @typechain/hardhat @types/chai @types/node ts-node typechain typescript

Raffle.sol Setup

⌨️ (13:46:55) Raffle.sol Setup

Introduction to Events

⌨️ (13:54:02) Introduction to Events

Events in Raffle.sol

⌨️ (14:00:47) Events in Raffle.sol

Introduction to Chainlink VRF

⌨️ (14:02:30) Introduction to Chainlink VRF

Sub-Lesson: Chainlink VRF

Implementing Chainlink VRF - Introduction

⌨️ (14:09:53) Implementing Chainlink VRF

Hardhat Shorthand

Implementing Chainlink VRF - The Request

Implementing Chainlink VRF - The FulFill

Modulo

Introduction to Chainlink Keepers

Implementing Chainlink Keepers - checkUpkeep

Enums

Implementing Chainlink Keepers - checkUpkeep continued

  • block.timestamp

Implementing Chainlink Keepers - performUpkeep

Code Cleanup

Deploying Raffle.sol

Mock Chainlink VRF Coordinator

Continued

Raffle.sol Unit Tests

  • We use async function in the describe blocks at the start, but we correctly take them out later.

Testing Events & Chai Matchers

Continued I

Hardhat Methods & Time Travel

Continued II

Callstatic

Continued III

Massive Promise Test

Continued IV

Raffle.sol Staging Tests

Testing on a Testnet

Recommended LINK amounts for Sepolia Staging Test:

  • Chainlink VRF: 2 LINK
  • Chainlink Keepers: 8 LINK

Conclusion

Typescript - Smart Contract Lottery

🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊 Completed Hardhat Basics! 🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊

Lesson 10: NextJS Smart Contract Lottery (Full Stack / Front End)

⌨️ (16:34:07) Lesson 10: NextJS Smart Contract Lottery (Full Stack / Front End)

💻 Code: https://github.com/PatrickAlphaC/nextjs-smartcontract-lottery-fcc

⚡️⚡️ Live Demo IPFS: ipfs://QmXwACyjcS8tL7UkYwimpqMqW9sKzSHUjE4uSZBSyQVuEH

⚡️⚡️ Live Demo Fleek: https://fancy-dream-3458.on.fleek.co/

Introduction

We move into using NextJS for our front end. NextJS is a React framework for building websites.

Optional Sub-Lesson: Full Stack Development & Other Libraries

NextJS Setup

yarn create next-app .

Manual Header I

React Hooks

Manual Header II

useEffect Hook

Local Storage

isWeb3EnabledLoading

web3uikit

Introduction to Calling Functions in Nextjs

Automatic Constant Value UI Updater

runContractFunction

useState

Calling Functions in NextJS

useNotification

  • Add onError to all your runContractFunction calls

Reading & Displaying Contract Data

A Note about onSuccess

  • onSuccess just checks to see if MetaMask sends the transaction, not

A Challenge to You

Tailwind & Styling

Introduction to Hosting your Site

⌨️ (18:12:50) Introdunction to Hosting your Site

IPFS

⌨️ (18:15:14) IPFS

Hosting on IPFS

⌨️ (18:18:51) Hosting on IPFS

Hosting on IPFS & Filecoin using Fleek

⌨️ (18:25:45) Hosting on IPFS & Filecoin using Fleek

Filecoin Overview

⌨️ (18:31:28) Filecoin Overview

Lesson 10 Recap

Lesson 11: Hardhat Starter Kit

⌨️ (18:51:36) Lesson 11: Hardhat Starter Kit

💻 Code: https://github.com/smartcontractkit/hardhat-starter-kit

Lesson 12: Hardhat ERC20s

⌨️ (18:59:24) Lesson 12: Hardhat ERC20s

💻 Code: https://github.com/PatrickAlphaC/hardhat-erc20-fcc

What is an ERC? What is an EIP?

What is an ERC20?

Manually Creating an ERC20 Token

Creating an ERC20 Token with Openzeppelin

Lesson 12 Recap

Lesson 13: Hardhat DeFi & Aave

⌨️ (19:16:13) Lesson 13: Hardhat DeFi & Aave

💻 Code: https://github.com/PatrickAlphaC/hardhat-defi-fcc

What is DeFi?

What is Aave?

Programmatic Borrowing & Lending

WETH - Wrapped ETH

Forking Mainnet

Depositing into Aave

Borrowing from Aave

Repaying with Aave

Visualizing the Transactions

Lesson 13 Recap

Happy Bow-Tie Friday with Austin Griffith

More DeFi Learnings:

Lesson 14: Hardhat NFTs (EVERYTHING you need to know about NFTs)

⌨️ (20:28:51) Lesson 14: Hardhat NFTs

💻 Code: https://github.com/PatrickAlphaC/hardhat-nft-fcc

What is an NFT?

Code Overview

Hardhat Setup

Basic NFT

Write Tests

Random IPFS NFT

Mapping Chainlink VRF Requests

Creating Rare NFTs

Setting the NFT Image

Setting an NFT Mint Price

Deploy Script

Uploading Token Images with Pinata

Uploading Token URIs (metadata) with Pinata

Deploying

Tests

Dynamic SVG On-Chain NFT

What is an SVG?

Initial Code

Base64 Encoding

Advanced: EVM Opcodes, Encoding, and Calling

abi.encode & abi.encodePacked

Introduction to Encoding Function Calls Directly

Introduction to Encoding Function Calls Recap

Encoding Function Calls Directly

Creating an NFT TokenURI on-Chain

Making the NFT Dynamic

Deploy Script

Deploying the NFTs to a Testnet

Lesson 14 Recap

Extra credit:

Lesson 15: NextJS NFT Marketplace (If you finish this lesson, you are a full-stack MONSTER!)

⌨️ (23:37:03) Lesson 15: NextJS NFT Marketplace (Full Stack / Front End)

Large Update, please read

Moralis has recently updated to a self-hosted server over their own server. For this, you can do one of the following:

  • Learn how to run one yourself
  • Follow along to learn the concepts of this more interactive app, without actually coding along
  • Skip to the section where we interact with the graph

TL;DR: TheGraph code should work exactly the same as the video, however the Moralis code will not.

💻 Code:

Special thanks to Matt Durkin for help with this section.

Introduction

Part I: NFT Marketplace Contracts

Hardhat Setup

NftMarketplace.sol

Reentrancy

NftMarketplace.sol - Continued

NftMarketplace.sol - Deploy Script

NftMarketplace.sol - Tests

NftMarketplace.sol - Scripts

Part II: Moralis Front End

What is Moralis?

NextJS Setup

Adding Tailwind

Introduction to Indexing in Web3

Connecting Moralis to our Local Hardhat Node

Moralis Event Sync

Reset Local Chain

Moralis Cloud Functions

Practice Resetting the Local Chain

Moralis Cloud Functions II

Querying the Moralis Database

Rendering the NFT Images

Update Listing Modal

Buy NFT Listing

Listing NFTs for Sale

Part III: TheGraph Front End

Introduction

What is The Graph?

Building a Subgraph

Deploying our Subgraph

Reading from The Graph

Hosting our Dapp

🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊 Completed Front End Basics! 🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊

Lesson 16: Hardhat Upgrades

⌨️ (28:53:11) Lesson 16: Hardhat Upgrades

💻 Code: https://github.com/PatrickAlphaC/hardhat-upgrades-fcc

Upgradable Smart Contracts Overview

Types of Upgrades

  1. Parameter
  2. Social Migrate
  3. Proxy
    1. Proxy Gotchas
      1. Function Collisions
      2. Storage Collisions
    2. Metamorphic Upgrades
    3. Transparent
    4. UUPS
    5. Diamond

Delegatecall

Small Proxy Example

Transparent Upgradable Smart Contract

Lesson 17: Hardhat DAOs

⌨️ (29:45:24) Lesson 17: Hardhat DAOs

⬆️ Up-to-date code: https://github.com/PatrickAlphaC/dao-template

💻 Code from video: https://github.com/PatrickAlphaC/hardhat-dao-fcc

Introduction

What is a DAO?

How to build a DAO

Lesson 18: Security & Auditing

⌨️ (31:28:32) Lesson 18: Security & Auditing

💻 Code: https://github.com/PatrickAlphaC/hardhat-security-fcc

Introduction

Slither

Fuzzing and Eth Security Toolbox

Closing Thoughts

Congratulations

🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊 Completed The Course! 🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊

Where do I go now?

Learning More

Community

Hackathons

Be sure to check out project grant programs!

And make today an amazing day!

Thank you

Thanks to everyone who is taking, participating in, and working on this course. It's been a passion project and a data dump of everything I've learnt in the web3 space to get you up to speed quickly. Also, a big thank you to Chainlink Labs for encouraging this course to come to light-and to the many Chainlink Labs team members who helped with various assets!

Patrick Collins Twitter Patrick Collins YouTube Patrick Collins Linkedin Patrick Collins Medium

full-blockchain-solidity-course-js's People

Contributors

0xsanyam avatar akashgreninja avatar akshaiim avatar alymurtazamemon avatar bharathmuddada avatar cymatic9 avatar divyanshudeoli avatar eroblaze avatar harendra-shakya avatar jacobwillemsma avatar krakxn avatar lanewhitten avatar marthendalnunes avatar msbivens avatar omniscienthorizon avatar othaime-en avatar patrickalphac avatar pinalikefruit avatar rohitks7 avatar rohitsingh107 avatar rowinvanamsterdam avatar santipu03 avatar scottt avatar shifta-robel avatar technophile-04 avatar uday03meh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

full-blockchain-solidity-course-js's Issues

Max Priority Fee Definition.

Lesson

Lesson 1

Could you please leave a link to the timestamp in the video where this error occurs? (You can right click a video and "copy video URL at current time")

https://youtu.be/gyMwXuJrbJQ?t=1h34m14s

Describe the bug

The best video on solidity, blockchain and web3 I've come across. Just wanted to correct what I think was a mistake.

You mentioned at the timestamp added to this issue that max priority fee was the max gas fee we are willing to pay plus the max tip we are willing to give the miners.

From my prior research before taking this course and little additional research I thought that definition applied to max fee rather than max priority fee.

Isn't Max priority fee the total tip we are willing to give the miners?

I'd love further explanation if I am wrong and thanks yet again for this wonderful course.

Lesson 7: Compiler Version Error -> 10:43.16

$ /home/ionmind/hardhat-fundme-fcc/node_modules/.bin/hardhat deploy --network rinkeby
Error HH606: The project cannot be compiled, see reasons below.

These files import other files that use a different and incompatible version of Solidity:

  * contracts/test/MockV3Aggregator.sol (^0.8.12) imports @chainlink/contracts/src/v0.6/tests/MockV3Aggregator.sol (^0.6.0)

To learn more, run the command again with --verbose

Read about compiler configuration at https://hardhat.org/config

After getting this error I modified the hardhat.config.js file as instructed on the video

module.exports = {
  //solidity: "0.8.12",
  solidity: {
    compilers: [{ version: "0.8.12" }, { version: "0.6.0" }],
  },

But still getting the error, so I also modified the compiler version in solhint.js file

{
  "extends": "solhint:recommended",
  "rules": {
    "compiler-version": ["error", "^0.8.12", "^0.6.0"],
    "func-visibility": ["warn", { "ignoreConstructors": true }],
    "var-name-mixedcase": "off",
    "avoid-low-level-calls": "off"
  }
}

But still getting the error. I will create a new copy of the contract in test on v0.8.12 and import locally into mockV3Aggregator as a temporary fix but it would be very helpful if someone could help me understand what I am doing wrong here for future references.

Thank you!

Lesson 5: Cannot connect to Ganache with JSON RPC provider

Hi, I am following the tutorial for Lesson 5 using WSL 2 Ubunto. Currently, I am on timestamp 7:07:32

When I try to deploy node.js, I receive an error that says I could not detect a network.

Here are the versions I am using:
node: v16.14.2
yarn: 1.12.19

I am sure Ganache is working. I have tried looking in forums, and StackOverflow but do not find anything that works. There are others that have the same issue and have not found an answer. So if I manage to fix this error, I will also make sure to help others.

Excuse me for the improperly asked question. This is my first ever issue on GitHub.

Deploying, please way...
Error: could not detect network (event="noNetwork", code=NETWORK_ERROR, version=providers/5.6.8)
    at Logger.makeError (/home/georgi_nedyalkov/fcc-hh-tutorial/ethers-simple-storage/node_modules/@ethersproject/logger/lib/index.js:233:21)
    at Logger.throwError (/home/georgi_nedyalkov/fcc-hh-tutorial/ethers-simple-storage/node_modules/@ethersproject/logger/lib/index.js:242:20)
    at JsonRpcProvider.<anonymous> (/home/georgi_nedyalkov/fcc-hh-tutorial/ethers-simple-storage/node_modules/@ethersproject/providers/lib/json-rpc-provider.js:561:54)
    at step (/home/georgi_nedyalkov/fcc-hh-tutorial/ethers-simple-storage/node_modules/@ethersproject/providers/lib/json-rpc-provider.js:48:23)
    at Object.next (/home/georgi_nedyalkov/fcc-hh-tutorial/ethers-simple-storage/node_modules/@ethersproject/providers/lib/json-rpc-provider.js:29:53)
    at fulfilled (/home/georgi_nedyalkov/fcc-hh-tutorial/ethers-simple-storage/node_modules/@ethersproject/providers/lib/json-rpc-provider.js:20:58)
    at runNextTicks (node:internal/process/task_queues:61:5)
    at listOnTimeout (node:internal/timers:528:9)
    at processTimers (node:internal/timers:502:7) {
  reason: 'could not detect network',
  code: 'NETWORK_ERROR',
  event: 'noNetwork'
}
const ethers = require("ethers");
const fs = require("fs-extra");

async function main() {
  // http://127.0.0.1:7545
  const provider = new ethers.providers.JsonRpcProvider([
    "http://127.0.0.1:7545",
  ]);
  const wallet = new ethers.Wallet(
    "2515bc70f606d5615a964972008f03b1fbdf222c66107b02e737e7e191613ecf",
    provider
  );
  const abi = fs.readFileSync("./SimpleStorage_sol_SimpleStorage.abi", "utf8");
  const binary = fs.readFileSync(
    "./SimpleStorage_sol_SimpleStorage.bin",
    "utf8"
  );
  const contractFactory = new ethers.ContractFactory(abi, binary, wallet);
  console.log("Deploying, please way...");
  const contract = await contractFactory.deploy();
  console.log(contract);
}

main()
  .then(() => process.exit(0))
  .catch((error) => {
    console.error(error);
    process.exit(1);
  });

Question: checkUpkeep

If checkUpkeep is called everytime automatically by keeper and decides on the basis of bool value to call the performUpkeep or not. Then in our raffle contract does it even make sense to call the checkUpkeep again inside performUpkeep ? will it save gas if we don't call it?

function checkUpkeep(bytes calldata /* checkData */) public  override returns(bool upkeepNeeded, bytes memory /* performData */){}

function performUpkeep(bytes calldata /* performData */) external override {
   (bool upkeepNeeded, ) = checkUpkeep("");
}

Getting compile errors after importing MockV3Aggregater test from node modules

Lesson

Lesson 7

Could you please leave a link to the timestamp in the video where this error occurs? (You can right click a video and "copy video URL at current time")

https://youtu.be/gyMwXuJrbJQ?list=PLyag8AsLVlQxjlVqS7zs7sbOMzG3hrk5u&t=39181

Operating System

Windows

Describe the bug

Am getting this error after importing the MockV3Aggregator test code from node modules

@chainlink/contracts/src/v0.6/interfaces/AggregatorV2V3Interface.sol:7:38: TypeError: Interfaces cannot inherit.
interface AggregatorV2V3Interface is AggregatorInterface, AggregatorV3Interface

I have tried to modifiy the solidity compiler version in hardhat-config file like this but the code wont compile

module.exports = {
  solidity: {
    compilers: [{ version: '0.8.8' }, { version: '0.6.0' }],
  },
  defaultNetwork: 'hardhat',
  networks: {
    ropsten: {
      url: process.env.ROPSTEN_URL || '',
      accounts:
        process.env.PRIVATE_KEY !== undefined ? [process.env.PRIVATE_KEY] : [],
    },
  },
  gasReporter: {
    enabled: process.env.REPORT_GAS !== undefined,
    currency: 'USD',
  },
  etherscan: {
    apiKey: process.env.ETHERSCAN_API_KEY,
  },
  namedAccounts: {
    deployer: {
      default: 0,
    },
  },
}

Verifying FundMe with Hardhat

I am following the YT video and am at 10:59:00 now thw contract is neither being verified nor any error is being displayed :-)
verify.js is as follow

const {run} = require("hardhat")
const verify = async (contractAddress, args)=>{
    console.log("Veryfing contract" +contractAddress)
    try {
        await run("verify:verify", {
          address: contractAddress,
          constructorArguments: args,
        });
        console.log("verified at "+contractAddress)
      } catch (e) {
        if (e.message.toLowerCase().includes("verified")) {
          console.log("Already Verified");
        } else console.log(e);
      }
}
module.exports = {verify}

Here is the output

sulabh@BTECH2006510:/mnt/c/projects/block/hardhat-fund-me$ yarn hardhat deploy --network rinkeby
yarn run v1.22.15
warning package.json: No license field
$ /mnt/c/projects/block/hardhat-fund-me/node_modules/.bin/hardhat deploy --network rinkeby
Nothing to compile
rinkeby
reusing "FundMe" at 0xEB738b09d9eBF8Ad6F79Dad1269D908eE8a37338
Veryfing contract0xEB738b09d9eBF8Ad6F79Dad1269D908eE8a37338
---------------------------------------
Done in 124.25s.

Lesson 7: 11:20:38 -> TypeError: ethers.getContract is not a function

AssertionError: Expected transaction to be reverted with You need to spend more ETH!, but other exception was thrown: Error: Transaction reverted: function returned an unexpected amount of data

I was getting this error when runinning test for fundMe() around 11:20:38 of the video

describe("FundMe", async function () {
  let fundMe;
  let deployer;
  let MockV3Aggregator;
  beforeEach(async function () {
    deployer = (await getNamedAccounts()).deployer;
    await deployments.fixture(["all"]);
    fundMe = await ethers.getContract("FundMe", deployer);
    MockV3Aggregator = await ethers.getContract("MockV3Aggregator", deployer);
  });

  describe("constructor", async function () {
    it("sets the aggregator addresses correctly", async function () {
      const response = await fundMe.priceFeed();
      assert.equal(response, MockV3Aggregator.address);
    });
  });
  describe("fund", async function () {
    it("Fails if you don't send enough ETH", async function () {
      await expect(fundMe.fund()).to.be.revertedWith(
        "You need to spend more ETH!"
      );
    });
  });
});

After some research it seemed that the issue could ber esolved by downloading @nomicslabs/hardhat-waffle from hardhat docs
[https://hardhat.org/plugins/nomiclabs-hardhat-waffle]

But after running the install I now get the following error running the above test

  1) FundMe
       "before each" hook for "sets the aggregator addresses correctly":
     TypeError: ethers.getContract is not a function

Any ideas of what could be the issue here? thank you!

Lesson 8: Error: Transaction reverted without a string and invalid block tags.

Discussed in #475

Originally posted by MichaelGKing June 21, 2022
Hello,

I am having trouble running my code on the local hardhat node.

On both Patrick's cloned repo's and my own work I consistently get this error:
Error: Transaction reverted without a reason string

Also in my node terminal, even after resetting my Metamask I get this issue: (block number changes)
Received invalid block tag 4. Latest block number is 3

When cloning Patrick's repo I do everything the Readme says. Except this part, I'm unsure what it means:
Reserve the front end with yarn http-server, input an amount in the text box, and hit fund button after connecting

This is my index.js folder:

// in front-end js you cannot use require, must use import
import { ethers } from "./ethers-5.6.esm.min.js";
import { abi, contractAddress } from "./constants.js";

// Have to add onclick events in js file, due to it being imported as a module type in the HTML.
const connectButton = document.getElementById("connectButton");
const fundButton = document.getElementById("fundButton");
connectButton.onclick = connect;
fundButton.onclick = fund;

console.log(ethers);

async function connect() {
  if (typeof window.ethereum != "undefined") {
    await window.ethereum.request({ method: "eth_requestAccounts" });
    connectButton.innerHTML = "Connected!";
  } else {
    connectButton.innerHTML = "Please install metamask!";
  }
}

// fund function
async function fund() {
  const ethAmount = "0.5";
  console.log(`Funding with ${ethAmount}...`);
  if (typeof window.ethereum != "undefined") {
    // provider / connection to the blockchain
    // signer / wallet/ someone with some gas
    // contract that we are interacting with
    // ^ ABI & Address
    // Web3Provider objects takes that http end point and automatically sticks it in ethers for us.
    // It looks at our metamask and says I found the http endpoint inside their metamask, thats what we are going to use as our provider here.
    const provider = new ethers.providers.Web3Provider(window.ethereum);
    const signer = provider.getSigner();
    const contract = new ethers.Contract(contractAddress, abi, signer);
    const transactionResponse = await contract.fund({
      value: ethers.utils.parseEther(ethAmount),
    });
  }
}

Any help on the issue would be greatly appreciated.

Fix links, and add special guest socials

Describe the enhancement

We have a bunch of links right now that are looking for supporting material. You can do a quick search on the repo for ]() and you'll find a bunch of hyperlinks that need to be added.

Including the special guest socials.

LESSON 5 - Verify & Publish error - rinkeby.etherscan

Compiler debug log:
 Error! Unable to generate Contract ByteCode and ABI
 Found the following ContractName(s) in source code : SimpleStorage
 But we were unable to locate a matching bytecode (err_code_2)
 For troubleshooting, you can try compiling your source code with the [Remix - Solidity IDE](https://remix.ethereum.org/) and check for exceptions

I am getting this error message when trying to verify & publish SimpleStorage.sol at the end of the lesson

This is my SimpleStorage contract - Compiled and deployed perfectly (Compiler v0.8.12)

//SPDX-License-Identifier: MIT
pragma solidity ^0.8.8; // 0.8.12 (Latest)

contract SimpleStorage {
    uint256 favoriteNumber;

    mapping(string => uint256) public nameToFavoriteNumber;
    //The string (name) is being mapped to favoriteNumber
    //Index starts iterating at 0

    struct People {
        uint256 favoriteNumber;
        string name;
    }

    People[] public people;

    function store(uint256 _favoriteNumber) public virtual {
        favoriteNumber = _favoriteNumber;
    }

    function retrieve() public view returns(uint256){
        return favoriteNumber;
    }

//calldata, memory, storage
    function addPerson(string memory _name, uint256 _favoriteNumber) public {
        people.push(People(_favoriteNumber, _name));
        nameToFavoriteNumber[_name] = _favoriteNumber; 
    }

}

Thank you!

lesson 2 line 11 struct error reading

Lesson

Lesson 2

Could you please leave a link to the timestamp in the video where this error occurs? (You can right click a video and "copy video URL at current time")

No response

Operating System

Windows

Describe the bug

struct bs

i wish i had an understanding as to why this will not allow me to complete my struct command, this is my 3rd time going over this section from the start and i am not trying to do this all over again. I just want people to show up on my deployed contract.

Cant install dependencies after setting up hardhat

I cant install dependencies after setting up hardhat, i was not given options to install am them automatically, i ran into the below errors when installing them manually using this command npm install --save-dev @nomiclabs/hardhat-waffle 'ethereum-waffle@^3.0.0' @nomiclabs/hardhat-ethers,

info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
PS C:\Users\PC\Desktop\DEVELOPEMENT\HARDHATDEMO> npm install --save-dev @nomiclabs/hardhat-waffle 'ethereum-waffle@^3.0.0' @nomiclabs/hardhat-ethers 'ethers@^5.0.0'
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/ethereum-waffle
npm ERR! dev ethereum-waffle@"3.0.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer ethereum-waffle@"^3.2.0" from @nomiclabs/[email protected]
npm ERR! node_modules/@nomiclabs/hardhat-waffle
npm ERR! dev @nomiclabs/hardhat-waffle@"*" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See C:\Users\PC\AppData\Local\npm-cache\eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\PC\AppData\Local\npm-cache_logs\2022-06-28T19_22_08_016Z-debug-0.log
PS C:\Users\PC\Desktop\DEVELOPEMENT\HARDHATDEMO>

Lesson 5:SyntaxError: Source file requires different compiler version

ethers-simple-storage/SimpleStorage.sol:2:1: SyntaxError: Source file requires different compiler version (current compiler is 0.4.17+commit.bdeb9e52.Emscripten.clang - note that nightly builds are considered to be strictly less than the released version
pragma solidity ^0.8.8;

I get this error on the 1st line
pragma solidity ^0.8.8;

But when i run the command line: solc --version it returns
Version: 0.8.14+commit.80d49f37.Linux.g++

Note that all compiler options have disappeared from settings and manual update of settings.json is not working either. Can anyone tell me what I am missing, plz? This is extremely upsetting...Thank you

This seemed to get rid of the TypeError, however, my function getters seem to be returning an empty promise.

This seemed to get rid of the TypeError, however, my function getters seem to be returning an empty promise.

Screen Shot 2022-06-07 at 3 57 47 PM

Screen Shot 2022-06-07 at 3 59 15 PM

Here is my numPlayers code:

const [numPlayers, setNumPlayers] = useState("0");
const { runContractFunction: getNumPlayers } = useWeb3Contract({
    abi: abi,
    contractAddress: raffleAddress, //specify networkId
    functionName: "getNumPlayers",
    params: {},
  });
const numPlayersFromCall = await getNumPlayers().toString();

Originally posted by @RevanthGundala in #165 (reply in thread)

LESSON 9: hh deploy [ERROR]

Error: ERROR processing /home/hh-fcc/hardhat-smartcontract-lottery-fcc/deploy/01-deploy-raffle.js:
Error: invalid contract address or ENS name (argument="addressOrName", value=undefined, code=INVALID_ARGUMENT, version=contracts/5.6.2)

======================================================================================

Terminal is returning the above error after deploying mocks when running hh deploy or yarn hardhat deploy [15:19:55]

I was unable to find a solution online & my 01-deploy-raffle.js seems identical from the one in the course. I also have watched the entire lesson from the beginning once again but still unable to figure out the issue.

Does anyone have a suggestion on how to fix this bug, plz?

Originally posted by @DorianDaSilva in #682

Lesson 7: FundMe.test.js >>> Error: expected 0 constructor arguments, got 2

  FundMe
    constructor
      1) "before each" hook for "sets the aggregator addresses correctly"


  0 passing (754ms)
  1 failing

  1) FundMe
       "before each" hook for "sets the aggregator addresses correctly":
     ERROR processing /home/me/hardhat-fundme-fcc/deploy/00-deploy-mocks.js:
Error: expected 0 constructor arguments, got 2

I am getting this error when running cmd line on FundMe.test.js:

$ yarn hardhat test

00-deploy-mocks.js deployed properly in the previous section & code is identical to the video. Not sure what the issue is, any input is welcome. Thank you!

[SOLVED]Lesson 7: Error: Transaction reverted: function returned an unexpected amount of data

image

| I am getting this error when running the test on addressTo AmountFunded() (11:23:25)

Below is my code (I ran it with & without describe line)

  describe("amount funded", async function () {
    it("Updated the amount funded data structure", async function () {
      await fundMe.fund({ value: sendValue });
      const response = await fundMe.addressToAmountFunded(deployer);
      assert.equal(response.toString(), sendValue.toString());
    });
  });

===============================================================================

|I tried checking online but no solution available on any of the forums

Does anyone have an idea of what maybe wrong? Been on this for hours and nothing. Thank you!

Lesson 7: yarn hardhat deploy --tags mocks

yarn hardhat deploy --tags mocks

returns

Error: expected 0 constructor arguments, got 2

after running line

local detected! Deploying mocks...
An unexpected error occurred:

Checked my code several times but all seems identical to video lesson. Help plz!

Lesson 5 - Compiler stopped working / All preferences have disappeared

I am getting the following errors after trying to run
node deploy.js with Ganache UI

Box on lower left of the screen when editing settings.json>>>
solc error: TypeError: solc.compileStandardWrapper is not a function

Terminal>>>

TypeError: Cannot read properties of undefined (reading 'JsonRpcProvider')

SimpleStorage.sol - line 2

pragma solidity ^0.8.14

SyntaxError: Source file requires different compiler version (current compiler is 0.4.17+commit.bdeb9e52.Emscripten.clang - note that nightly builds are considered to be strictly less than the released version
pragma solidity ^0.8.14;

NOTE: Compiler was working fine and version was set properly.

Compiler version must be fixed [compiler-fixed]

Everything was fine before trying to deploy to ganache

async function main() {
  const provider = new ethers.provider.JsonRpcProvider("HTTP://0.0.0.0:8545");
  const wallet = new ethers.Wallet(
    "c893......................6c9a13081",
    provider
  );

Now, all compiler settings have disappeared from preferences, only get the option to edit json file and settings.json edits are not working.

Can anyone tell me what the hell is going on and how to fix this, plz?

Hardhat Question

@PatrickAlphaC
In deploy script can i not access the SomeContract right after deployment ?. i want to call one of the set methods right after deployments, ethers.getContract("SomeContract") is throwing error ethers.getContract is not a function


  const someContract = await deploy("SomeContract",{
    from: deployer,
    args: [],
    log: true,
    waitConfirmations: network.config.blockConfirmations || 1
  });

  const someC = await ethers.getContract("SomeContract");

Best way to test low level call function

@PatrickAlphaC
How can i test the withdrawProceeds that it should revert with the NftMarketplace__TransferFailed(); error ?

function withdrawProceeds() external {
        uint256 proceeds = s_proceeds[msg.sender];
        if(proceeds <= 0){
            revert NftMarketplace__NoProceeds();
        }

        s_proceeds[msg.sender] = 0;
        (bool success,) = payable(msg.sender).call{value: proceeds}("");
        if(!success){
            revert NftMarketplace__TransferFailed();
        }
    }

Error in a link

Describe the enhancement

Hi Patrick,

First thank you for this amazing content. Especially concerning low level calls, I was struggling finding a good intro and your one is perfect.

In your readme (https://github.com/smartcontractkit/full-blockchain-solidity-course-js), section : Lesson 14 Recap, the link "Knowing and controlling your Smart Contract Address" is redirecting to the same link as "From Solidity to byte code". If you remember the doc you wanted to put, maybe you could try to replace with the correct version :)

Add Timestamps to all the sections

Describe the enhancement

Every "section" of the video is separated by a clip of what's in ./img/hh-fcc-background.png. We currently have the title text of each section in this repo, but we don't have the timestamp in here!

Error: No Contract deployed with name VRFCoordinatorV2Mock

Hi Patrick,

Absolutely love your YouTube content. Been working through your latest course featuring this repo and it's been great. I'm stuck at hh deploy at around 15:20:00 and I cannot for the life of me figure it out. I've tried everything for the last 5 hours or so. Here's the error I keep getting:

image

I'm stuck to be honest. I've tried everything, uninstalling with package.json, switching around versions. Keep getting this error. If I clone this repo everything compiles as in your lecture, however.

I'm about to give up and just continue with your repo, but it's a shame. Any ideas on what I'm missing here? Thanks sir.

VRF stuck in Pending.

As per title, for the lottery VRF implementation, I've followed the steps and have been met with the VRF being stuck twice.

Localhost/Hardhat works fine in the unit tests, but the staging is stuck due to Chainlink VRF being unable to go through.

image

Here's the contract address.

Lesson 7: Compiler Version Error -> 10:43.16 [SOLVED]

$ /home/ionmind/hardhat-fundme-fcc/node_modules/.bin/hardhat deploy --network rinkeby
Error HH606: The project cannot be compiled, see reasons below.

These files import other files that use a different and incompatible version of Solidity:

  * contracts/test/MockV3Aggregator.sol (^0.8.12) imports @chainlink/contracts/src/v0.6/tests/MockV3Aggregator.sol (^0.6.0)

To learn more, run the command again with --verbose

Read about compiler configuration at https://hardhat.org/config

After getting this error I modified the hardhat.config.js file as instructed on the video

module.exports = {
  //solidity: "0.8.12",
  solidity: {
    compilers: [{ version: "0.8.12" }, { version: "0.6.0" }],
  },

But still getting the error, so I also modified the compiler version in solhint.js file

{
  "extends": "solhint:recommended",
  "rules": {
    "compiler-version": ["error", "^0.8.12", "^0.6.0"],
    "func-visibility": ["warn", { "ignoreConstructors": true }],
    "var-name-mixedcase": "off",
    "avoid-low-level-calls": "off"
  }
}

But still getting the error.

I created a separate AggregatorV2V3Interface file in test folder, locally imported into MockV3Aggregator.sol & also declared solidity version ^0.8.12 for each of the files

//SPDX-License-Identifier:MIT
pragma solidity ^0.8.12;

interface AggregatorInterface {
        //Code Here//
}

interface AggregatorV3Interface {
       //Code Here//
}

interface AggregatorV2V3Interface is AggregatorInterface, AggregatorV3Interface {}
//SPDX-License-Identifier:MIT
pragma solidity ^0.8.12;

import "./AggregatorV2V3Interface.sol";

There are no errors or warnings in the code but I still get the same error when trying to compile. I don't get why I seem to be the only person having this compiler issue.

Any help is appreciated. Thank you!

eth conversion on Test net not deploying

I can not deploy my Fundme contract into MataMask despiting dividing minimum usd / eth price=50/1100= 0.05 eth.
when i converted it to wei it failed to deploy (Minimum gas fee transaction failed) what could be the issue?

Why do we borrow 0.95 in the defi example?

Can anyone please help me understand this part, i understood the part 0.95 wherein if we can borrow 10, in that case we are just borrowing the 95% of the DAI, last reciprocal part i didn't understand why do we even need that. sorry for the dumb math question

  const amountDaiToBorrow = availableBorrowsETH.toString() * 0.95 * (1 / daiPrice.toNumber());

Compiler Trouble

[Info  - 11:14:56 AM] solang language server v0.1.11 initialized
thread 'main' panicked at 'not implemented', src/emit/ewasm.rs:835:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Output terminal returns this error which causes this error on the pragma version declaration

/mnt/c/Users/doria/hardhat-simple-storage-fcc/contracts/SimpleStorage.sol:2:1: SyntaxError: Source file requires different compiler version (current compiler is 0.4.17+commit.bdeb9e52.Emscripten.clang - note that nightly builds are considered to be strictly less than the released version
pragma solidity ^0.8.8; // 0.8.12 (Latest)
^---------------------^

Seems to be caused by solidity + hardhat extension - I get error on solidity Juan blanco ext, Solang and solhint (All stopped working) but even unistalled errors persist. Help plz, this is an on going issue!

Raffle Keepers , VRF Issue

My raffle contract deploys perfectly fine, after deploying the contract https://rinkeby.etherscan.io/address/0x2FBeaAFdacb7116CD5258d64ee102E908addEc85

  1. Created the VRF Chainlink Subscription https://vrf.chain.link/rinkeby/6148
  2. Registered the keeper
    3.Funded both vrf and keepers

After all theses steps.. i ran the staging test ... it initiated the test, entered into the raffle. after 30 seconds performUpkeep triggered.it even emitted the requestId https://rinkeby.etherscan.io/tx/0xb72ed45c229ecf369459c55e05d91a3ca49cf2c0919b0c02d85c717f6e94ec96#eventlog
But in VRF sub , it still shows pending, waited for almost 24hours for the first time :(. i thought i did something wrong so tried the whole process again. after the performUpkeep the vrf shows it in pending. i also checked the
VRFCoordinatorV2 rinkeby contract pendingRequestExists('6148') with my subId it returns true
https://rinkeby.etherscan.io/address/0x6168499c0cFfCaCD319c818142124B7A15E857ab#readContract

image

@PatrickAlphaC what could be the issue ?

Lesson 5 : TypeError : Cannot read properties of undefined (reading `toHexString`)

Lesson

Lesson 5

Could you please leave a link to the timestamp in the video where this error occurs? (You can right click a video and "copy video URL at current time")

https://youtu.be/gyMwXuJrbJQ?t=27189

Operating System

Windows

Describe the bug

I could not get Ganache to run properly, so I skipped to hardhat and am having some issues deploying my contract at this phase. Here is the TypeError. I tried googling and searching on the appropriate resources, but can't seem to find the solution.

~/hardhat-fcc/ethers-simple-storage$ node deploy.js
TypeError: Cannot read properties of undefined (reading 'toHexString')
at isHexable (/home/thearkitech/hardhat-fcc/ethers-simple-storage/node_modules/@ethersproject/bytes/lib/index.js:9:21)
at hexlify (/home/thearkitech/hardhat-fcc/ethers-simple-storage/node_modules/@ethersproject/bytes/lib/index.js:175:9)
at new SigningKey (/home/thearkitech/hardhat-fcc/ethers-simple-storage/node_modules/@ethersproject/signing-key/lib/index.js:20:82)
at new Wallet (/home/thearkitech/hardhat-fcc/ethers-simple-storage/node_modules/@ethersproject/wallet/lib/index.js:120:36)
at main (/home/thearkitech/hardhat-fcc/ethers-simple-storage/deploy.js:11:20)
at Object. (/home/thearkitech/hardhat-fcc/ethers-simple-storage/deploy.js:47:1)
at Module._compile (node:internal/modules/cjs/loader:1103:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)

This is my current deploy.js code:

const ethers = require("ethers");
const fs = require("fs-extra");
require("dotenv").config()
// synchronous [solidity]
// asynchronous [javascript]
// http://172.29.144.1:7545S


async function main() {
    const provider = new ethers.providers.JsonRpcProvider(process.env.RPC_URL);
    const wallet = new ethers.Wallet(process.env.PRIVATE_KEY, provider);
    const abi = fs.readFileSync("./SimpleStorage_sol_SimpleStorage.abi", "utf8");
    const binary = fs.readFileSync("./SimpleStorage_sol_SimpleStorage.bin","utf8");
    const contractFactory = new ethers.ContractFactory(abi,binary,wallet);
    console.log("Deploying, please wait...");
    const contract = await contractFactory.deploy();//could add overrides here
     await contract.deployTransaction.wait(1);
    // console.log("Here is the deployment transaction (transaction response): ");
    // console.log(contract.deployTransaction);

    // console.log("Here is the transaction receipt: ");
    // console.log(transactionReceipt);

//     console.log("Let's deploy with only transaction data!");
//     const nonce = await wallet.getTransactionCount();//auto updates nonce count
//     const tx = {
//         nonce: nonce,
//         gasPrice: "20000000000",
//         gasLimit: "1000000",
//         to: null,
//         value: 0,
//         data: "0x608060405234801561001057600080fd5b5061077a806100206000396000f3fe608060405234801561001057600080fd5b50600436106100575760003560e01c80632e64cec11461005c5780636057361d1461007a5780636f760f41146100965780638bab8dd5146100b25780639e7a13ad146100e2575b600080fd5b610064610113565b6040516100719190610533565b60405180910390f35b610094600480360381019061008f9190610476565b61011c565b005b6100b060048036038101906100ab919061041a565b61012f565b005b6100cc60048036038101906100c791906103d1565b6101bf565b6040516100d99190610533565b60405180910390f35b6100fc60048036038101906100f79190610476565b6101ed565b60405161010a92919061054e565b60405180910390f35b60008054905090565b8060008190555060005460008190555050565b600260405180604001604052808381526020018481525090806001815401808255809150506001900390600052602060002090600202016000909190919091506000820151816000015560208201518160010190805190602001906101959291906102a9565b505050806001836040516101a9919061051c565b9081526020016040518091039020819055505050565b6001818051602081018201805184825260208301602085012081835280955050505050506000915090505481565b600281815481106101fd57600080fd5b906000526020600020906002020160009150905080600001549080600101805461022690610647565b80601f016020809104026020016040519081016040528092919081815260200182805461025290610647565b801561029f5780601f106102745761010080835404028352916020019161029f565b820191906000526020600020905b81548152906001019060200180831161028257829003601f168201915b5050505050905082565b8280546102b590610647565b90600052602060002090601f0160209004810192826102d7576000855561031e565b82601f106102f057805160ff191683800117855561031e565b8280016001018555821561031e579182015b8281111561031d578251825591602001919060010190610302565b5b50905061032b919061032f565b5090565b5b80821115610348576000816000905550600101610330565b5090565b600061035f61035a846105a3565b61057e565b90508281526020810184848401111561037b5761037a61070d565b5b610386848285610605565b509392505050565b600082601f8301126103a3576103a2610708565b5b81356103b384826020860161034c565b91505092915050565b6000813590506103cb8161072d565b92915050565b6000602082840312156103e7576103e6610717565b5b600082013567ffffffffffffffff81111561040557610404610712565b5b6104118482850161038e565b91505092915050565b6000806040838503121561043157610430610717565b5b600083013567ffffffffffffffff81111561044f5761044e610712565b5b61045b8582860161038e565b925050602061046c858286016103bc565b9150509250929050565b60006020828403121561048c5761048b610717565b5b600061049a848285016103bc565b91505092915050565b60006104ae826105d4565b6104b881856105df565b93506104c8818560208601610614565b6104d18161071c565b840191505092915050565b60006104e7826105d4565b6104f181856105f0565b9350610501818560208601610614565b80840191505092915050565b610516816105fb565b82525050565b600061052882846104dc565b915081905092915050565b6000602082019050610548600083018461050d565b92915050565b6000604082019050610563600083018561050d565b818103602083015261057581846104a3565b90509392505050565b6000610588610599565b90506105948282610679565b919050565b6000604051905090565b600067ffffffffffffffff8211156105be576105bd6106d9565b5b6105c78261071c565b9050602081019050919050565b600081519050919050565b600082825260208201905092915050565b600081905092915050565b6000819050919050565b82818337600083830152505050565b60005b83811015610632578082015181840152602081019050610617565b83811115610641576000848401525b50505050565b6000600282049050600182168061065f57607f821691505b60208210811415610673576106726106aa565b5b50919050565b6106828261071c565b810181811067ffffffffffffffff821117156106a1576106a06106d9565b5b80604052505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b610736816105fb565b811461074157600080fd5b5056fea264697066735822122071e19bb4890c5bad4bbb19b7844c2eea0e1be6d3a977d51f7802315910422eee64736f6c63430008070033",
//         chainID: 31337,
//     };
//     const sentTxResponse = await wallet.sendTransaction(tx);
//     await sentTxResponse.wait(1);
//     console.log(sentTxResponse);

const currentFavoriteNumber = await contract.retrieve();
console.log(`Current Favorite Number: ${currentFavoriteNumber.toString()}`);
const transactionResponse = await contract.store("7");
const transactionReceipt = await transactionResponse.wait(1);
const updatedFavoriteNumer = await contract.retrieve();
console.log(`Updated favorite number is: ${updatedFavoriteNumber}`);
 }

main()
.then(() => process.exit(0))
.catch((error) => {
    console.error(error)
    process.exit(1);
});

LESSON 9: Error: invalid contract address or ENS name [15:19:55]

Error: ERROR processing /home/hh-fcc/hardhat-smartcontract-lottery-fcc/deploy/01-deploy-raffle.js:
Error: invalid contract address or ENS name (argument="addressOrName", value=undefined, code=INVALID_ARGUMENT, version=contracts/5.6.2)

======================================================================================

Terminal is returning the above error after deploying mocks when running hh deploy or yarn hardhat deploy

I was unable to find a solution online & my 01-deploy-raffle.js seems identical from the one in the course.

Does anyone have a suggestion on how to fix this bug, plz?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.