Vyper for Beginners — Toolkit

Welcome back to Vyper for Beginners! This lesson will cover my recommended toolkit for writing, compiling, testing, and finally deploying a Vyper contract.

It’s no surprise that the most fully-featured toolkit for Vyper is written in Python. Brownie is, by their own description:

A Python-based development and testing framework for smart contracts targeting the Ethereum Virtual Machine.

For those familiar with the Ethereum development ecosystem, Brownie is the Python equivalent of Truffle (written in JavaScript). Both tools allow you to write, test, deploy and debug smart contracts.

Brownie has native support for both Vyper and Solidity contracts, so you don’t need to use a separate toolkit as you move between the languages.

Vyper for Beginners

Development Platform

I do all of my development using Linux, and all of my installation instructions here will be written with my primary workstation as the example. I am using Pop_OS (a Ubuntu derivative) version 21.10.

If you choose to use a different Linux distribution or a different operating system entirely, that is OK. Brownie and Vyper are cross-platform and will work on any system that offers a recent version of Python 3.

If you cannot dedicated a machine to Linux development, I recommend installing it in a virtual machine (VirtualBox or similar). The advantage to using a VM for development is that you can maintain a platform compatibility with this guide without affecting your primary workstation.

Providing a complete installation guide for multiple operating systems is beyond the scope of this lesson series, so if you decide to deviate from my recommendations please be aware that you may run into issues that I cannot solve.

I am using the following package versions:

  • Python version 3.9.7
  • Pip version 20.3.4 (installed via apt)
  • Brownie version 1.18.1
  • Vyper version 0.3.2 (installed via pip+git, more on this later)

I do my development using VSCode version 1.65.2 and an assortment of helpful extensions:

  • Pylance v2022.3.3
  • Python IntelliSense v2022.2.1924087327
  • Vyper v0.0.13

Formatting Conventions

Whenever I include monospace-formatted text inside a normal paragraph, I am highlighting a command, variable, or some programming element relevant to the topic.

Whenever I show a block of text inside a code block, it signifies some program output or input that I want you to either enter on your machine or review from mine.

This is an example of a code block.

It may contain new lines and special characters, but it will be continuous from top to bottom.

I will include shell commands from a Linux / Mac / Windows terminal in a code block. Whenever you see a code block with any of these symbols, you can be reasonably assured that I’m showing you a shell command:

$
#
>>>

My local workstation is named hades, and my user is named devil so you will frequently see code blocks that look like this:

devil@hades:~$ some_commmand

This signifies that I’m pasting the actual input and output from a terminal. Yours may look different, and I expect that you’ll choose a different login and machine name (though I do love imitation, very flattering).

Installation

The first thing you will need is a functional Python installation, plus the development libraries needed to install the remainder of the tools via pip (the Package Installer for Python).

Open a terminal and execute the following:

devil@hades:~$ sudo apt install python3 python3-dev python3-pip
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
[...]

This will install the necessary base packages from apt, then we can use pip for the remainder.

devil@hades:~$ pip install eth-brownie 
[...]
Installing collected packages: eth-brownie
Successfully installed eth-brownie-1.18.1

Now we install Vyper, except via a special command. Vyper 0.3.2 has not been released, but it is the first version to offer support for Dynamic Arrays. This is a feature we want, so until it has been officially packaged and released, we will install it via a special pip option, which retrieves and compiles it from the most recent version available on GitHub.

devil@hades:~$ pip install git+https://github.com/vyperlang/vyper
Collecting git+https://github.com/vyperlang/vyper
  Cloning https://github.com/vyperlang/vyper to /tmp/pip-req-build-py99gbr8
  Running command git clone -q https://github.com/vyperlang/vyper /tmp/pip-req-build-py99gbr8
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
    Preparing wheel metadata ... done
Requirement already satisfied: semantic-version==2.8.5 in ./.local/lib/python3.9/site-packages (from vyper==0.3.2+commit.5dcd8a78) (2.8.5)
Requirement already satisfied: asttokens==2.0.5 in ./.local/lib/python3.9/site-packages (from vyper==0.3.2+commit.5dcd8a78) (2.0.5)
Requirement already satisfied: pycryptodome<4,>=3.5.1 in ./.local/lib/python3.9/site-packages (from vyper==0.3.2+commit.5dcd8a78) (3.14.1)
Requirement already satisfied: wheel in /usr/lib/python3/dist-packages (from vyper==0.3.2+commit.5dcd8a78) (0.34.2)
Requirement already satisfied: six in /usr/lib/python3/dist-packages (from asttokens==2.0.5->vyper==0.3.2+commit.5dcd8a78) (1.16.0)
Building wheels for collected packages: vyper
  Building wheel for vyper (PEP 517) ... done
  Created wheel for vyper: filename=vyper-0.3.2+commit.5dcd8a78-py3-none-any.whl size=256175 sha256=2ec85e5554580d4f14ae523509b923bbb1f3b14346614797810037a015234b8a
  Stored in directory: /tmp/pip-ephem-wheel-cache-vac30sqr/wheels/1f/6f/95/94488289c0848a7fe536f487b6b6ff1b3cafced9a34e5710d0
Successfully built vyper
Installing collected packages: vyper
  Attempting uninstall: vyper
    Found existing installation: vyper 0.3.1
    Uninstalling vyper-0.3.1:
      Successfully uninstalled vyper-0.3.1
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
eth-brownie 1.18.1 requires vyper==0.3.1, but you have vyper 0.3.2+commit.5dcd8a78 which is incompatible.
Successfully installed vyper-0.3.2+commit.5dcd8a78

Please do not be intimidated by all of this console output. Pip is telling us here that it built Vyper version 0.3.2 from the GitHub source (as of the commit tagged 5dcd8a78), then detected an existing installation of 0.3.1, which is uninstalled and replaced with our 0.3.2 version. It offers a helpful warning that eth-brownie requires an exact version of 0.3.1, but ours does not match.

This will be resolved in the future, so if you’re reading this after Vyper 0.3.2 has been released, simply ignore all of this.

A Simple Brownie Project

To create a directory for your Brownie project, create it using a file explorer or on the terminal using mkdir directory_name. Then, inside the terminal, move into the directory and create the project structure using Brownie:

devil@hades:~$ mkdir vyper_for_beginners
devil@hades:~$ cd vyper_for_beginners/
devil@hades:~/vyper_for_beginners$ brownie init
Brownie v1.18.1 - Python development framework for Ethereum

SUCCESS: A new Brownie project has been initialized at /home/devil/vyper_for_beginners

Next Steps

In the next lesson I will cover the requirements for a Vyper smart contract, discuss the basic variable types that Vyper offers, compare the control and logic structures against Python, and demonstrate how to write, test, and deploy a very simple “Hello World” contract in Vyper.

Photo of author

Written By BowTiedDevil

Degenerate coder, open source software maximalist, engineer, turbo autist.

Disclosure

This article may contain links to third-party websites or other content for information purposes. BowTiedIsland may receive a commission at no cost to you if you purchase a product after clicking one of these links. The Third-Party Sites are not under the control of BowTiedIsland, and BowTiedIsland is not responsible for the content of any Third-Party Site. All information contained herein is the opinion of the writer and does not constitute financial advice. We aim to act as a neutral third party and aid in your research and analysis.


The Jungle


Crypto, Investing, and E-Commerce with BowTied Bull

The future is internet based, therefore we have a triangle based approach with crypto, e-commerce business making and Investing in traditional assets

Break Into a 6-Figure Wall Street Career

Learn how to efficiently break into investment banking and private equity. The Banker’s Bible is a definitive resource that offers an   A-Z blueprint and also gives you 24/7 access to real finance professionals. 

Fitness With BowTiedOx

BowTiedOx provides you a place to find all of his latest programs and guides.

Weekly newsletters that cover fitness, health, and mindset, all grounded in the fundamentals of physiology.

Media Production with BowTied Turkey and BowTied Tamarin

Video is no longer optional.

Don’t get left behind.

Your brand deserves professional videos to engage your audience.

Art & Graphic Design with BowTied Patriot

BowTied Patriot is a graphic artist who specializes in photography, mixed medium custom artwork, and NFT creation.

Join BowTiedPatriot as he dives into making Art in Web3.0 and The Metaverse.

Cooking with BowTiedOctopod

Learn secrets from a fine dining chef for maximum flavor and time-saving efficiency

Newsletters on Ingredients, Techniques and Flavor hacks that will have you eating better. We will never eat bugs!

Meme Warfare with DgenFren

Increase your online engagement, organically influence narratives, and build your online persona by using marketing that your target audience actually wants: memes.

Learn How to Sell with BowTiedSalesGuy

Sales is one of the most transferrable life skills, yet few know how to actually sell.

Traditional sales tactics don’t cut it in today’s hyper competitive world.

Learn the secrets from a Chad Salesman and change your Life forever.

Ecommerce with BowTiedOpossum

Learn the skills to start and build your first online business.

Want to build a business that travels with you?

Learn from an industry veteran that has worked on and with brands you already know.