5/5
## Modules and Uses Statement Let's talk about modules and the uses statement in Vyper. We've already gone over how to create a module. There's just one more thing to talk about. ### Initializing a Module With Dependencies Sometimes, you'll encounter a module that uses other modules. Vyper's module system allows this. However, it requires us to explicitly declare access to the imported module's state. We will use the special "walrus" syntax to initialize the module that we're going to use. We'll import `ownable_2step` and then we'll say `initializes: ownable`. This is the walrus syntax. ```python import ownable_2step initializes: ownable ``` Next, we'll initialize the `ownable_2step` module, and we'll have to use the walrus operator for this. Remember that this syntax might seem weird. ```python initializes: ownable_2step[ownable] := ownable ``` This is just saying that the `ownable_2step` module is initialized by this module. This might be a little confusing, but it'll make sense once you see it in practice. ### Workshop Here's a workshop for you: 1. Add a second module to `five_more`. We've already imported `favorites`, and we've initialized `favorites`. ```python import favorites initializes: favorites ``` 2. Try to export functions from two different modules. ### The Uses Statement This is one area we'll use an AI. You can go ahead and ask AI questions to solve this problem. Remember, there is a `uses` statement in Vyper. You can read through the docs and understand how to use it to make a contract with a `uses` statement. ```python import ownable uses: ownable ``` We'll go over this more later in the course!
Let's talk about modules and the uses statement in Vyper.
We've already gone over how to create a module. There's just one more thing to talk about.
Sometimes, you'll encounter a module that uses other modules.
Vyper's module system allows this. However, it requires us to explicitly declare access to the imported module's state.
We will use the special "walrus" syntax to initialize the module that we're going to use.
We'll import ownable_2step
and then we'll say initializes: ownable
. This is the walrus syntax.
Next, we'll initialize the ownable_2step
module, and we'll have to use the walrus operator for this. Remember that this syntax might seem weird.
This is just saying that the ownable_2step
module is initialized by this module. This might be a little confusing, but it'll make sense once you see it in practice.
Here's a workshop for you:
Add a second module to five_more
. We've already imported favorites
, and we've initialized favorites
.
Try to export functions from two different modules.
This is one area we'll use an AI. You can go ahead and ask AI questions to solve this problem.
Remember, there is a uses
statement in Vyper. You can read through the docs and understand how to use it to make a contract with a uses
statement.
We'll go over this more later in the course!
A detailed guide to using modules and dependencies in Vyper. The lesson covers initializing a module with dependencies, the walrus operator, and the uses statement. It includes a workshop with four challenges for practice.
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 August 11, 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 August 11, 2025