5/5
## Vyper Debug Statements We've been using the `boa` library and the `boa` library is great for us, but now let's talk about the `print` function. Let's say that we want to be able to see the `msg.sender` when we call the `store` function. So, we can actually put a print statement right in our Vyper code! Now, we need to be very careful. This is specifically for debugging, and we don't want to have these `print` statements in real smart contracts. We'll add this line to the `store` function, `print(msg.sender)`. ```python def store(favorite_number: uint256): print(msg.sender) self.my_favorite_number = favorite_number ``` So, what we'll do is we'll run our code. First, we'll clear out our terminal: ```bash clear ``` And then we'll run our Python script: ```bash python deploy_favorites_pyevm.py ``` We get a warning telling us `print` should only be used for debugging. This is because we should not deploy print statements to the blockchain. But, even though it's a waste of gas and it might result in some weird oddities, we can see that we get the sender address.
We've been using the boa
library and the boa
library is great for us, but now let's talk about the print
function. Let's say that we want to be able to see the msg.sender
when we call the store
function. So, we can actually put a print statement right in our Vyper code!
Now, we need to be very careful. This is specifically for debugging, and we don't want to have these print
statements in real smart contracts. We'll add this line to the store
function, print(msg.sender)
.
So, what we'll do is we'll run our code. First, we'll clear out our terminal:
And then we'll run our Python script:
We get a warning telling us print
should only be used for debugging. This is because we should not deploy print statements to the blockchain.
But, even though it's a waste of gas and it might result in some weird oddities, we can see that we get the sender address.
A practical guide to using Vyper debug statements - Learn how to add print statements in Vyper code to track and debug function calls. Explore the warning message that appears when deploying contracts with print statements and discover how TitanoBoa can help.
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