Skip to main content

Ape Ethereum Framework

Project description

Quick Start

Prerequisite

In the latest release, Ape requires:

  • Linux or macOS
  • Python 3.7.X or later

Windows:

  1. Install Windows Subsystem Linux (WSL)
  2. Choose Ubuntu 20.04 OR Any other Linux Distribution with Python 3.7.X or later

Please make sure you are using Python 3.7.X or later.

Check your python command by entering

python3 --version

Installation

Suggestion: Create a virtual environment using virtualenv or venv.

You may skip this creating a virtual environment if you know you don't require one for your use case.

Create your virtual environment folder

python3 -m venv /path/to/new/environment
source <venv_folder>/bin/activate

You should see (name_of_venv) DESKTOP_NAME:~/path:$. To deactivate the virtual environment, do:

deactivate

Now that your Python version is later than 3.7.X and you have created a virtual environment. Let's install Ape! There are 3 ways to install ape: pip, setuptools, or Docker.

via pip

You can install the latest release via pip:

pip install -U pip
pip install eth-ape

via setuptools

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

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

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**

Overview

For more in-depth information about the project please look at the projects It explains the purpose of each folder and how to use them effectively.

Use ape init to initialize your ape project folders. Visit userguide project for more information.

ape init

Environment Variables:

Environment Variables are used to help connect you to your files or ecosystems outside of ApeWorX.

Please setup environment variables (where applicable) and follow the latest instructions from the 3rd party:

Example use case:

# 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>

Visit ape-alchemy

Visit ape-infura

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 :mainnet-fork:hardhat

Visit Ape Console to learn how to use Ape Console.

Quick Usage

Use -h to list all the commands.

ape -h

You can import or generate accounts.

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

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-class plugins. Any plugin that is not an official plugin has the chance of not being trustworthy. Thus, you should be mindful about which plugins you install. Additionally, plugins that come bundled with ape in the core installation cannot be removed and are considered part of the ape core software.

You can interact and compile contracts. Here is an example of a project with a contract you interact with:

git clone https://github.com/brownie-mix/vyper-token-mix.git
cd vyper-token-mix/

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

Provide the same arguments to pytest as you would to the ape test command.

ape test -k test_only_one_thing --coverage

Connect an IPython session through your favorite provider.

ape console --network ethereum:mainnet:infura

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

Logging

To enable debug logging, run your command with the --verbosity flag using DEBUG as the value:

ape run --verbosity DEBUG

You can use ape as a package outside of scripts for the ape run command as well.

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

You can work with test accounts, local accounts, and (WIP) popular hardware wallets:

from ape import accounts
a = accounts[0]  # Load by index
a = accounts["example.eth"]  # or load by ENS/address
a = accounts.load("alias") # or load by alias

You can also work with contract types:

from ape import project
c = a.deploy(project.MyContract, ...)
c.viewThis()  # Make Web3 calls
c.doThat(sender=a)  # Make Web3 transactions
assert c.MyEvent[-1].caller == a  # Search through Web3 events

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

eth-ape-0.2.4.tar.gz (864.4 kB view details)

Uploaded Source

Built Distribution

eth_ape-0.2.4-py3-none-any.whl (149.1 kB view details)

Uploaded Python 3

File details

Details for the file eth-ape-0.2.4.tar.gz.

File metadata

  • Download URL: eth-ape-0.2.4.tar.gz
  • Upload date:
  • Size: 864.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/35.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.64.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.12

File hashes

Hashes for eth-ape-0.2.4.tar.gz
Algorithm Hash digest
SHA256 48c078be115a32fd5d275f598e89426aa6e61597ec37e3be970bb8e1d4479475
MD5 5a51b51af2ad5826b025a186b5d3f4d5
BLAKE2b-256 59b7cf2771a2611cf2f5633e4b148707bf8b81f8357de49a0d7231e186e60e60

See more details on using hashes here.

File details

Details for the file eth_ape-0.2.4-py3-none-any.whl.

File metadata

  • Download URL: eth_ape-0.2.4-py3-none-any.whl
  • Upload date:
  • Size: 149.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/35.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.64.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.12

File hashes

Hashes for eth_ape-0.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 8923e48a0a121792c9dbd53f3664847921f21e7c49b2c2b8f22f02587e0624b0
MD5 55126efd46a050e4e35beade046cdb58
BLAKE2b-256 af126692189227baa7359785726fb379e7a6cd977b895307d4c7f077ea89977f

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