ape-vyper: Ape Framework plugin for compiling Vyper contracts
Project description
Quick Start
Ape compiler plugin around VVM
Dependencies
- python3 version 3.10 up to 3.12.
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 pyproject.toml file:
[tool.vyper.version]
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:
[tool.ape.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:
[[tool.ape.dependencies]]
name = "VyperVoting"
github = "vyperlang/vyper"
contracts_folder = "examples/voting/"
version = "v0.3.8"
[tool.ape.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:
[tool.ape.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
VVM CLI
You can install versions of Vyper using the ape vyper vvm CLI tools.
List installed versions using:
ape vyper vvm list
To list the available Vyper versions, do:
ape vyper vvm list --available
Install more versions using the command:
ape vyper vvm install 0.3.7 0.3.10
Custom Output Format
To customize Vyper's output format (like the native -f flag), you can configure the output format:
For example, to only get the ABI, do:
[tool.ape.vyper]
output_format = ["abi"]
To do this using the CLI only (adhoc), use the following command:
ape compile --config-override '{"vyper": {"output_format": ["abi"]}}'
Solc JSON Format
ape-vyper supports the socl_json format.
To use this format, configure ape-vyper like:
[tool.ape.vyper]
output_format = ["solc_json"]
Note: Normally, in Vyper, you cannot use solc_json with other formats.
However, ape-vyper handles this by running separately for the solc_json request.
Be sure to use the --force flag when compiling to ensure you get the solc JSON output.
ape compile file_needing_solc_json_format.vy -f
To get a dependency source file in this format, configure and compile the dependency.
[[tool.ape.dependencies]]
name = "my_dep"
config_override = { "vyper" = { "output_format" = ["solc_json"] } }
And then run:
ape pm compile --force
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ape_vyper-0.8.10.tar.gz.
File metadata
- Download URL: ape_vyper-0.8.10.tar.gz
- Upload date:
- Size: 72.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5f077f2a00eb3d66867cd08f33562030757d919f27eab4115ad3b59a56c181c2
|
|
| MD5 |
8ff01a08b5b9d49c25476271c9551dc0
|
|
| BLAKE2b-256 |
895b107f98e51e1e860e661314657d73ae49967c42566a646ea2f10de992827f
|
Provenance
The following attestation bundles were made for ape_vyper-0.8.10.tar.gz:
Publisher:
publish.yaml on ApeWorX/ape-vyper
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ape_vyper-0.8.10.tar.gz -
Subject digest:
5f077f2a00eb3d66867cd08f33562030757d919f27eab4115ad3b59a56c181c2 - Sigstore transparency entry: 826963745
- Sigstore integration time:
-
Permalink:
ApeWorX/ape-vyper@414e993b64deeac14d84ca191e7b70fdc26ffe58 -
Branch / Tag:
refs/tags/v0.8.10 - Owner: https://github.com/ApeWorX
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@414e993b64deeac14d84ca191e7b70fdc26ffe58 -
Trigger Event:
release
-
Statement type:
File details
Details for the file ape_vyper-0.8.10-py3-none-any.whl.
File metadata
- Download URL: ape_vyper-0.8.10-py3-none-any.whl
- Upload date:
- Size: 47.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9b4af6ac22caa42effdb96bb5fc9b41eafbbd473218815195fdefe4bc8742d2a
|
|
| MD5 |
80576c67dc6555d6af8c628c7dab9870
|
|
| BLAKE2b-256 |
b05988e385a2443e6c65c4c13c9b008b173e43c6037f5fd64c6e2f6260e9c931
|
Provenance
The following attestation bundles were made for ape_vyper-0.8.10-py3-none-any.whl:
Publisher:
publish.yaml on ApeWorX/ape-vyper
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ape_vyper-0.8.10-py3-none-any.whl -
Subject digest:
9b4af6ac22caa42effdb96bb5fc9b41eafbbd473218815195fdefe4bc8742d2a - Sigstore transparency entry: 826963792
- Sigstore integration time:
-
Permalink:
ApeWorX/ape-vyper@414e993b64deeac14d84ca191e7b70fdc26ffe58 -
Branch / Tag:
refs/tags/v0.8.10 - Owner: https://github.com/ApeWorX
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@414e993b64deeac14d84ca191e7b70fdc26ffe58 -
Trigger Event:
release
-
Statement type: