Skip to content

Cyfrin/moccasin-full-course-cu

Repository files navigation

Blockchain Developer, Vyper Smart Contract & Python Career Path - Powered By AI - Beginner to Expert Course

| Moccasin Edition 2025 |

Learn smart contract development, and level up your career

Stargazers Forks Contributors Issues GPLv3 License



This repository houses course resources and discussions for the course.

Please refer to this for an in-depth explanation of the content:

  • Website - Join Cyfrin Updraft and enjoy 50+ hours of smart contract development courses
  • Twitter - Stay updated with the latest course releases
  • LinkedIn - Add Updraft to your learning experiences
  • Discord - Join a community of 3000+ developers and auditors
  • Codehawks - Smart contracts auditing competitions to help secure web3

Python Blockchain Developer, Smart Contract, & Vyper Course - Powered By AI

Required Prerequisites

Nice to have:

  • A little understanding of python

Table of Contents

All the sections on this repo are for several courses on the Vyper Developer Career path of Cyfrin Updraft.

Resources
  1. Required Prerequisites
  2. Table of Contents
  3. Testnet Faucets
  4. Resources For This Course
Welcome & Course Introduction
  1. Welcome to the Course Repo
  2. Section 0: Welcome to the Course!
  3. Section 1: Blockchain Basics
Vyper 101
  1. Section 1: Welcome to Remix - Favorite's List
  2. Section 2: Remix Buy Me A Coffee
  3. Section 3: AI Prompting, Asking Questions, and Researching
Moccasin Fundamentals
  1. Section 1: Python Crash Course
  2. Local Development Introduction
  3. Section 2: Web3.py Favorite's List
  4. Section 3: Titanoboa Favorite's List
  5. Moccasin Version
  6. Section 4: Moccasin Favorite's List
  7. Section 5: Moccasin Five More
  8. ⭐️ Section 6: Moccasin Buy Me A Coffee (GET HERE!)
  9. Section 7: HTML/JS Buy Me A Coffee
  10. Section 8: Moccasin ERC20
  11. Section 9: How to get hired
Advanced Moccasin
  1. Section 1: Moccasin NFTs
  2. Section 2: Moccasin DeFi | Algorithmic Trading
  3. ⭐️ Section 3: Moccasin DeFi | Stablecoin (GET HERE!)
  4. Section 4: Moccasin Signatures
  5. Section 5: Moccasin Upgrades
Course Completion
  1. Congratulations
  2. Disclosures
  3. Sponsors
  4. Thank you

Recommended Tools

  • Recommended Testnet: Sepolia (Or Tenderly Virtual Network)

If you receive a flag pop-up requiring you to have 0.001 ETH on mainnet, you may be able to wait 10 to 20 minutes and try again to avoid adding the 0.001 ETH on the mainnet.

⚠️ 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.

Chainlist

Resources For This Course

Bridging to ZKsync

If you want to work with real funds on ZKsync for any challenges that we deploy there, you can follow this list.

Please do not use real funds unless you are confident of what you are doing, especially when it comes to private key safety.

  1. The process for bridging looks like the following:
    1. Buy ETH (On an exchange like Coinbase or Kraken)
  2. Send ETH -> one of your wallets like:
    1. Metamask
    2. Frame
    3. Rainbow
    4. Argent
    5. Coinbase Wallet
  3. Use the ZKsync Bridge

Welcome to the Course Repo

Best Practices

  • Follow the repository: While going through the course be 100% certain to follow along with the github repository. If you run into 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 on your end and maybe even have the code sample next to you.
  • Use ChatGPT and/or the course chat

(back to top) ⬆️

Section 0: Welcome to the Course!


Section 1: Blockchain Basics

[!IMPORTANT] Please be sure to go through blockchain basics before coming here! The GitHub repository for that curriculum can be found here:

🐱 GitHub repository : https://github.com/Cyfrin/blockchain-basics-cu

(back to top) ⬆️

Vyper 101


Section 1: Welcome to Remix - Favorite's List

πŸ’» Code: https://github.com/Cyfrin/remix-favorites-cu

Workshop

Spend at most 25 minutes on all of these prompts without the aide of AI. If you're unable to solve them after 25 minutes, stop, take a break, and then work with an AI or the discussions to help you solve them. Good luck!

  1. Create a function called add that adds 1 to whatever is in self.favorite_number
  2. Have the starting favorite number different from 7, check to make sure it's the number you set!
  3. (Challenging) Create a new type using the "struct" keyword, and create a function that will save a new variable of that type to a state/storage variable.

Section 2: Remix Buy Me A Coffee

πŸ’» Code: https://github.com/Cyfrin/remix-buy-me-a-coffee-cu

Workshop

Spend at most 25 minutes on all of these prompts without the aide of AI. If you're unable to solve them after 25 minutes, stop, take a break, and then work with an AI or the discussions to help you solve them. Good luck!

  1. (Optional) Get the price of a different asset using Chainlink price feeds on your fake chain
  2. Write a function to get the total amount of funds in the contract
    1. Loop through the array of funders, and how much they've funded!
    2. Try not to just use self.balance!
  3. (Challenging!) Write a function that allows you to change the owner of the contract
    1. Hint: You'll need to make sure OWNER isn't immutable!

(back to top) ⬆️

Section 3: AI Prompting, Asking Questions, and Researching


No code here!

Workshop

Get a good idea for "how good" your AI is. Maybe shop around for an AI you like. Ask them some softball questions to figure out how smart they are. Like:

  1. Make a minimal vyper contract
  2. What's the difference between a dynamic array and a fixed sized array?
  3. Here is some vyper code:
@external
def add_person(name: String[100], favorite_number: uint256):
    new_person: Person = Person(favorite_number = favorite_number, name = name)
    self.list_of_people[self.list_of_people_index] = new_person
    self.list_of_numbers[self.list_of_people_index] = favorite_number
    self.list_of_people_index += 1
    self.name_to_favorite_number[name] = favorite_number

What does it do?

  1. Is this vyper code safe?
send(OWNER, self.balance)

(back to top) ⬆️

Moccasin Fundamentals


Section 1: Python Crash Course

Python Version: 3.11

Full code: https://github.com/Cyfrin/python-in-updraft-cu

Google Collab

Installation & Setup (MacOS & Linux)

Installation & Setup (Windows/WSL)

  • Special Guest Vasiliy
  • 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 or CodeSpaces

  • 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

Install Python (Windows WSL/Linux/Ubuntu)

To check for python, run:

which python
python --version

which python3
python3 --version

To install a specific version of python:

sudo apt-get update
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get update
sudo apt-get install python3.11

Local Development Introduction

  • CMD + K or CTRL + K clears the terminal
  • code . to open VSCode in a new VSCode window

Workshop

Spend at most 25 minutes on all of these prompts without the aide of AI. If you're unable to solve them after 25 minutes, stop, take a break, and then work with an AI or the discussions to help you solve them. Good luck!

Here is your final project, make a function that takes 2 inputs, the first is a year, and the second is a number of days. The function should print out either:

Y days after Jan 1st, X, it will still be the year X

or

Y days after Jan 1st, X, it will be the year Z

Where:

  • X is the starting year, the first input to the function
  • Y is the number of days, the second input to the function
  • Z is the year after the X number of days

Examples

The function invocations will look like this:

what_year(1985, 376)

Which should print:

376 days after Jan 1st, 1985, it will be the year 1986

Or

what_year(1985, 200)

Which should print:

200 days after Jan 1st, 1985, it will still be the year 1985

Or

what_year(1985, 1098)

Which should print:

1098 days after Jan 1st, 1985, it will be the year 1988

Notice how "still" is added to the second sentance, but not the first!

Assumptions

  1. Assume a year is 365 days (but, if you're off by a day or two, that's ok)
  2. Don't worry about leap years
  3. Don't use the datetime package!

Python in Updraft

  • uv

  • Virtual environments image

Virtual environments diagram

(back to top) ⬆️

Section 2: Web3.py Favorite's List

πŸ’» Code: https://github.com/Cyfrin/web3py-favorites-cu

Workshop

Spend at most 25 minutes on all of these prompts without the aide of AI. If you're unable to solve them after 25 minutes, stop, take a break, and then work with an AI or the discussions to help you solve them. Good luck!

Do one of the following:

  • (Optional) Deploy the favorites.vy contract to your tenderly RPC URL!
  • Deploy the favorites.vy contract to anvil with a different wallet address, and a new encrypted key!

(back to top) ⬆️

Section 3: Titanoboa Favorite's List

πŸ’» Code: https://github.com/Cyfrin/boa-favorites-cu

pyevm

Workshop

Spend at most 25 minutes on all of these prompts without the aide of AI. If you're unable to solve them after 25 minutes, stop, take a break, and then work with an AI or the discussions to help you solve them. Good luck!

  1. Create your own contract that you can:
    1. Deploy to your local anvil instance
    2. Call set_bool(boolean) which which change a variable named my_bool to the boolean you pass it
    3. Call get_bool() which will return the value of my_bool
  2. Deploy to your local tenerly network (if you still have the free trial!)

Moccasin Version

0.3.6

Install command

uv tool install 'moccasin==0.3.6' 

Section 4: Moccasin Favorite's List

πŸ’» Code: https://github.com/Cyfrin/mox-favorites-cu

wget -O zkvyper <RELEASE_VERSION>
chmod +x zkvyper
mv zkvyper /usr/local/bin

Sign up for Alchemy

Workshop

Spend at most 25 minutes on all of these prompts without the aide of AI. If you're unable to solve them after 25 minutes, stop, take a break, and then work with an AI or the discussions to help you solve them. Good luck!

  1. Deploy your contract to your tenderly virtual network
  2. Write your own deploy script, and deploy it to the pyevm network
  3. Write your own deploy script, and deploy it to the eravm network
  4. Write a new test in your testfile, and run it!

(back to top) ⬆️

Section 5: Moccasin Five More

πŸ’» Code: https://github.com/Cyfrin/mox-five-more-cu

  • create_copy_of image

create_copy_of

Workshop

Spend at most 25 minutes on all of these prompts without the aide of AI. If you're unable to solve them after 25 minutes, stop, take a break, and then work with an AI or the discussions to help you solve them. Good luck!

  1. Add a second module to five_more
    1. Initialize it
    2. And call one of the functions from it. For example, in your five_more contract:
    initializes: my_contract
    
    def some_func():
     my_contract.set_bool(True)
  2. Try to export functions from 2 different modules
  3. (Challenging) Make a contract that successfully compiles with the uses keyword
  4. (Challenging) Make a contract that uses the contract from #3!

(back to top) ⬆️

⭐️ Section 6: Moccasin Buy Me A Coffee (GET HERE!)

πŸ’» Code: https://github.com/Cyfrin/mox-buy-me-a-coffee-cu

  • Storage Images:
Storage Start Booleans Fixed Arrays Dynamic Arrays
Mappings Constants Immutables Memory Variables

Test types

There are many types of tests:

  • Unit: Test a single function/part of your code.
  • Integration: Test how different parts of your code work together.
  • Staging: Test your code in a production-like environment.
  • Forked (Staging): Test your code in a production-like environment, but with a forked version of the blockchain.
  • Fuzz: Test your code with random inputs.
  • Formal Verification: Prove that your code is correct.

Workshops

Spend at most 25 minutes on all of these prompts without the aide of AI. If you're unable to solve them after 25 minutes, stop, take a break, and then work with an AI or the discussions to help you solve them. Good luck!

Workshop 1

Write a test that:

  • Funds the contract with 10 different funders
  • Withdraws the funds using the owner
  • Asserts that:
    • The ending balance of buy_me_a_coffee is 0
    • The ending balance of the owner is the addition of all the amounts the funders added

Workshop 2

  1. Write enough tests to get you over 95% code coverage for buy_me_a_coffee.vy
  2. Sign up for Cyfrin Profiles! (And then tweet at me!)
  3. Push your code up to GitHub
  4. Add a new commit up to your GitHub repo

(back to top) ⬆️

Section 7: HTML/JS Buy Me A Coffee

πŸ’» Code: https://github.com/Cyfrin/html-fund-me-cu

Workshop

None, Just enjoy the section!

Section 8: Moccasin ERC20

πŸ’» Code: https://github.com/Cyfrin/mox-erc20-cu

We teach how to build minimal ERC20 tokens like WETH, LINK, USDC, and DAI!

Extra Learnings

  • Random Numbers
  • CEI
  • Console

Workshop 1

Spend at most 25 minutes on all of these prompts without the aide of AI. If you're unable to solve them after 25 minutes, stop, take a break, and then work with an AI or the discussions to help you solve them. Good luck!

If you do the stateful fuzzer challenge, 1 hour is ok!

  • Write tests for your snek_token ERC20, try to get to 80% coverage!
  • (Challenging!) Write a stateful fuzzer for your ERC20 token!

Note

The workshop of the next section is what you should do. DO NOT CONTINUE TO ADVANCED MOCCASIN UNTIL YOU'VE COMPLETED THE WORKSHOP OF SECTION 9! You'll only be cheating yourself.

(back to top) ⬆️

Section 9: How to get hired

Steps

  1. Write down your reasons why
  2. Do 1 full course Cyfrin Updraft
    1. Get through Advanced Moccasin
  3. Apply your knowledge and get real experience
    1. Hackathons like ETH Global
    2. Competitive Audits like CodeHawks
    3. Make pull requests to open sourced projects
    4. Build projects and add them to your GitHub
    5. Update your Cyfrin Profile
  4. Apply to jobs, start a company, or freelance
  5. Repeat steps 3 and 4
    1. You should always be learning more by doing more!

Workshop

Spend at most 1 week on this :)

Feel free to use some AI!

Prompt

Build a smart contract lottery/raffle yourself, using minimal AI help. You can build a "weak randomness" lotttery, using on-chain randomness (but just know, it's not secure!). Or go the extra mile and use Chainlink VRF 2.5 to build a secure lottery.

You should:

  1. Have test coverage of over 80% of your lines of code
  2. Have a function called enter_raffle for people to enter your raffle
  3. The raffle should pick 1 winner after X seconds
    1. Have this be a customizable variable
  4. The winner should get the sum of all the entrance fees added by the other participants
  5. Anyone can call a pick_winner or request_winner function, that will randomly select the winner.

Here are some example code bases to help you:


Advanced Moccasin


Section 1: Moccasin NFTs

πŸ’» Code: https://github.com/Cyfrin/mox-nft-cu

Workshop 1

Spend at most 25 minutes on all of these prompts without the aide of AI. If you're unable to solve them after 25 minutes, stop, take a break, and then work with an AI or the discussions to help you solve them. Good luck!

  1. Upload your own dog image to IPFS, mint it as an NFT, and then see it in your Metamask!
  2. Write tests to get to at least 80% coverage!

Workshop 2

Spend at most 25 minutes on all of these prompts without the aide of AI. If you're unable to solve them after 25 minutes, stop, take a break, and then work with an AI or the discussions to help you solve them. Good luck!

  1. Deploy your mood NFT to a locally running chain, flip it's mood, and view it in metamask!
  2. Get to 80% test coverage!

Section 2: Moccasin DeFi | Algorithmic Trading

πŸ’» Code: https://github.com/Cyfrin/mox-algorithmic-trading-cu


We will rebalance a portfolio using USDC and WETH.

Workshop

Spend at most 25 minutes on all of these prompts without the aide of AI. If you're unable to solve them after 25 minutes, stop, take a break, and then work with an AI or the discussions to help you solve them. Good luck!

  1. Copy the code you wrote in your notebook into some scripts
  2. Run your scripts on a Tenderly virtual network, or a forked network
    1. Start with your target allocations not being correct, but then correct them!

⭐️ Section 3: Moccasin DeFi | Stablecoin (GET HERE!)

πŸ’» Code: https://github.com/Cyfrin/mox-stablecoin-cu

You'll learn how to build your own stablecoin! Pick collateral like WETH, WBTC, and USDC to make your own stablecoin! Stablecoins one of the most POWERFUL applications on earth!

Workshop 1

Spend at most 25 minutes on all of these prompts without the aide of AI. If you're unable to solve them after 25 minutes, stop, take a break, and then work with an AI or the discussions to help you solve them. Good luck!

  1. Get your unit test coverage above 80%!

Workshop 2

Spend at most 25 minutes on all of these prompts without the aide of AI. If you're unable to solve them after 25 minutes, stop, take a break, and then work with an AI or the discussions to help you solve them. Good luck!

  1. Complete your own fuzz tests!

Workshop 3

  1. Look into the audit report, see if you can spot some issues with this codebase yourself!

Section 4: Moccasin Signatures

πŸ’» Code: https://github.com/Cyfrin/mox-signatures-cu

SubLesson - Signatures

Workshop

Spend at most 25 minutes on all of these prompts without the aide of AI. If you're unable to solve them after 25 minutes, stop, take a break, and then work with an AI or the discussions to help you solve them. Good luck!

  1. Deploy to ZKsync (era test node, sepolia, or tenderly ETH virtual network)
  2. Try to make a bigger merkle tree with 8 leaves!

Section 5: Moccasin Upgrades

πŸ’» Code: https://github.com/Cyfrin/mox-upgrades-cu

Workshop

Spend at most 25 minutes on all of these prompts without the aide of AI. If you're unable to solve them after 25 minutes, stop, take a break, and then work with an AI or the discussions to help you solve them. Good luck!

  1. Try to write a contract that has a function selector collision with the proxy
  2. Write a contract where the storage variables change order!

(back to top) ⬆️

Congratulations

🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊 Completed all 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!

(back to top) ⬆️

Disclosures

Transparency is important! So we want to disclose any potential conflicts that might have affected my judgement so you can pick tools that are right for you. Patrick is co-founder of Alpha Chain, a blockchain infrastructure company. Alpha Chain runs Chainlink, Ethereum, Binance, Polygon, Harmony, Solana, Moonbeam, and Moonriver blockchain services. Alpha Chain often works with Alchemy and receives discounted services. Patrick is the co-founder of Cyfrin, and they do smart contract security & auditing services. Patrick is also the co-founder of Chain Accel, who is an advisor on the Peeranha project.

Because of all this, I have added alternatives to each section where we suggest a tool.

(back to top) ⬆️

Sponsors

A huge thank you to our sponsors. These are the groups and technologies

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 Cyfrin & Chain Accel for encouraging this course to come to light, and many, many, many people from the community.

And thanks to the Cyfrin team for making this possible!

License

Cyfrin Updraft content is open-sourced licensed as GPLv3.

Cyfrin Twitter Cyfrin YouTube Cyfrin LinkedIn

About

No description, website, or topics provided.

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published