ape-tokens


Nameape-tokens JSON
Version 0.8.3 PyPI version JSON
download
home_pagehttps://github.com/ApeWorX/ape-tokens
Summaryape-tokens: tokenlists plugin for Ape
upload_time2024-10-29 17:58:59
maintainerNone
docs_urlNone
authorApeWorX Ltd.
requires_python<4,>=3.9
licenseApache-2.0
keywords ethereum
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Quick Start

A series of utilities for working with tokens, based on the [`py-tokenlists`](https://github.com/ApeWorX/py-tokenlists).

## Dependencies

- [python3](https://www.python.org/downloads) version 3.8 up to 3.12.

## Installation

### via `pip`

You can install the latest release via [`pip`](https://pypi.org/project/pip/):

```bash
pip install ape-tokens
```

### via `setuptools`

You can clone the repository and use [`setuptools`](https://github.com/pypa/setuptools) for the most up-to-date version:

```bash
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:

```bash
ape tokens install tokens.1inch.eth
```

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

```bash
ape tokens list-tokens
```

To see other available CLI commands, run:

```bash
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`:

```python
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:

```python
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:

```python
from ape_tokens import tokens

bat = tokens["BAT"]

print(bat.address)
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/ApeWorX/ape-tokens",
    "name": "ape-tokens",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4,>=3.9",
    "maintainer_email": null,
    "keywords": "ethereum",
    "author": "ApeWorX Ltd.",
    "author_email": "admin@apeworx.io",
    "download_url": "https://files.pythonhosted.org/packages/73/e6/63e80270c367a2b6375a5473072b37ff7c148b15c96217303bee7462d0b5/ape-tokens-0.8.3.tar.gz",
    "platform": null,
    "description": "# Quick Start\n\nA series of utilities for working with tokens, based on the [`py-tokenlists`](https://github.com/ApeWorX/py-tokenlists).\n\n## Dependencies\n\n- [python3](https://www.python.org/downloads) version 3.8 up to 3.12.\n\n## Installation\n\n### via `pip`\n\nYou can install the latest release via [`pip`](https://pypi.org/project/pip/):\n\n```bash\npip install ape-tokens\n```\n\n### via `setuptools`\n\nYou can clone the repository and use [`setuptools`](https://github.com/pypa/setuptools) for the most up-to-date version:\n\n```bash\ngit clone https://github.com/ApeWorX/ape-tokens.git\ncd ape-tokens\npython3 setup.py install\n```\n\n## Quick Usage\n\n### CLI Usage\n\nFirst, install a token list, such as the `1inch` token list, which contains many tokens that you can use:\n\n```bash\nape tokens install tokens.1inch.eth\n```\n\nTo see all the tokens you can use, run command:\n\n```bash\nape tokens list-tokens\n```\n\nTo see other available CLI commands, run:\n\n```bash\nape tokens --help\n```\n\n### Python Usage\n\nOne of the main reasons to use the `ape-tokens` plugin is to have nicer UX for providing token amounts to contract transactions.\nFor example, let's say you have a smart-contract named `MyContract` with a function `provideLinkToken()` that takes a decimal value of `LINK` tokens.\nThe following is an example script that deploys the contract and makes a transaction by expressing the value of LINK as `8.23 LINK`:\n\n```python\nfrom ape import accounts, project\n\nmy_account = accounts[0]\ncontract = my_account.deploy(project.MyContract)\n\ncontract.provideLinkTokens(\"8.23 LINK\")\n```\n\nAlternatively, if you need the converted value returned to you, you can use the `convert` tool from the root `ape` namespace:\n\n```python\nfrom ape import convert\n\nconvert(\"100.1234 BAT\", int)\n```\n\nLastly, 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:\n\n```python\nfrom ape_tokens import tokens\n\nbat = tokens[\"BAT\"]\n\nprint(bat.address)\n```\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "ape-tokens: tokenlists plugin for Ape",
    "version": "0.8.3",
    "project_urls": {
        "Homepage": "https://github.com/ApeWorX/ape-tokens"
    },
    "split_keywords": [
        "ethereum"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "10348d1b581bf2b0d9351ccdbc1989ed9be5bc771a26411b1a9fee7710ff6d9a",
                "md5": "c1b49304b45bf3e32e5dad1025eb44de",
                "sha256": "0a5dd22c39d9aec73c9604ca464f3b0bafc42a36909cdad343687b080365be59"
            },
            "downloads": -1,
            "filename": "ape_tokens-0.8.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c1b49304b45bf3e32e5dad1025eb44de",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4,>=3.9",
            "size": 10449,
            "upload_time": "2024-10-29T17:58:58",
            "upload_time_iso_8601": "2024-10-29T17:58:58.160325Z",
            "url": "https://files.pythonhosted.org/packages/10/34/8d1b581bf2b0d9351ccdbc1989ed9be5bc771a26411b1a9fee7710ff6d9a/ape_tokens-0.8.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "73e663e80270c367a2b6375a5473072b37ff7c148b15c96217303bee7462d0b5",
                "md5": "7937f9052c8220210d2c6224a0163c9b",
                "sha256": "da628bb40b7e7ede80c2d095992deb008350823f275c5a235bb33ca15d843fde"
            },
            "downloads": -1,
            "filename": "ape-tokens-0.8.3.tar.gz",
            "has_sig": false,
            "md5_digest": "7937f9052c8220210d2c6224a0163c9b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4,>=3.9",
            "size": 15447,
            "upload_time": "2024-10-29T17:58:59",
            "upload_time_iso_8601": "2024-10-29T17:58:59.635145Z",
            "url": "https://files.pythonhosted.org/packages/73/e6/63e80270c367a2b6375a5473072b37ff7c148b15c96217303bee7462d0b5/ape-tokens-0.8.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-29 17:58:59",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ApeWorX",
    "github_project": "ape-tokens",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "ape-tokens"
}
        
Elapsed time: 0.81685s