Skip to main content

Python Toolkit for AMAX

Project description

Python Toolkit for AMAX

PyPi PyPi

Installation

On Linux platform

python3 -m pip install -U pip
python3 -m pip install pyamaxkit

On Windows platform:

python -m pip install -U pip
python -m pip install pyamaxkit

On Apple M1 hardware

pyamaxkit does not have pre-built versions available for ARM chips. In order to build it from source code, you need to install cmake, go, scikit-build, cython.

brew install go
brew install cython
xcode-select --install
python3 -m pip install -U pip
python3 -m pip install cmake
python3 -m pip install scikit-build
python3 -m pip install pyamaxkit

Code Examples

Example1

import os
from pyamaxkit import amaxapi, wallet
#import your account private key here
wallet.import_key('mywallet', '5K463ynhZoCDDa4RDcr63cUwWLTnKqmdcoTKTHBjqoKfv4u5V7p')

amaxapi.set_node('https://chain.amaxtest.com')
info = amaxapi.get_info()
print(info)
args = {
    'from': 'test1',
    'to': 'test2',
    'quantity': '1.00000000 AMAX',
    'memo': 'hello world'
}
amaxapi.push_action('amax.token', 'transfer', args, {'test1':'active'})

Async Example

import os
import asyncio
from pyamaxkit import wallet
from pyamaxkit.chainapi import ChainApiAsync

#import your account private key here
wallet.import_key('mywallet', '5K463ynhZoCDDa4RDcr63cUwWLTnKqmdcoTKTHBjqoKfv4u5V7p')

async def test():
    amaxapi = ChainApiAsync('https://chain.amaxtest.com')
    info = await amaxapi.get_info()
    print(info)
    args = {
        'from': 'test1',
        'to': 'test2',
        'quantity': '1.00000000 AMAX',
        'memo': 'hello world'
    }
    r = await amaxapi.push_action('amax.token', 'transfer', args, {'test1':'active'})
    print(r)

asyncio.run(test())

Sign With Ledger Hardware Wallet Example

import os
from pyamaxkit import amaxapi
amaxapi.set_node('https://chain.amaxtest.com')
args = {
    'from': 'test1',
    'to': 'test2',
    'quantity': '1.00000000 AMAX',
    'memo': 'hello world'
}

#indices is an array of ledger signing key indices
amaxapi.push_action('amax.token', 'transfer', args, {'test1':'active'}, indices=[0])

Docs

Building from Source Code

Installing Prerequisites

Install the build dependencies:

python3 -m pip install scikit-build
python3 -m pip install cython

Install the Go compiler and cmake with your system package manager so that the CGo components can be compiled. You will also need a C compiler such as gcc. On Debian based systems run sudo apt-get install build-essential. When targeting a different architecture install the matching cross compiler (for example gcc-aarch64-linux-gnu) and set GOARCH and CC accordingly, e.g.:

export GOARCH=arm64
export CC=aarch64-linux-gnu-gcc

For Windows platform

python -m pip install scikit-build
python -m pip install cython
  1. Download and Install gcc compiler from tdm-gcc
  2. Install Go compiler from download
  3. Install cmake from download
  4. Install python3 from downloads

Press Win+R to open Run Dialog, input the following command

cmd -k /path/to/gcc/mingwvars.bat

Downloading Source Code

git clone https://www.github.com/AMAX-DAO-DEV/pyamaxkit
cd pyamaxkit
git submodule update --init --recursive

Build

./build.sh

For Windows platform, in the cmd dialog, enter the following command:

python setup.py sdist bdist_wheel

Installation

./install.sh

For Windows platform

python -m pip uninstall pyamaxkit -y;python -m pip install .\dist\pyamaxkit-[SUFFIX].whl

Publishing to PyPI

Use the helper script to build and upload the package. Set PYPI_TOKEN with your API token and optionally PYPI_REPOSITORY (defaults to pypi). The script installs build requirements such as scikit-build and Cython automatically.

python3 scripts/publish_pypi.py

License

MIT

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

pyamaxkit-1.0.7.tar.gz (3.2 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pyamaxkit-1.0.7-cp39-cp39-macosx_10_16_x86_64.whl (2.2 MB view details)

Uploaded CPython 3.9macOS 10.16+ x86-64

pyamaxkit-1.0.7-cp38-cp38-manylinux2014_x86_64.whl (609.1 kB view details)

Uploaded CPython 3.8

File details

Details for the file pyamaxkit-1.0.7.tar.gz.

File metadata

  • Download URL: pyamaxkit-1.0.7.tar.gz
  • Upload date:
  • Size: 3.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.13

File hashes

Hashes for pyamaxkit-1.0.7.tar.gz
Algorithm Hash digest
SHA256 e5040a57f9bd1ff514a061f6e1da4a06f04416e9e70d9e14b918e9ac66a5cdaf
MD5 4e254a42643f22dfc62e8b01b77fa74a
BLAKE2b-256 f9b5ac0163adb5502565d6d80841aadb2a0701e3aae4164180a43b0189c3a16d

See more details on using hashes here.

File details

Details for the file pyamaxkit-1.0.7-cp39-cp39-macosx_10_16_x86_64.whl.

File metadata

File hashes

Hashes for pyamaxkit-1.0.7-cp39-cp39-macosx_10_16_x86_64.whl
Algorithm Hash digest
SHA256 65371b2280feaaaab13b0c7ff915522a1b3c463805265c8160a2a719b04da362
MD5 19a72d2953b1e9d50ae8503d2f0f7354
BLAKE2b-256 7ff0e429f264f6b48e4207a2d57adedf72a9d414eba1773ee4dafaa6390dd442

See more details on using hashes here.

File details

Details for the file pyamaxkit-1.0.7-cp38-cp38-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyamaxkit-1.0.7-cp38-cp38-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 925131b3ff2d2966109cb8ea68e36cab9bc6239d6e495a28a3a36a05e08eb5fc
MD5 f2466227bc106dc0cbc23c389bccebc8
BLAKE2b-256 cb075ebb068c6a570d99fc6b8cbf6c1c0793b4f5161bcb1e22a239156cdcdc69

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page