1/5
## Deploy Scripts Let's write a deployment script. We can create a function called: ```python def moccasin_main(): ``` We can then call another function within this one: ```python return deploy() ``` Let's create that function: ```python def deploy(): ``` We'll add a pass statement to the function for now. ```python pass ``` We'll also add an import statement at the top of the script. ```python from contracts import snek_token ``` We will import the *to_wei* function from *eth_utils* as well. ```python from eth_utils import to_wei ``` Let's assign an initial supply to our token in a variable called *INITIAL_SUPPLY* ```python INITIAL_SUPPLY = to_wei(1000, 'ether') ``` Now, let's get our contract: ```python snek_contract = snek_token.deploy(INITIAL_SUPPLY) ``` Lastly, let's add a print statement to see the address of our deployed contract. ```python print(f"Deployed SnekToken at: {snek_contract.address}") ``` Now, if we run our script, we should see our deployed contract address printed in the terminal. We can run our script from the terminal. ```bash mox run deploy ``` We can also run the script using the file path. ```bash mox run ./script/deploy.py ``` Both of these will output our contract address.
A comprehensive guide to deploying a Vyper smart contract using a Python deployment script with Moccasin. The lesson covers importing the contract, setting up the initial supply, and running the script to deploy the contract to a local blockchain.
Previous lesson
Previous
Next lesson
Next
Give us feedback
Course Overview
About the course
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
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 20min
Duration: 1h 51min
Duration: 58min
Duration: 2h 23min
Duration: 53min
Duration: 2h 24min
Duration: 28min
Duration: 1h 54min
Duration: 11min
Course Overview
About the course
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
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
Testimonials
Read what our students have to say about this course.
Chainlink
Chainlink
Gustavo Gonzalez
Solutions Engineer at OpenZeppelin
Francesco Andreoli
Lead Devrel at Metamask
Albert Hu
DeForm Founding Engineer
Radek
Senior Developer Advocate at Ceramic
Boidushya
WalletConnect
Idris
Developer Relations Engineer at Axelar