{"id":9405,"library":"vyper","title":"Vyper Smart Contract Compiler","description":"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.","status":"active","version":"0.4.3","language":"en","source_language":"en","source_url":"https://github.com/vyperlang/vyper","tags":["blockchain","ethereum","smart-contract","compiler","evm","web3"],"install":[{"cmd":"pip install vyper","lang":"bash","label":"Install Vyper"}],"dependencies":[],"imports":[{"note":"The primary programmatic compilation function `compile_code` is directly available from the top-level package.","wrong":"import vyper.compiler","symbol":"compile_code","correct":"from vyper import compile_code"}],"quickstart":{"code":"from vyper import compile_code\n\ncontract_code = '''\n# @version ^0.4.0\n\n# A simple Vyper contract\n\n@external\ndef hello() -> String[100]:\n    return \"Hello, Vyper!\"\n'''\n\n# Compile the contract to get bytecode, ABI, and other artifacts\ncompiled_artifacts = compile_code(\n    contract_code,\n    output_formats=['bytecode', 'abi'],\n    evm_version='shanghai' # Specify EVM version for compatibility\n)\n\nprint(\"Bytecode:\", compiled_artifacts['bytecode'])\nprint(\"ABI:\", compiled_artifacts['abi'])","lang":"python","description":"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."},"warnings":[{"fix":"Consult the official Vyper release notes (docs.vyperlang.org/en/latest/release-notes.html) for specific upgrade instructions and breaking changes.","message":"Vyper adheres to a `0.x.x` versioning scheme, meaning breaking changes can occur in minor releases. Always review release notes when upgrading between `0.X.x` versions (e.g., from 0.3.x to 0.4.x).","severity":"breaking","affected_versions":"<1.0.0"},{"fix":"Always explicitly specify the target EVM version using the `evm_version` parameter in `compile_code` or the `--evm-version` CLI flag to ensure consistent bytecode across environments.","message":"The default EVM version targeted by the compiler can change in minor releases (e.g., to 'prague' in v0.4.3). This might affect bytecode generation and compatibility with specific chain deployments if not explicitly handled.","severity":"breaking","affected_versions":"All versions"},{"fix":"Ensure your environment uses a compatible Python version (e.g., `python3.10` or `python3.11`). Use `pyenv` or `conda` for managing Python versions if necessary.","message":"Vyper requires Python 3.10 or higher, but strictly less than Python 4.0. Running with an unsupported Python version will lead to installation or runtime errors.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always use the latest stable version of Vyper to benefit from critical security patches. Regularly check the official Vyper GitHub for security advisories.","message":"Recent releases (e.g., v0.4.1) have included security-related fixes for low-to-moderate severity vulnerabilities. Older versions may contain known security flaws.","severity":"breaking","affected_versions":"<0.4.1"},{"fix":"Avoid using experimental features in production. If used for development, be aware of potential instabilities and thoroughly test generated bytecode.","message":"Experimental compiler features, such as the `--venom` or `--experimental-codegen` flags (aliases), are subject to rapid change, may contain bugs, or produce unoptimized/unexpected bytecode. They are not recommended for production deployments.","severity":"gotcha","affected_versions":"All versions with experimental features"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Run `pip install vyper` to install the library.","cause":"The Vyper library has not been installed in the current Python environment.","error":"ModuleNotFoundError: No module named 'vyper'"},{"fix":"Review the Vyper contract code against the official Vyper documentation for the specific version you are using. Vyper has a minimalist design, so many Solidity features are not present.","cause":"There is a syntax error or an attempt to use a non-existent keyword or feature in your Vyper contract code.","error":"SyntaxException: line X:X 'some_invalid_keyword' is not allowed"},{"fix":"Switch your Python environment to a compatible version (e.g., 3.10, 3.11, 3.12). You can use `pyenv install 3.12.0 && pyenv local 3.12.0` or create a new virtual environment with the correct Python version.","cause":"You are attempting to run Vyper with an unsupported Python version. Vyper typically requires Python 3.10+ but less than 4.","error":"ValueError: Vyper does not support python version 3.9.x (or similar for other unsupported versions)"},{"fix":"Ensure that the `output_formats` list explicitly includes all the keys you intend to access (e.g., `['bytecode', 'abi', 'ast_dict']`). Check for compilation errors if outputs are still missing.","cause":"The specified `output_formats` in `compile_code` did not include the key you are trying to access, or compilation failed silently without producing all artifacts.","error":"KeyError: 'bytecode' (or 'abi') when accessing compiled_artifacts"}]}