1/5
## Stablecoin Project Setup We are going to create a new repo for it. ```bash mkdir mox-stablecoin-cu ``` Then we will open this directory in Visual Studio Code: ```bash code mox-stablecoin-cu ``` Then we will create a new folder called "mox-init." ```bash mox init --vscode --pyproject ``` We will delete everything in the "script" folder. Next, we will open "README.md" to define what we are building. ``` # Stablecoin ## Introduction 1. Users can deposit $200 of ETH 2. They can then mint $50 of Stablecoin 1. This means they will have a 4/1 ratio of collateral to stablecoin (200/50 = 4/1) 2. We will set a required collateral ratio of 2/1 3. If the price of ETH drops, for example to $50, others should be able to liquidate those users! ``` We should use AI to assist us in understanding the finance concepts involved in this lesson. Now we are ready to start building our stablecoin. We are going to create our actual stablecoin. We will call this "decentralized_stable_coin.vy." ``` # pragma version 0.4.1 @license MIT @author You @title Decentralized Stable Coin @dev Follows the ERC20 token standard ``` We will use the "snekmate" package to assist us. ```bash mox install snekmate ``` We can now import the necessary functions from "snekmate." ``` from snekmate.tokens import erc20 from snekmate.auth import ownable as ow ``` We will add the necessary functions. ``` initializes: ow initializes: erc20(ownable = ow) @deploy def init(): ow.init() erc20.init(name = "Decentralized Stable Coin", symbol = "DSC", decimals = 18) ``` We will define the constants for our stablecoin. ``` NAME: constant(String[25]) = "Decentralized Stable Coin" SYMBOL: constant(String[5]) = "DSC" DECIMALS: constant(uint8) = 18 EIP_712_VERSION: constant(String[20]) = "1" ``` We will export our stablecoin using "IERC20" and other functions. ``` exports: ( erc20.IERC20, erc20.burn_from, erc20.mint, erc20.set_minter, ow.owner, ow.transfer_ownership ) ``` The final code is as follows: ``` # pragma version 0.4.1 @license MIT @author You @title Decentralized Stable Coin @dev Follows the ERC20 token standard from snekmate.tokens import erc20 from snekmate.auth import ownable as ow initializes: ow initializes: erc20(ownable = ow) exports: ( erc20.IERC20, erc20.burn_from, erc20.mint, erc20.set_minter, ow.owner, ow.transfer_ownership ) NAME: constant(String[25]) = "Decentralized Stable Coin" SYMBOL: constant(String[5]) = "DSC" DECIMALS: constant(uint8) = 18 EIP_712_VERSION: constant(String[20]) = "1" @deploy def init(): ow.init() erc20.init(NAME, SYMBOL, DECIMALS, NAME, EIP_712_VERSION) ```courses\advanced-moccasin\3-moccasin-stablecoin\3-setup\+page.md You are a supervisor checking the quality of a written lesson generated by a technical writing system. You are tasked with ensuring the written lesson is high quality and meets certain criteria. Important criteria: 1. Include ALL significant topics covered 2. If something specific such a technique or methodology is mentioned, this is very important to include 3. ALL code should be formatted on new lines as: ```javascript commands ``` 4. DO NOT include diagrams or images, but absolutely provide code blocks from the lesson. 6. ALWAYS format your response in markdown 7. DO NOT use H1s 8. ONLY output the written lessons 9. Use first person plural (we, us) when appropriate 10. DO NOT transcribe the video verbatim. Written lesson should be bespoke 11. DO NOT deviate from the video content 12. ONLY include code being shown or written in the video 13. Terminal commands being run must be formatted on new lines as: ```bash commands ``` Based on the criteria above, ensure the provided lesson matches what's required. Check the major topics in the written lesson vs the video content. If anything in the written lesson ISN'T in the video, remove it. If anything in the video ISN'T in the written lesson, add it.
A beginner's guide to building a decentralized stablecoin on the Vyper blockchain. The lesson covers setting up the development environment, creating a stablecoin contract, and exporting functions like 'mint' and 'burn' for use in another contract.
Previous lesson
Previous
Next lesson
Next
Give us feedback
Vyper 0.4.1
Last updated on April 21, 2025
Course Overview
About the course
How to build a DeFi stablecoin and customized NFT
How to deploy your smart contract on ZKsync with Moccasin
Advanced testing techniques like stateful and stateless Python fuzzing
How to write algorithmic trading scripts in Python
Hashing signatures, proxies, delegate calls, upgradable contracts, random numbers, and more!
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)
Last updated on April 21, 2025
Duration: 2h 21min
Duration: 1h 58min
Duration: 2h 55min
Duration: 1h 55min
Duration: 46min
Course Overview
About the course
How to build a DeFi stablecoin and customized NFT
How to deploy your smart contract on ZKsync with Moccasin
Advanced testing techniques like stateful and stateless Python fuzzing
How to write algorithmic trading scripts in Python
Hashing signatures, proxies, delegate calls, upgradable contracts, random numbers, and more!
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)
Last updated on April 21, 2025