# Smart Contracting with Vyper and Ape

By [omnifient](https://paragraph.com/@omnifient) · 2023-05-28

---

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.

(Brief) Ecosystem Comparison
----------------------------

So, how does this compare with the Solidity ecosystem? Here’s a very rough comparison table:

![Note: these things are not very clean to categorize since the tools can do many things and/or span through different ecosystems.](https://storage.googleapis.com/papyrus_images/36575df3da0dbc56dd740311dec970bdcbaf504941e0c111c0fe244b9fbc3002.png)

Note: these things are not very clean to categorize since the tools can do many things and/or span through different ecosystems.

(Brief) Ecosystem Overview
--------------------------

Now let’s quickly go through the main tools, so you know what’s what:

*   [Vyper](https://github.com/vyperlang/vyper): as mentioned, it’s how you write the smart contracts. That means you’re gonna have the [docs](https://docs.vyperlang.org/en/stable/) open all the time. Here’s a nice intro to learn how to write [Vyper: the definitive 0 to 1 guide](https://mirror.xyz/%F0%9F%91%85%F0%9F%8C%88%F0%9F%91%85.eth/B6vH4y6a_dD8O9ODWt_JsjnTZECsXj0yDEDzh_QCjjM).
    
*   [Brownie](https://github.com/eth-brownie/brownie): the OG development and testing framework, actually written in python (but supports Solidity contracts).
    
*   [ApeWorx](https://www.apeworx.io/): 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](https://blog.chain.link/apeworx-python-vyper/).
    
*   [Ganache](https://github.com/trufflesuite/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](https://github.com/vyperlang/titanoboa), since it’s under the Vyper team’s umbrella, which is a very new Vyper interpreter with a bunch of features!

Getting started quickly
-----------------------

Ok, here we go. Start by ensuring you got an up to date `python --version` installed (currently. anything >= 3.10 is new-ish).

1.  Create a virtual environment, and activate it
    
    `python -m venv <my-project>`
    
    `cd <my-project>`
    
    `source bin/activate`
    
2.  then install ape and vyper using pip `pip install vyper eth-ape`
    
3.  freeze the packages cause it’s a good practice `pip freeze > requirements.txt`
    
4.  run `ape --version`
    

If you get an output with something like `0.6.10`, then great, you got ape running!

1.  Now it’s time to start the ape project: `ape init`
    
2.  Configure ape now, or later, up to you. If you do it now, you’ll want to familiarize with the [docs](https://docs.apeworx.io/ape/stable/userguides/quickstart.html)
    
    1.  Edit the `ape-config.yaml` with [plugins](https://academy.apeworx.io/tutorials/plugins), [networks](https://docs.apeworx.io/ape/stable/userguides/networks.html), etc.
        
    2.  Then run `ape plugins install .` to install the plugins
        
3.  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](http://docs.vyperlang.org/) 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.

[https://docs.apeworx.io/ape/stable/userguides/testing.html](https://docs.apeworx.io/ape/stable/userguides/testing.html)

Finally, time to run scripts to deploy things. Again, we use Ape for that.

[https://docs.apeworx.io/ape/stable/userguides/scripts.html](https://docs.apeworx.io/ape/stable/userguides/scripts.html)

You might want to deploy locally on a mainnet fork, I like using [Foundry’s Anvil](https://github.com/foundry-rs/foundry/tree/master/anvil) for that.

And that’s pretty much it, we’ve covered the basics to get started building with Vyper and Ape.

Other Resources
---------------

Many people have written about Vyper, and they did a better job than me. Check their stuff.

[https://github.com/zcor/vyper-dev](https://github.com/zcor/vyper-dev)

Need real time help? Join [Vyper’s discord](https://discord.gg/6tw7PTM7C2) and [Ape’s discord](https://discord.com/invite/apeworx) channels.

---

*Originally published on [omnifient](https://paragraph.com/@omnifient/smart-contracting-with-vyper-and-ape)*
