ape-tokens: tokenlists plugin for Ape
Project description
Quick Start
A series of utilities for working with tokens, based on the py-tokenlists
.
Dependencies
- python3 version 3.8 up to 3.11.
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
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 ape-tokens-0.7.1.tar.gz
.
File metadata
- Download URL: ape-tokens-0.7.1.tar.gz
- Upload date:
- Size: 15.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 20f06095664de527c401892edc6fff0a7403919e9948e238699b1afc59d8ceb6 |
|
MD5 | 24f1cbaeed407054b7d2939b8a448ff1 |
|
BLAKE2b-256 | 316d38578500a997a10a5e95464058954ac10fff9ffda076fc437cec91435138 |
File details
Details for the file ape_tokens-0.7.1-py3-none-any.whl
.
File metadata
- Download URL: ape_tokens-0.7.1-py3-none-any.whl
- Upload date:
- Size: 10.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8edd70dacb77cf369a825d7703c0866e81bdf652a99f0589f7fbf98f67986446 |
|
MD5 | c92530d0da0dc46d7147dc2abc7b3637 |
|
BLAKE2b-256 | 1f5315c0e97d92bc38cdda478d5f2b76f0e4e8fe3cd1b3a6f2997e94e7d2eafa |