Hello, and welcome to another episode of… oh wait, wrong channel.
Lets start over then!
Tired of contract Solidity is SoVerbose, ICantTakeItAnymore, Etc { … }
? Yeah, me too. That’s why I decided to write EVM smart contracts with “the other” stack! LFG Vyper!
What’s Vyper? It’s a Pythonic Smart Contract Language for the EVM. def is_it_nicer_to_write() → bool: return True
It’s picking up attention thanks to some big DeFi projects (Hello Curve), and people looking beyond Solidity.
This post gives a brief overview of the ecosystem, and takes you from 0 to 100 faster than Usain Bolt.
So, how does this compare with the Solidity ecosystem? Here’s a very rough comparison table:
Now let’s quickly go through the main tools, so you know what’s what:
Vyper: as mentioned, it’s how you write the smart contracts. That means you’re gonna have the docs open all the time. Here’s a nice intro to learn how to write Vyper: the definitive 0 to 1 guide.
Brownie: the OG development and testing framework, actually written in python (but supports Solidity contracts).
ApeWorx: a newer alternative for developing contracts. While the focus is mainly on Vyper contracts, it also supports Solidity. Here’s a nice intro to Ape.
Ganache: also an OG tool, for spinning up your own node, and testing locally. Ganache is also agnostic to how your contracts are written.
It’s also worth mentioning Titanoboa, since it’s under the Vyper team’s umbrella, which is a very new Vyper interpreter with a bunch of features!
Ok, here we go. Start by ensuring you got an up to date python --version
installed (currently. anything >= 3.10 is new-ish).
Create a virtual environment, and activate it
python -m venv <my-project>
cd <my-project>
source bin/activate
then install ape and vyper using pip
pip install vyper eth-ape
freeze the packages cause it’s a good practice
pip freeze > requirements.txt
run ape --version
If you get an output with something like 0.6.10
, then great, you got ape running!
Now it’s time to start the ape project: ape init
Configure ape now, or later, up to you. If you do it now, you’ll want to familiarize with the docs
Now go and write some code
touch contracts/hello.vy
# and add this into hello.vy
@external
def hello() -> bool:
return True
Then you can ape compile -s
. Things will be successful if it outputs the deployment bytecode size.
Now you’re ready to learn the language and write Vyper contracts!
Once you’re done with the contracts, it’s time to test! Note: the Vyper docs talk about Brownie and Ethereum Tester, but I prefer using Ape - follow its docs.
Finally, time to run scripts to deploy things. Again, we use Ape for that.
You might want to deploy locally on a mainnet fork, I like using Foundry’s Anvil for that.
And that’s pretty much it, we’ve covered the basics to get started building with Vyper and Ape.
Many people have written about Vyper, and they did a better job than me. Check their stuff.
Need real time help? Join Vyper’s discord and Ape’s discord channels.