Vyper Smart Contract Compiler

0.4.3 · active · verified Thu Apr 16

Vyper is a Pythonic programming language for the Ethereum Virtual Machine (EVM), designed with security, auditability, and simplicity in mind. It provides a more constrained set of features compared to other EVM languages, aiming to reduce complexity and potential vulnerabilities. The current version is 0.4.3, with minor releases and release candidates occurring frequently, typically leading to stable minor versions every few months.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to programmatically compile a basic Vyper smart contract using the `compile_code` function. It specifies the desired output formats (bytecode and ABI) and an EVM version for compilation, then prints the resulting artifacts.

from vyper import compile_code

contract_code = '''
# @version ^0.4.0

# A simple Vyper contract

@external
def hello() -> String[100]:
    return "Hello, Vyper!"
'''

# Compile the contract to get bytecode, ABI, and other artifacts
compiled_artifacts = compile_code(
    contract_code,
    output_formats=['bytecode', 'abi'],
    evm_version='shanghai' # Specify EVM version for compatibility
)

print("Bytecode:", compiled_artifacts['bytecode'])
print("ABI:", compiled_artifacts['abi'])

view raw JSON →