Skip to main content

A python wrapper for the Ergo Appkit

Project description

ergo-python-appkit

This is a wrapper around Ergo's appkit, which is based on scala/java. Jpype is used to map to the JVM and the jar running within. That means that Java needs to be installed for this package to work.

Installation

Installation can be done through pip. Currently the package is not available yet on PyPi so you need to refer directly to the github.

pip install git+https://github.com/ergo-pad/ergo-python-appkit.git

Usage

The ergo appkit can be accessed by importing java classes AFTER importing the appkit, like this:

import ergo_python_appkit.appkit
from org.ergoplatform.appkit import Address

myErgoAddress = Address.create("9gF2wmTWcEX2EZu5QY3dJwURep1HWsXjUZdVavVWESun4Sp8BYj")
#will print the ergotree belonging to the address
print(myErgoAddress.toErgoContract().getErgoTree())

There are also convenience methods created to allow for easier use from Python for appkit functionality that is used often.

An example of a simple intra wallet transaction send from the nodes wallet:

from ergo_python_appkit.appkit import ErgoAppKit
from org.ergoplatform.appkit import Address

appKit = ErgoAppKit("http://myergonode:9053","mainnet","http://api.ergoplatform.org","nodeapikey")
myAddress = "9gF2wmTWcEX2EZu5QY3dJwURep1HWsXjUZdVavVWESun4Sp8BYj"

#collect boxes to spend 1 erg
inputs = appKit.boxesToSpend(address=myAddress,nergToSpend=int(1e9))

#Define output box
outputBox = appKit.buildOutBox(
                value=int(1e9),
                tokens=None,
                registers=None,
                contract=appKit.contractFromAddress(myAddress)
            )

#Build the unsigned transaction
unsignedTx = appKit.buildUnsignedTransaction(
                inputs=inputs,
                outputs=[outputBox],
                fee=int(1e6),
                sendChangeTo=Address.create(myAddress).getErgoAddress()
            )

#Sign the transaction with the node
signedTx = appKit.signTransactionWithNode(unsignedTx)

#Send the transaction
appKit.sendTransaction(signedTx)

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

ergo_python_appkit-0.1.0.tar.gz (50.9 MB view details)

Uploaded Source

Built Distribution

ergo_python_appkit-0.1.0-py3-none-any.whl (51.0 MB view details)

Uploaded Python 3

File details

Details for the file ergo_python_appkit-0.1.0.tar.gz.

File metadata

  • Download URL: ergo_python_appkit-0.1.0.tar.gz
  • Upload date:
  • Size: 50.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.10.4

File hashes

Hashes for ergo_python_appkit-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6b2338611cc3c71d7e90777770e17482b4efd3ccd9d4575a6914c32eab09de2e
MD5 1c1ab018c1de834f87163dafebd4834d
BLAKE2b-256 e6479dcc388eb89a7af41bb71c2f815c1c4ea497ec5481c3ca5b1af27f6c0cd8

See more details on using hashes here.

File details

Details for the file ergo_python_appkit-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for ergo_python_appkit-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9a9243894b7e4b9fcdea17c3d7eb17ef53ff23fc80cb37e4b96c4a969b4a5088
MD5 aa7386b2604f00d042313ced9df7a044
BLAKE2b-256 e5b42bc4227754967b64487421ef64c1f5b69ac4d5c2f0b51f62b2a0d8082a2a

See more details on using hashes here.

Supported by

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