Skip to main content

Plugin for Ape Ethereum Framework for compiling Vyper contracts

Project description

Quick Start

Ape compiler plugin around VVM

Dependencies

Installation

via pip

You can install the latest release via pip:

pip install ape-vyper

via setuptools

You can clone the repository and use setuptools for the most up-to-date version:

git clone https://github.com/ApeWorX/ape-vyper.git
cd ape-vyper
python3 setup.py install

Quick Usage

First, place Vyper contract source files (files with extension .vy) in your Ape project's contracts folder. An example Vyper contract can be found here. Then, from your root Ape project folder, run the command:

ape compile

The .vy files in your project will compile into ContractTypes that you can deploy and interact with in Ape.

Contract Flattening

For ease of publishing, validation, and some other cases it's sometimes useful to "flatten" your contract into a single file. This combines your contract and any imported interfaces together in a way the compiler can understand. You can do so with a command like this:

ape vyper flatten contracts/MyContract.vy build/MyContractFlattened.vy

[!WARNING] This feature is experimental. Please report any bugs you find when trying it out.

Compiler Version

By default, the ape-vyper plugin uses version pragma for version specification. However, you can also configure the version directly in your ape-config.yaml file:

vyper:
  version: 0.3.7

EVM Versioning

By default, ape-vyper will use whatever version of EVM rules are set as default in the compiler version that gets used, or based on what the #pragma evm-version ... pragma comment specifies (available post-v0.3.10). Sometimes, you might want to use a different version, such as deploying on Arbitrum or Optimism where new opcodes are not supported yet. If you want to require a different version of EVM rules to use in the configuration of the compiler, set it in your ape-config.yaml like this:

vyper:
  evm_version: paris

NOTE: The config value chosen will not override if a pragma is set in a contract.

Interfaces

You can not compile interface source files directly. Thus, you must place interface files in a directory named interfaces in your contracts_folder e.g. contracts/interfaces/IFace.vy. Then, these files can be imported in other .vy sources files via:

import interfaces.IFace as IFace

Alternatively, use JSON interfaces from dependency contract types by listing them under the import_remapping key:

# Use `voting` example contracts from Vyperlang repo.
dependencies:
  - name: VyperVoting
    github: vyperlang/vyper
    contracts_folder: examples/voting/
    version: v0.3.8

# Automatically allow importing voting contracts in your project.
vyper:
  import_remapping:
    - "voting=VyperVoting@v0.3.8"

Import the voting contract types like this:

# @version 0.3.10

import voting.ballot as ballot

Decimals

To use decimals on Vyper 0.4, use the following config:

vyper:
  enable_decimals: true

Pragmas

Ape-Vyper supports Vyper 0.3.10's new pragma formats

Version Pragma

#pragma version 0.3.10

EVM Version Pragma

#pragma evm-version paris

Optimization Pragma

#pragma optimize codesize

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ape-vyper-0.8.7.tar.gz (68.7 kB view details)

Uploaded Source

Built Distribution

ape_vyper-0.8.7-py3-none-any.whl (43.7 kB view details)

Uploaded Python 3

File details

Details for the file ape-vyper-0.8.7.tar.gz.

File metadata

  • Download URL: ape-vyper-0.8.7.tar.gz
  • Upload date:
  • Size: 68.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.15

File hashes

Hashes for ape-vyper-0.8.7.tar.gz
Algorithm Hash digest
SHA256 595e797147e59afa1662e77aa6976e80eacb6d945a4c5e0c3af8d8f22bfc87cd
MD5 14b592e03ef573e01dd7b6a2e36eec4d
BLAKE2b-256 062a50afa11243e4c426990f1f449af1eaeb8d833c838bbdfa18583b3513764b

See more details on using hashes here.

File details

Details for the file ape_vyper-0.8.7-py3-none-any.whl.

File metadata

  • Download URL: ape_vyper-0.8.7-py3-none-any.whl
  • Upload date:
  • Size: 43.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.15

File hashes

Hashes for ape_vyper-0.8.7-py3-none-any.whl
Algorithm Hash digest
SHA256 b477d5325948a6982b23b426b671c598e5935bf4f107bc8d017fdf2fff6f595d
MD5 4eb678b0573995f0763697c8f7f1f619
BLAKE2b-256 00f13a9f5be9d5cab6adf93df55ea4a0df3e63e407f8ece1b7f1acc8aca30f9f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page