Skip to main content

PyPI version

icplazapy

Version 3.0.0

Tools for Icplaza wallet management and offline transaction signing

Table of Contents generated with mdformat-toc

Installing

Installing from PyPI repository (https://pypi.org/project/icplazapy):

pip install icplazapy

Usage

Generating a wallet

from icplazapy import generate_wallet

wallet = generate_wallet()

The value assigned to wallet will be a dictionary just like:

{
    'seed': 'loan weapon tone clever party picture spot novel almost change rug primary speak entry usage maximum farm beyond magnet crazy later day addict orchard', 
    'derivation_path': "m/44'/118'/0'/0/0", 
    'private_key': b'\x06\xe5*di\x88q0\xe4\x08Y\x9aL\xcb\xd7\xc0\xac\xc6\x9d\x9a\x18\xc5$\x00\xacM5\xae\x1b\x07\xe7N', 'public_key': b'\x02Jj\xe8>y\xe0\xcb\xe2\x11oIX@29p\xd3\x1c\x83\xcd\xa4i\xb0\x9e\xd7\x9f!\xf5\xbe\xb7\xe1i', 
    'address': 'icplaza1ayuhuzmlkw3dr7ftajxcl9kzg4vvzr0ltwpwjl'
}

Converter functions

Mnemonic seed to private key

from icplazapy import BIP32DerivationError, seed_to_privkey

seed = (
    "teach there dream chase fatigue abandon lava super senior artefact close upgrade"
)
try:
    privkey = seed_to_privkey(seed, path="m/44'/118'/0'/0/0")
except BIP32DerivationError:
    print("No valid private key in this derivation path!")

Private key to public key

from icplazapy import privkey_to_pubkey

privkey = bytes.fromhex(
    "6dcd05d7ac71e09d3cf7da666709ebd59362486ff9e99db0e8bc663570515afa"
)
pubkey = privkey_to_pubkey(privkey)

Public key to address

from icplazapy import pubkey_to_address

pubkey = bytes.fromhex(
    "03e8005aad74da5a053602f86e3151d4f3214937863a11299c960c28d3609c4775"
)
addr = pubkey_to_address(pubkey)

Private key to address

from icplazapy import privkey_to_address

privkey = bytes.fromhex(
    "6dcd05d7ac71e09d3cf7da666709ebd59362486ff9e99db0e8bc663570515afa"
)
addr = privkey_to_address(privkey)

Public key to hex address

from icplazapy import pubkey_to_hex_address

pubkey = bytes.fromhex(
    "03e8005aad74da5a053602f86e3151d4f3214937863a11299c960c28d3609c4775"
)
addr = pubkey_to_address(pubkey)

Private key to hex address

from icplazapy import privkey_to_hex_address

privkey = bytes.fromhex(
    "6dcd05d7ac71e09d3cf7da666709ebd59362486ff9e99db0e8bc663570515afa"
)
addr = privkey_to_address(privkey)

address from hex address

from icplazapy import from_hex_address
hex_addr = "0x4790155804CB6fd0D3697CBb367E75397408a587"
addr = from_hex_address(hex_addr)

address to hex address

from icplazapy import to_hex_address
addr = "icplaza1g7gp2kqyedhap5mf0janvln4896q3fv87z2dm6"
hex_addr = to_hex_address(addr)

Signing transactions

from icplazapy import Transaction

tx = Transaction(
    privkey=bytes.fromhex(
        "26d167d549a4b2b66f766b0d3f2bdbe1cd92708818c338ff453abde316a2bd59"
    ),
    account_num=11335,
    sequence=0,
    fee=1000,
    gas=70000,
    memo="",
    chain_id="icplaza_9000-4",
    sync_mode="sync",
)
tx.add_transfer(
    recipient="icplaza1g7gp2kqyedhap5mf0janvln4896q3fv87z2dm6", amount=387000
)

pushable_tx = tx.get_pushable()


# Optionally submit the transaction using your preferred method.
# This example uses the httpx library.
import httpx

# icplaza rest api
api_base_url = ""
httpx.post(api_base_url + "/txs", data=pushable_tx)

One or more token transfers can be added to a transaction by calling the add_transfer method.

When the transaction is fully prepared, calling get_pushable will return a signed transaction in the form of a JSON string. This can be used as request body when calling the POST /txs endpoint of the Cosmos REST API.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

icplazapy-3.0.0.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

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

icplazapy-3.0.0-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

Details for the file icplazapy-3.0.0.tar.gz.

File metadata

  • Download URL: icplazapy-3.0.0.tar.gz
  • Upload date:
  • Size: 7.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.8

File hashes

Hashes for icplazapy-3.0.0.tar.gz
Algorithm Hash digest
SHA256 151ca2222678cfc4ebe472b957aa844f665e1de96a4852281a55affc983e8dfd
MD5 2dc7129a3656f45cd10212fe6912fd42
BLAKE2b-256 212f0d986fe62a8dc143a35fc60c62c5ccbc88b0fe076c7f9f84d104c952a9a3

See more details on using hashes here.

File details

Details for the file icplazapy-3.0.0-py3-none-any.whl.

File metadata

  • Download URL: icplazapy-3.0.0-py3-none-any.whl
  • Upload date:
  • Size: 7.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.8

File hashes

Hashes for icplazapy-3.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1d46435b9732bdb593e327753d4bbce0e7e0f96074896cbd891b1a17160c79f5
MD5 6db9849e3ef07748d968303978f96f5f
BLAKE2b-256 4159334231e659a1aae03a722c597746eeafdf97acfc9d1c78cc7949d7172e97

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

3.0.0 This release

2 files

Supported by

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