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.tar.gz (38.1 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-py3-none-any.whl (39.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: knishioclient-0.6.0.tar.gz
  • Upload date:
  • Size: 38.1 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.tar.gz
Algorithm Hash digest
SHA256 d976f87ff52ab4081ed99c44c4e1fd9a798f7ed11c321a32dfe897d9dcf581b3
MD5 3f19704de2d9f2a0ee7b50cb26eed661
BLAKE2b-256 b9a37d6db278ad551cb7d7bb8a1861284f9bc6888fc42660cacb3447f22e71d9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: knishioclient-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 39.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for knishioclient-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ab60a04f6cc9c53b029effabda3dd0c93a37a4231d4f878ec8455bcd9666f1a4
MD5 e57dba32ba1f732099d56242ae6da32b
BLAKE2b-256 3fa70bf15e5ce9bd000d7af6280931d13775599d64b4a79f15085c4e857e338d

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