Viper Support

Populus has support for the viper compiler. Viper is a python-like experimental programming language.

Known limitations

Viper requires Python 3.6 or above.


To install the compiler:

pip install

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 it as your compiler backend the project.json file must be modified. Place a backend key in the compilation section, as shown below:

    "version": "8",
    "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/

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: