Skip to main content

ape-tokens: tokenlists plugin for Ape

Project description

Ape Token Utilities

A series of utilities for working with tokens, based on the py-tokenlists.

Dependencies

  • python3 version 3.7 or greater, python3-dev

Installation

via pip

You can install the latest release via pip:

pip install ape-tokens

via setuptools

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

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

Quick Usage

CLI Usage

First, install a token list, such as the 1inch token list, which contains many tokens that you can use:

ape tokens install tokens.1inch.eth

To see all the tokens you can use, run command:

ape tokens list-tokens

To see other available CLI commands, run:

ape tokens --help

Python Usage

One of the main reasons to use the ape-tokens plugin is to have nicer UX for providing token amounts to contract transactions. For example, let's say you have a smart-contract named MyContract with a function provideLinkToken() that takes a decimal value of LINK tokens. The following is an example script that deploys the contract and makes a transaction by expressing the value of LINK as 8.23 LINK:

from ape import accounts, project

my_account = accounts[0]
contract = my_account.deploy(project.MyContract)

contract.provideLinkTokens("8.23 LINK")

Alternatively, if you need the converted value returned to you, you can use the convert tool from the root ape namespace:

from ape import convert

convert("100.1234 BAT", int)

Lastly, to get information about a token, including its contract address, you can do so by importing the tokens member from the root ape_tokens namespace:

from ape_tokens import tokens

bat = tokens["BAT"]

print(bat.address)

Development

This project is in development and should be considered a beta. Things might not be in their final state and breaking changes may occur. Comments, questions, criticisms and pull requests are welcomed.

License

This project is licensed under the Apache 2.0.

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-tokens-0.1.0b4.tar.gz (14.6 kB view details)

Uploaded Source

Built Distribution

ape_tokens-0.1.0b4-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file ape-tokens-0.1.0b4.tar.gz.

File metadata

  • Download URL: ape-tokens-0.1.0b4.tar.gz
  • Upload date:
  • Size: 14.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.12

File hashes

Hashes for ape-tokens-0.1.0b4.tar.gz
Algorithm Hash digest
SHA256 b20a9f069414c501c669fa1522261c07b1777486aa48c13501ade7e69db5437b
MD5 923e7b03d5427bd636fa2fa0afb3283d
BLAKE2b-256 2a0d3dcf35ba770d01dba4bd7ed30091407fc21f6f6e71d63326718b42c0f3a0

See more details on using hashes here.

File details

Details for the file ape_tokens-0.1.0b4-py3-none-any.whl.

File metadata

  • Download URL: ape_tokens-0.1.0b4-py3-none-any.whl
  • Upload date:
  • Size: 9.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.12

File hashes

Hashes for ape_tokens-0.1.0b4-py3-none-any.whl
Algorithm Hash digest
SHA256 36fd2a33c3e730083f25c505bde4f7348aca03e81fccb8a1866b30b5d66d2662
MD5 5c45716a386b7f76852168801854410c
BLAKE2b-256 66546b3a6236922c2b66de16efd771e57345d5a701214bae52c1acb84f466671

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