Refactor 2

A comprehensive guide to refactoring your Vyper smart contract. The lesson covers using a price module to convert ETH to USD, utilizing constant variables for efficiency, and optimizing storage for a clean contract.

1. Intro
A comprehensive workshop on creating a professional Buy Me A Coffee project using Mocassin. Learn advanced testing techniques including unit tests, staging tests, and integration tests. Duration: 5min
2. Setup
A simple Vyper smart contract to Buy Me a Coffee - This lesson shows how to build a simple contract that allows users to send money to the creator, keeping track of who sent how much. The lesson also covers how to set a minimum amount for donations, how to withdraw the money, and how to display the current price of ETH in USD. Duration: 3min
3. Refactor
A practical guide to refactoring code in Vyper by separating interfaces into their own files. The lesson covers how to use AI to convert in-line interfaces to file interfaces, and how to import modules into your contract. Duration: 6min
4. Storage
A comprehensive introduction to storage layout in Vyper smart contracts. The lesson explores different storage variable types, including constants, immutables, and arrays, as well as how these types are allocated and accessed in storage. Duration: 16min
5. Refactor 2
A comprehensive guide to refactoring your Vyper smart contract. The lesson covers using a price module to convert ETH to USD, utilizing constant variables for efficiency, and optimizing storage for a clean contract. Duration: 1min
6. Script
A practical guide to writing a deployment script and tackling the challenges of testing on a PyEVM network - This lesson walks through writing a simple deployment script using Python and explores the issues of using hardcoded contract addresses for testing on PyEVM networks. Duration: 5min
7. Mocks
A practical guide to testing Vyper smart contracts using mock contracts. The lesson covers how to create and deploy mock contracts, integrate them into tests, and debug errors for a successful and efficient testing process. Duration: 10min
8. Manifest
A powerful tutorial to deploying a Vyper smart contract to a blockchain network. This video covers how to set up a development environment, create a new contract, compile it, deploy it to the blockchain, and test the deployed smart contract. Duration: 11min
9. Top Level
A powerful introduction to top-level named contracts, showing you how to create parameters for every network you are deploying to. The lesson covers creating the top-level named contracts in your project and explaining the concept of deployer scripts for each network. Duration: 6min
10. Kinds
A comprehensive guide to the kinds of tests used in Vyper development - This video explores different types of tests used in Vyper smart contract development, such as unit tests, integration tests, staging tests, forked tests, fuzz tests, and formal verification. Duration: 2min
11. Unit
A comprehensive guide to writing unit tests for a Vyper smart contract in a Python environment. The lesson demonstrates the use of pytest fixtures to streamline testing, covering the basics of setting up a test environment, importing necessary components, and running unit tests. Duration: 8min
12. Test Revert
A practical guide to testing for reverts in Vyper smart contracts - The lesson covers testing for reverts using Boa, a Python testing library for Vyper contracts. It demonstrates how to test for reverts using the `with boa.reverts` function. Duration: 2min
13. Set Balance
A practical guide to writing cheat codes in Vyper smart contracts - This lesson covers setting the balance of a user within a test environment using the Boa cheat code library. You will learn how to effectively test the interaction of your smart contract with users who have different amounts of money. Duration: 4min
14. Prank
A comprehensive guide to pranking in Vyper smart contract testing with Boa. The lesson explores the 'boa.env.prank()' function, enabling you to impersonate other users and test scenarios involving unauthorized access to functions like withdraw. Duration: 4min
15. Mid Sec Work
A comprehensive guide to Vyper smart contract testing using Pytest - This lesson teaches you how to test a smart contract using Pytest, covering key concepts like setting up your test environment, writing individual tests, and ensuring your code is robust and secure. Duration: 2min
16. More Fixtures
A practical guide to using Pytest Fixtures in Vyper smart contract testing. The lesson covers how to create custom fixtures to simplify repetitive test setup tasks, making your tests more concise and efficient. Duration: 3min
17. Test Coverage
A helpful guide to understanding test coverage in Vyper smart contract development. This lesson covers how to use Pytest-cov to determine how much of your code has been tested and which lines you've missed. Duration: 4min
18. Gas Profile
A detailed guide to gas profiling in Vyper smart contracts. This lesson covers how to use the gas profile command to get an output on gas use for test functions, showing the difference in cost between storage and constant variables. Duration: 3min
19. Fork Tests
A practical guide to running fork tests in a Vyper development environment - Fork tests allow you to test your smart contract against a real blockchain network (e.g., Sepolia) but without deploying your contract. This enables you to simulate how your contract will interact with real contracts and data, allowing you to discover potential errors or issues before deploying to a live network. Duration: 6min
20. Staging
Duration: 7min
21. Deployments Db
A practical guide to managing deployments using a SQLite database. The lesson covers how to set the 'save_to_db' flag to true in 'mocassin.toml', store deployment information, and access the database to retrieve addresses and other deployment data. Duration: 9min
22. Zksync Testing
A comprehensive guide to testing your smart contract against zkSync. This video covers deploying and testing smart contracts using a mocked zkSync network with different test scenarios including funding the contract and withdrawing funds from the contract. Duration: 1min
23. Github
A comprehensive guide to pushing your code to GitHub. The lesson covers creating a new repository, adding files to the repository, staging and committing changes, and pushing your commit to the GitHub remote. Duration: 16min
24. Clone
A practical guide to cloning a GitHub repo - This lesson demonstrates how to clone a GitHub repo to your local machine using the Git command line tool. You'll learn how to navigate to your desired folder, use the git clone command, and open the cloned project in VS Code. Duration: 3min
25. Workshop
A challenging workshop to finish the "Buy Me A Coffee" Vyper project - This workshop builds on the previous lessons, guiding you to write enough tests to achieve 100% code coverage, sign up for Cyfr.in Profiles, push your code to GitHub, and add a new commit to your GitHub repo. Duration: 2min
26. Recap
A comprehensive recap of Mocassin Buy Me A Coffee project. The lesson covers formatting code, using constants and immutables, understanding storage, deploying to a forked network, writing and running unit and staging tests, and the importance of keeping a deployment history. Duration: 5min

Course Overview

About the course

What you'll learn

Python basics

Introduction to Web3.py

Introduction to Titanoboa

Introduction to Moccasin

How to create an ERC-20

How to test Python code and Vyper smart contract

How to deploy Vyper smart contracts on ZKsync using Moccasin

Course Description

Who is this course for?

  • Software engineers
  • Web3 developers
  • Finance developers
  • AI developers
  • Everyone interested in learning Python and smart contracts

Potential Careers

Smart Contract Auditor

$100,000 - $200,000 (avg. salary)

On-chain Data Analyst

$59,000 - $139,000 (avg. salary)

DeFi Developer

$75,000 - $200,000 (avg. salary)

Smart Contract Engineer

$100,000 - $150,000 (avg. salary)

Web3 developer

$60,000 - $150,000 (avg. salary)

Web3 Developer Relations

$85,000 - $125,000 (avg. salary)

Meet your instructors

Patrick Collins

Patrick Collins

Founder at Cyfrin

Web3 engineer, educator, and Cyfrin co-founder. Patrick's smart contract development and security courses have helped hundreds of thousands of engineers kickstarting their careers into web3.

Last updated on April 21, 2025

Testimonials

Students Reviews

Read what our students have to say about this course.

Chainlink

Chainlink

Chainlink

Gustavo Gonzalez

Gustavo Gonzalez

Solutions Engineer at OpenZeppelin

Francesco Andreoli

Francesco Andreoli

Lead Devrel at Metamask

Albert Hu

Albert Hu

DeForm Founding Engineer

Radek

Radek

Senior Developer Advocate at Ceramic

Boidushya

Boidushya

WalletConnect

Idris

Idris

Developer Relations Engineer at Axelar