Skip to main content

Project Origin ledger SDK

Project description

Ledger-SDK

The goal of this repository is to create a simple and common way to interact with the Ledger of Origins that is a part of Project Origin.

This is work in progress, more documentation will be written as the project progresses.

Requirements

The following four libraries are required to be installed.

pkg-config
libsecp256k1-dev
gcc
libzmq3-dev 

Keys

TODO: A whole section where there will be info on key management.

Using the SDK

There are a number of request that can be executed to the ledger, these are:

  • PublishMeasurementRequest
  • IssueGGORequest
  • TransferGGORequest
  • SplitGGORequest
  • RetireGGORequest

The first two are only for issuing bodies, and will be denied if tried.

To execute a request one must first import the ledger, batch and a request type

from origin_ledger_sdk import Ledger, Batch, TransferGGORequest

Transfer request

Next one can create a new TransferGGORequest, This request requires two keys as input. First key should be the private extended key that contains a GGO. Second should be the address where the GGO must be transferred to.

Batch

After the request has been created, we must create a batch using a another key. And then the request is added to the batch. Multiple request can be added to the same batch. Which insures all or none of the transactions are executed.

    batch = Batch(signer_key=key)
    batch.add_request(request)

BEWARE - everything done in one batch can be seen by anyone as a single batch and therefore know they have been performed by the same entity. So one should be careful about what one bundles in a single batch.

Executing a batch

Last thing to do is to send the batch to the ledger. Create an instance of the Ledger with the url to the public endpoint Everything on the ledger is asynchronous, so a handle is returned, on which a user can request the status of the batch.

ledger = Ledger('https://url-to-ledger')

# Send the batch to the ledger to execute.
handle = ledger.execute_batch(batch) 

# Request status of the batch.
status = ledger.get_batch_status(handle)

Source code

Make sure to upgrade your system packages for good measure:

pip install --upgrade --user setuptools pip pipenv

Then install project dependencies:

pipenv install

To run the tests:

pipenv run pytest

Push to pypi

python3 setup.py bdist_wheel
python3 -m twine upload dist/* --repository project_origin

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

Origin_Ledger_SDK-0.1.12-py3-none-any.whl (14.0 kB view details)

Uploaded Python 3

File details

Details for the file Origin_Ledger_SDK-0.1.12-py3-none-any.whl.

File metadata

  • Download URL: Origin_Ledger_SDK-0.1.12-py3-none-any.whl
  • Upload date:
  • Size: 14.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.6

File hashes

Hashes for Origin_Ledger_SDK-0.1.12-py3-none-any.whl
Algorithm Hash digest
SHA256 d4f2ebfcc5a0fab56cb78e39e574cf6306bfd1b94dbbc2a8ed0c3372ea0c70a1
MD5 44dde605aa5f1cca9bd23107be33efed
BLAKE2b-256 c4af468dd82009d8193d2331cdc005fabe05e2d55f55ec7998e2dd2ed61ba168

See more details on using hashes here.

Provenance

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