Ape Ethereum Framework
Project description
Quick Start
Prerequisite
In the latest release, Ape requires:
- Linux or macOS
- Python 3.8 or later
Windows:
- Install Windows Subsystem Linux (WSL)
- Choose Ubuntu 20.04 OR Any other Linux Distribution with Python 3.8 or later
Check your python command by entering:
python3 --version
Installation
There are 3 ways to install ape: pipx
, pip
, or Docker
.
via pipx
Install pipx
via their installation instructions
Then install ape
via
pipx install eth-ape
To install Ape and a list of common, recommended plugins at the same time, do:
pipx install eth-ape'[recommended-plugins]'
via pip
Suggestion: Create a virtual environment using virtualenv
or venv.
You may skip creating a virtual environment if you know you don't require one for your use case.
NOTE: For MacOS users, we advise installing in a virtual environment to avoid interfering with OS-level site packages.
virtualenv via homebrew
- (MacOS Option) Install via homebrew brew
First, create your virtual environment folder:
python3 -m venv <path/to/new/env>
Then, activate your virtual environment:
source <venv_folder>/bin/activate
You should see (name_of_venv) DESKTOP_NAME:~/path:$
.
To deactivate the virtual environment, do:
deactivate
Now that you have Python installed in your virtual environment, install the eth-ape
Python package:
You can install the latest release via pip:
pip install -U pip
pip install eth-ape
To install Ape and a list of common, recommended plugins at the same time, do:
pip install eth-ape'[recommended-plugins]'
via docker
Please visit our Dockerhub for more details on using Ape with Docker.
docker run \
--volume $HOME/.ape:/root/.ape \
--volume $HOME/.vvm:/root/.vvm \
--volume $HOME/.solcx:/root/.solcx \
--volume $PWD:/root/project \
--workdir /root/project \
apeworx/ape compile
Docker Uninstall Process: You will need to remove files generated by docker
sudo rm -rf **\~/.solcx**
sudo rm -rf **\~/.vvm**
Environment Variables:
Some plugins require environment variables to connect to their external systems, such project IDs or API keys. Follow instructions from individual plugin documentations, such as:
Generally, set environment variables by doing the following:
# Used by the `ape-infura` plugin
export WEB3_INFURA_PROJECT_ID=<YOUR_INFURA_PROJECT_ID>
# Used by the `ape-alchemy` plugin
export WEB3_ALCHEMY_API_KEY=<YOUR_ALCHEMY_KEY>
Place these in environment files, such as your .bashrc
or .zshrc
.
Quick Usage
Use -h
to list all the commands:
ape -h
Projects
When using Ape, you generally will work with a project.
To quickly get started using ape, generate a project using the ape init
command:
ape init
For more in-depth information about smart-contract projects using the Ape framework, see the projects guide.
Accounts
In Ape, you will need accounts to make transactions.
You can import or generate accounts using the core accounts
plugin:
ape accounts import acc0 # Will prompt for a private key
ape accounts generate acc1
List all your accounts with the list
command.
ape accounts list
Learn more about accounts in Ape by following the accounts guide.
Plugins
Add any plugins you may need, such as vyper
.
ape plugins list -a
ape plugins install vyper
ape plugins list -a
NOTE: If a plugin does not originate from the ApeWorX GitHub organization, you will get a warning about installing 3rd-party plugins.
Install 3rd party plugins at your own risk.
Additionally, plugins that come bundled with ape
in the core installation cannot be removed and are part of the ape
core software.
Learn more about installing plugins from following this guide. Learn more about developing your own plugins from this guide.
Compiling
You can compile contracts within the contracts/
directory of your project.
The --size
option will display you the size of the contract.
ape compile --size
Learn more about compiling in Ape by following the compile guide.
Testing
Use Ape to test your smart-contract projects.
Provide the same arguments to pytest
as you would to the ape test
command.
For example:
ape test -k test_only_one_thing
Visit the testing guide to learn more about testing using Ape.
Console
Ape provides an IPython
interactive console with useful pre-defined locals to interact with your project.
To interact with a deployed contract in a local environment, start by opening the console:
ape console --network ethereum:mainnet:infura
Visit Ape Console to learn how to use Ape Console.
Scripts
If you want to run specific files in a scripts/
directory, you can do it using the ape run
command.
# This command will run a file named deploy in the scripts/ directory
$ ape run deploy
Learn more about scripting using Ape by following the scripting guide.
Logging
To enable debug logging, run your command with the --verbosity
flag using DEBUG
as the value:
ape --verbosity DEBUG run
Networks
You can work with registered networks, providers, and blockchain ecosystems (like Ethereum):
from ape import networks
with networks.ethereum.mainnet.use_provider("infura"):
... # Work with the infura provider here
To learn more about networks in Ape, see this guide.
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
File details
Details for the file eth-ape-0.5.6.tar.gz
.
File metadata
- Download URL: eth-ape-0.5.6.tar.gz
- Upload date:
- Size: 1.0 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.3 readme-renderer/37.3 requests/2.28.1 requests-toolbelt/0.10.1 urllib3/1.26.12 tqdm/4.64.1 importlib-metadata/5.0.0 keyring/23.11.0 rfc3986/2.0.0 colorama/0.4.6 CPython/3.8.14
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dccf3807a32d131c3892e1a83373a0e930e4024ae55f06e804afb995c3b51e3d |
|
MD5 | d9e4e0da408487e9f6a22a42b72e30c0 |
|
BLAKE2b-256 | a25356d85e0c554c9e580c6807a849daed242abc0d97042a2629021b88b397a2 |
File details
Details for the file eth_ape-0.5.6-py3-none-any.whl
.
File metadata
- Download URL: eth_ape-0.5.6-py3-none-any.whl
- Upload date:
- Size: 197.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.3 readme-renderer/37.3 requests/2.28.1 requests-toolbelt/0.10.1 urllib3/1.26.12 tqdm/4.64.1 importlib-metadata/5.0.0 keyring/23.11.0 rfc3986/2.0.0 colorama/0.4.6 CPython/3.8.14
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c579c8b0a2c530324a76698d7ef400983f09cc0558cedc5483a5636283b41462 |
|
MD5 | ecca223837ed78c2be0e58a3dc9f59e5 |
|
BLAKE2b-256 | 3e662f934f54a6f44348fee8c2414b268bbf1e99193f45237612d43086c6bfde |