Package: icplazapy
icplazapyforked fromhukkin/cosmospymodifiedhukkin/cosmospyto icplazapyicplaza chain is an evmos like chain.Version 3.0.0Tools for Icplaza wallet management and offline transaction signingTable of Contentsgenerated withmdformat-tocInstallingUsageGenerating a walletConverter functionsMnemonic seed to private keyPrivate key to public keyPublic key to addressPrivate key to addressPublic key to hex addressPrivate key to hex addressaddress from hex addressaddress to hex addressSigning transactionsInstallingInstalling from PyPI repository (https://pypi.org/project/icplazapy):pipinstallicplazapyUsageGenerating a walletfromicplazapyimportgenerate_walletwallet=generate_wallet()The value assigned towalletwill 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 functionsMnemonic seed to private keyfromicplazapyimportBIP32DerivationError,seed_to_privkeyseed=("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")exceptBIP32DerivationError:print("No valid private key in this derivation path!")Private key to public keyfromicplazapyimportprivkey_to_pubkeyprivkey=bytes.fromhex("6dcd05d7ac71e09d3cf7da666709ebd59362486ff9e99db0e8bc663570515afa")pubkey=privkey_to_pubkey(privkey)Public key to addressfromicplazapyimportpubkey_to_addresspubkey=bytes.fromhex("03e8005aad74da5a053602f86e3151d4f3214937863a11299c960c28d3609c4775")addr=pubkey_to_address(pubkey)Private key to addressfromicplazapyimportprivkey_to_addressprivkey=bytes.fromhex("6dcd05d7ac71e09d3cf7da666709ebd59362486ff9e99db0e8bc663570515afa")addr=privkey_to_address(privkey)Public key to hex addressfromicplazapyimportpubkey_to_hex_addresspubkey=bytes.fromhex("03e8005aad74da5a053602f86e3151d4f3214937863a11299c960c28d3609c4775")addr=pubkey_to_address(pubkey)Private key to hex addressfromicplazapyimportprivkey_to_hex_addressprivkey=bytes.fromhex("6dcd05d7ac71e09d3cf7da666709ebd59362486ff9e99db0e8bc663570515afa")addr=privkey_to_address(privkey)address from hex addressfromicplazapyimportfrom_hex_addresshex_addr="0x4790155804CB6fd0D3697CBb367E75397408a587"addr=from_hex_address(hex_addr)address to hex addressfromicplazapyimportto_hex_addressaddr="icplaza1g7gp2kqyedhap5mf0janvln4896q3fv87z2dm6"hex_addr=to_hex_address(addr)Signing transactionsfromicplazapyimportTransactiontx=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.importhttpx# icplaza rest apiapi_base_url=""httpx.post(api_base_url+"/txs",data=pushable_tx)One or more token transfers can be added to a transaction by calling theadd_transfermethod.When the transaction is fully prepared, callingget_pushablewill return a signed transaction in the form of a JSON string.
This can be used as request body when calling thePOST /txsendpoint of theCosmos REST API.