Viper Support

Populus has support for the viper compiler (a python-like experimental programming language).


To install the viper compiler:

You will see the viper binary is now installed.

$ viper
usage: viper [-h] [-f {abi,json,bytecode,bytecode_runtime,ir}]
viper: error: the following arguments are required: input_file

To use viper as you compiler backend you have to configure you project.json file to support viper, this is done by placing a backend key in the compilation section of your project.json, as shown below:

    "version": "7",
    "compilation": {
        "contracts_source_dirs": ["./contracts"],
        "import_remappings": [],
        "backend": {
            "class": "populus.compilation.backends.ViperBackend"

This will set the populus framework to only pick up viper contracts in the configured contracts directories. Now that everything is configured you can create a viper greeter contract:

# contracts/Greeter.vy

greeting: bytes <= 20

def __init__():
    self.greeting = "Hello"

def setGreeting(x: bytes <= 20):
    self.greeting = x

def greet() -> bytes <= 40:
    return self.greeting

And run the default populus tests: