# Quick Start
Ape compiler plugin around [VVM](https://github.com/vyperlang/vvm)
## Dependencies
- [python3](https://www.python.org/downloads) version 3.10 up to 3.12.
## Installation
### via `pip`
You can install the latest release via [`pip`](https://pypi.org/project/pip/):
```bash
pip install ape-vyper
```
### via `setuptools`
You can clone the repository and use [`setuptools`](https://github.com/pypa/setuptools) for the most up-to-date version:
```bash
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](https://vyper.readthedocs.io/en/stable/vyper-by-example.html).
Then, from your root Ape project folder, run the command:
```bash
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:
```bash
ape vyper flatten contracts/MyContract.vy build/MyContractFlattened.vy
```
> \[!WARNING\]
> This feature is experimental. Please [report any bugs](https://github.com/ApeWorX/ape-solidity/issues/new?assignees=&labels=bug&projects=&template=bug.md) 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:
```yaml
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:
```yaml
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:
```python
import interfaces.IFace as IFace
```
Alternatively, use JSON interfaces from dependency contract types by listing them under the `import_remapping` key:
```yaml
# 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:
```python
# @version 0.3.10
import voting.ballot as ballot
```
### Decimals
To use decimals on Vyper 0.4, use the following config:
```yaml
vyper:
enable_decimals: true
```
### Pragmas
Ape-Vyper supports Vyper 0.3.10's [new pragma formats](https://github.com/vyperlang/vyper/pull/3493)
#### Version Pragma
```python
#pragma version 0.3.10
```
#### EVM Version Pragma
```python
#pragma evm-version paris
```
#### Optimization Pragma
```python
#pragma optimize codesize
```
Raw data
{
"_id": null,
"home_page": "https://github.com/ApeWorX/ape-vyper",
"name": "ape-vyper",
"maintainer": null,
"docs_url": null,
"requires_python": "<4,>=3.10",
"maintainer_email": null,
"keywords": "ethereum",
"author": "ApeWorX Ltd.",
"author_email": "admin@apeworx.io",
"download_url": "https://files.pythonhosted.org/packages/06/2a/50afa11243e4c426990f1f449af1eaeb8d833c838bbdfa18583b3513764b/ape-vyper-0.8.7.tar.gz",
"platform": null,
"description": "# Quick Start\n\nApe compiler plugin around [VVM](https://github.com/vyperlang/vvm)\n\n## Dependencies\n\n- [python3](https://www.python.org/downloads) version 3.10 up to 3.12.\n\n## Installation\n\n### via `pip`\n\nYou can install the latest release via [`pip`](https://pypi.org/project/pip/):\n\n```bash\npip install ape-vyper\n```\n\n### via `setuptools`\n\nYou can clone the repository and use [`setuptools`](https://github.com/pypa/setuptools) for the most up-to-date version:\n\n```bash\ngit clone https://github.com/ApeWorX/ape-vyper.git\ncd ape-vyper\npython3 setup.py install\n```\n\n## Quick Usage\n\nFirst, place Vyper contract source files (files with extension `.vy`) in your Ape project's contracts folder.\nAn example Vyper contract can be found [here](https://vyper.readthedocs.io/en/stable/vyper-by-example.html).\nThen, from your root Ape project folder, run the command:\n\n```bash\nape compile\n```\n\nThe `.vy` files in your project will compile into `ContractTypes` that you can deploy and interact with in Ape.\n\n### Contract Flattening\n\nFor ease of publishing, validation, and some other cases it's sometimes useful to \"flatten\" your contract into a single file.\nThis combines your contract and any imported interfaces together in a way the compiler can understand.\nYou can do so with a command like this:\n\n```bash\nape vyper flatten contracts/MyContract.vy build/MyContractFlattened.vy\n```\n\n> \\[!WARNING\\]\n> This feature is experimental. Please [report any bugs](https://github.com/ApeWorX/ape-solidity/issues/new?assignees=&labels=bug&projects=&template=bug.md) you find when trying it out.\n\n### Compiler Version\n\nBy default, the `ape-vyper` plugin uses version pragma for version specification.\nHowever, you can also configure the version directly in your `ape-config.yaml` file:\n\n```yaml\nvyper:\n version: 0.3.7\n```\n\n### EVM Versioning\n\nBy default, `ape-vyper` will use whatever version of EVM rules are set as default in the compiler version that gets used,\nor based on what the `#pragma evm-version ...` pragma comment specifies (available post-`v0.3.10`).\nSometimes, you might want to use a different version, such as deploying on Arbitrum or Optimism where new opcodes are not supported yet.\nIf 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:\n\n```yaml\nvyper:\n evm_version: paris\n```\n\n**NOTE**: The config value chosen will not override if a pragma is set in a contract.\n\n### Interfaces\n\nYou can not compile interface source files directly.\nThus, you must place interface files in a directory named `interfaces` in your `contracts_folder` e.g. `contracts/interfaces/IFace.vy`.\nThen, these files can be imported in other `.vy` sources files via:\n\n```python\nimport interfaces.IFace as IFace\n```\n\nAlternatively, use JSON interfaces from dependency contract types by listing them under the `import_remapping` key:\n\n```yaml\n# Use `voting` example contracts from Vyperlang repo.\ndependencies:\n - name: VyperVoting\n github: vyperlang/vyper\n contracts_folder: examples/voting/\n version: v0.3.8\n\n# Automatically allow importing voting contracts in your project.\nvyper:\n import_remapping:\n - \"voting=VyperVoting@v0.3.8\"\n```\n\nImport the voting contract types like this:\n\n```python\n# @version 0.3.10\n\nimport voting.ballot as ballot\n```\n\n### Decimals\n\nTo use decimals on Vyper 0.4, use the following config:\n\n```yaml\nvyper:\n enable_decimals: true\n```\n\n### Pragmas\n\nApe-Vyper supports Vyper 0.3.10's [new pragma formats](https://github.com/vyperlang/vyper/pull/3493)\n\n#### Version Pragma\n\n```python\n#pragma version 0.3.10\n```\n\n#### EVM Version Pragma\n\n```python\n#pragma evm-version paris\n```\n\n#### Optimization Pragma\n\n```python\n#pragma optimize codesize\n```\n",
"bugtrack_url": null,
"license": "Apache-2.0",
"summary": "Plugin for Ape Ethereum Framework for compiling Vyper contracts",
"version": "0.8.7",
"project_urls": {
"Homepage": "https://github.com/ApeWorX/ape-vyper"
},
"split_keywords": [
"ethereum"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "00f13a9f5be9d5cab6adf93df55ea4a0df3e63e407f8ece1b7f1acc8aca30f9f",
"md5": "4eb678b0573995f0763697c8f7f1f619",
"sha256": "b477d5325948a6982b23b426b671c598e5935bf4f107bc8d017fdf2fff6f595d"
},
"downloads": -1,
"filename": "ape_vyper-0.8.7-py3-none-any.whl",
"has_sig": false,
"md5_digest": "4eb678b0573995f0763697c8f7f1f619",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4,>=3.10",
"size": 43707,
"upload_time": "2024-10-29T17:46:27",
"upload_time_iso_8601": "2024-10-29T17:46:27.855836Z",
"url": "https://files.pythonhosted.org/packages/00/f1/3a9f5be9d5cab6adf93df55ea4a0df3e63e407f8ece1b7f1acc8aca30f9f/ape_vyper-0.8.7-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "062a50afa11243e4c426990f1f449af1eaeb8d833c838bbdfa18583b3513764b",
"md5": "14b592e03ef573e01dd7b6a2e36eec4d",
"sha256": "595e797147e59afa1662e77aa6976e80eacb6d945a4c5e0c3af8d8f22bfc87cd"
},
"downloads": -1,
"filename": "ape-vyper-0.8.7.tar.gz",
"has_sig": false,
"md5_digest": "14b592e03ef573e01dd7b6a2e36eec4d",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4,>=3.10",
"size": 68684,
"upload_time": "2024-10-29T17:46:29",
"upload_time_iso_8601": "2024-10-29T17:46:29.699206Z",
"url": "https://files.pythonhosted.org/packages/06/2a/50afa11243e4c426990f1f449af1eaeb8d833c838bbdfa18583b3513764b/ape-vyper-0.8.7.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-29 17:46:29",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "ApeWorX",
"github_project": "ape-vyper",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "ape-vyper"
}