Skip to main content

ape-tokens: tokenlists plugin for Ape

Project description

Quick Start

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

Dependencies

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)

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.8.3.tar.gz (15.4 kB view details)

Uploaded Source

Built Distribution

ape_tokens-0.8.3-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

Details for the file ape-tokens-0.8.3.tar.gz.

File metadata

  • Download URL: ape-tokens-0.8.3.tar.gz
  • Upload date:
  • Size: 15.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.15

File hashes

Hashes for ape-tokens-0.8.3.tar.gz
Algorithm Hash digest
SHA256 da628bb40b7e7ede80c2d095992deb008350823f275c5a235bb33ca15d843fde
MD5 7937f9052c8220210d2c6224a0163c9b
BLAKE2b-256 73e663e80270c367a2b6375a5473072b37ff7c148b15c96217303bee7462d0b5

See more details on using hashes here.

File details

Details for the file ape_tokens-0.8.3-py3-none-any.whl.

File metadata

  • Download URL: ape_tokens-0.8.3-py3-none-any.whl
  • Upload date:
  • Size: 10.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.15

File hashes

Hashes for ape_tokens-0.8.3-py3-none-any.whl
Algorithm Hash digest
SHA256 0a5dd22c39d9aec73c9604ca464f3b0bafc42a36909cdad343687b080365be59
MD5 c1b49304b45bf3e32e5dad1025eb44de
BLAKE2b-256 10348d1b581bf2b0d9351ccdbc1989ed9be5bc771a26411b1a9fee7710ff6d9a

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