Skip to main content

Client library for engaging with the Pantos system

Project description

Pantos logo

CI Quality Gate Status

Pantos Client Library

1. Introduction

1.1 Overview

Welcome to the documentation for Pantos Client Library, a powerful tool for engaging with the Pantos system. This documentation aims to provide developers with comprehensive information on how to use the features offered by the library.

1.2 Features

The Pantos Client Library API exposes the following functionalities:

  1. Loading the private key from a keystore file
  2. Retrieve the service node bids
  3. Retrieve the balance of a token
  4. Transfer tokens
  5. Deploy PANDAS tokens

2. Installation

2.1 Prerequisites

Please make sure that your development environment meets the following requirements:

Keystore File (Wallet)

The library requires a private key encrypted with a password.

Since, for the moment, the Pantos protocol supports only EVM blockchains, only an Ethereum account keystore file is sufficient. It can be created with tools such as https://vanity-eth.tk/.

One of the most significant advantages of using Pantos is that the protocol has been designed to require minimal user friction when cross-chain operations are performed. Therefore, when using the Pantos products, you must top up your wallet only with PAN tokens.

Python Version

The Pantos Client Library supports Python 3.10 or higher. Ensure that you have the correct Python version installed before the installation steps. You can download the latest version of Python from the official Python website.

Library Versions

The Pantos Client Library has been tested with the library versions specified in poetry.lock.

Poetry

Poetry is our tool of choice for dependency management and packaging.

Installing: https://python-poetry.org/docs/#installing-with-the-official-installer or https://python-poetry.org/docs/#installing-with-pipx

By default poetry creates the venv directory under under {cache-dir}/virtualenvs. If you opt for creating the virtualenv inside the project’s root directory, execute the following command:

poetry config virtualenvs.in-project true

2.2 Installation Steps

Clone the repository

Clone the repository to your local machine:

$ git clone https://github.com/pantos-io/client-library.git
$ cd client-library
$ git submodule init
$ git submodule update --remote

Libraries

Create the virtual environment and install the dependencies:

$ poetry install --no-root

3. Usage

3.1 Configuration

The configuration can be found in client-library.yml.

The library already has a set configuration for our testnet environment, but feel free to adapt it to your needs.

3.2 Examples

The api.py exposes the public functions of the library.

The following example leverages all the functionalities of the library:

#! /usr/bin/env python
"""Example usage of the Pantos client library.

"""
import decimal
import getpass
import pathlib

import pantos.client as pc

# Example retrieval of token balance
try:
    token_balance = pc.retrieve_token_balance(
        pc.Blockchain.POLYGON,
        pc.BlockchainAddress('0xaAE34Ec313A97265635B8496468928549cdd4AB7'),
        pc.TokenSymbol('pan'))
    print('Token balance: {}'.format(token_balance))
except pc.PantosClientError:
    # Handle exception
    raise

# Example retrieval of service node bids
try:
    service_node_bids = pc.retrieve_service_node_bids(pc.Blockchain.AVALANCHE,
                                                      pc.Blockchain.CRONOS)
    print('Service node bids: {}'.format(service_node_bids))
except pc.PantosClientError:
    # Handle exception
    raise

# Read private key from file
if not pathlib.Path('my_client.keystore').exists():
    raise FileNotFoundError('Keystore file not found')
with open('my_client.keystore', 'r') as keystore_file:
    keystore = keystore_file.read()

# Example token transfer
password = getpass.getpass('Keystore password: ')
try:
    private_key = pc.decrypt_private_key(pc.Blockchain.ETHEREUM, keystore,
                                         password)
    task_id = pc.transfer_tokens(
        pc.Blockchain.ETHEREUM, pc.Blockchain.BNB_CHAIN, private_key,
        pc.BlockchainAddress('0xaAE34Ec313A97265635B8496468928549cdd4AB7'),
        pc.TokenSymbol('pan'), decimal.Decimal('3.1'))
    print('Task ID of service node: {}'.format(task_id))
except pc.PantosClientError:
    # Handle exception
    raise

# Example of deploying a token contract
password = getpass.getpass('Keystore password: ')
try:
    private_key = pc.load_private_key(pc.Blockchain.ETHEREUM,
                                      pathlib.Path('my_client.keystore'),
                                      password)
    deployment_blockchains = [pc.Blockchain.ETHEREUM]
    payment_blockchain = pc.Blockchain.ETHEREUM
    task_id = pc.deploy_pantos_compatible_token('Test_cli', 'TCLI', 7, True,
                                                False, 54321,
                                                deployment_blockchains,
                                                payment_blockchain,
                                                private_key)
    print('Task ID deployment: {}'.format(task_id))
except pc.PantosClientError:
    # Handle exception
    raise

4. Contributing

At the moment, contributing to this project is not available.

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

pantos_client_library-1.1.1.tar.gz (32.1 kB view details)

Uploaded Source

Built Distribution

pantos_client_library-1.1.1-py3-none-any.whl (40.7 kB view details)

Uploaded Python 3

File details

Details for the file pantos_client_library-1.1.1.tar.gz.

File metadata

  • Download URL: pantos_client_library-1.1.1.tar.gz
  • Upload date:
  • Size: 32.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for pantos_client_library-1.1.1.tar.gz
Algorithm Hash digest
SHA256 042d5d38625cdf6be2a24b8c1686b830a4398e3f45bd2eb3a2eb5253db895ea4
MD5 821e820b48c186e3f77480bce3bbae62
BLAKE2b-256 a5ea22b6917fdb6f7b4496cccd996e7e5b844b752678d2a5320f873fbaeae997

See more details on using hashes here.

File details

Details for the file pantos_client_library-1.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for pantos_client_library-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a2ec960d285007c33679f950f8d5ebd0b0f74570fd54ac58c75e5805c78b2255
MD5 5ef03b4e859f3b4985f38c0572560fea
BLAKE2b-256 35abf90c588c29075fa9239c0a35c27ec161f145f3525c0cb1f3f508a52c8472

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