Skip to main content

Knish.IO Python API Client

Project description

Knish.IO Python Client

This is an experimental Python implementation of the Knish.IO API client. Its purpose is to expose class libraries for building and signing Knish.IO Molecules, composing Atoms (presently "A", "C", "M", "U", "I", "T" and "V" isotopes are supported), and generating Wallet addresses (public keys) and private keys as per the Knish.IO Technical Whitepaper.

Getting Started

  1. pip install knishio-client-python
  2. Inside your application code, from knishioclient.models import Molecule, Wallet
  3. Build a 2048-character user secret via your preferred methodology (random string?).
  4. Initialize a wallet with wallet = Wallet(secret, token)

You can also specify a third, optional position argument represents the private key index (hexadecimal), and must NEVER be used more than once. It will be generated randmly if not provided.

A fourth argument, salt_length, helps tweak the length of the random position, if the parameter is not provided.

The token argument (string) is the slug for the token being transacted with. Knish.IO anticipates user's personal metadata being kept under the USER token.

Building Your Molecule

  1. Build your molecule with molecule = Molecule(secret, source_wallet, remainder_wallet, cell_slug) The cell_slug argument represents the slug for your Knish.IO cell. It's meant to segregate molecules of one use case from others. Leave it null if not sure.
  2. For a "M"-type molecule, build your metadata as an array of objects, for example:
data = [
  {
    'key': 'name',
    'value': 'foo'
  },
  {
    'key': 'email',
    'value': 'bar'
  },
  #...
]

or

data = {
  'name': 'foo',
  'email': 'bar',
  #...
}
  1. Initialize the molecule as "M"-type: molecule.init_meta(data, meta_type, meta_id) The meta_type and meta_id arguments represent a polymorphic key to whatever asset you are attaching this metadata to.
  2. Sign the molecule with the user secret: molecule.sign()
  3. Make sure everything checks out by verifying the molecule:
from knishioclient.models import Molecule, Wallet

source_wallet = Wallet(secret, token)
remainder_wallet = Wallet(secret, token)

molecule = Molecule(secret, source_wallet, remainder_wallet, cell_slug)

molecule.init_meta(data, meta_type, meta_id)
molecule.sign()

if molecule.check():
  #...  Do stuff? Send the molecule to a Knish.IO node, maybe?

Broadcasting

  1. Knish.IO nodes use GraphQL to receive new molecules as a Mutation. The code for the mutation is as follows:
  mutation MoleculeMutation($molecule: MoleculeInput!) {
    ProposeMolecule(
      molecule: $molecule,
    ) {
      molecularHash,
      height,
      depth,
      status,
      reason,
      reasonPayload,
      createdAt,
      receivedAt,
      processedAt,
      broadcastedAt
    }
  }
  1. Use your favorite GraphQL client to send the mutation to a Knish.IO node with the molecule you've signed as the only parameter.
  2. The status field of the response will indicate whether the molecule was accepted or rejected, or if it's pending further processing. The reason and reasonPayload fields can help further diagnose and handle rejections.

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

knishioclient-0.6.0.post1.tar.gz (43.9 kB view details)

Uploaded Source

Built Distribution

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

knishioclient-0.6.0.post1-py3-none-any.whl (45.9 kB view details)

Uploaded Python 3

File details

Details for the file knishioclient-0.6.0.post1.tar.gz.

File metadata

  • Download URL: knishioclient-0.6.0.post1.tar.gz
  • Upload date:
  • Size: 43.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for knishioclient-0.6.0.post1.tar.gz
Algorithm Hash digest
SHA256 673bbab28f8058c8adb1bba3cf3fcbe419786d565bbf1e654960fd00bf85a0d6
MD5 c413d34b0a3d90740404abd8cb63b091
BLAKE2b-256 ea85958aa5396dec2f21e06adc0dfcff4fcefb60f3bd9bd26c69dbdbec3da789

See more details on using hashes here.

File details

Details for the file knishioclient-0.6.0.post1-py3-none-any.whl.

File metadata

File hashes

Hashes for knishioclient-0.6.0.post1-py3-none-any.whl
Algorithm Hash digest
SHA256 d7000f837c5d3b058023e7bb0db6ecfddc2cd3b4d7b2c78c9a4ba0e5fbd9be49
MD5 fb27cd935805e0462b1362099b4a4dea
BLAKE2b-256 7f3f229309cc505ec985f1fa0782216d436c140337d45b2f82e10e75e2306bc8

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