Metadata-Version: 2.2
Name: knishioclient
Version: 0.6.0.post1
Summary: Knish.IO Python API Client
Home-page: https://github.com/WishKnish/KnishIO-Client-Python
Author: Yuri Kizilov
Author-email: y.kizilov.sev@yandex.ru
License: LICENSE
Project-URL: Homepage, https://knish.io
Project-URL: GitHub: issues, https://github.com/WishKnish/KnishIO/issues
Project-URL: GitHub: wiki, https://github.com/WishKnish/KnishIO/wiki
Project-URL: GitHub: source, https://github.com/WishKnish/KnishIO
Project-URL: Docs, https://docs.knish.io
Keywords: wishknish,knishio,blockchain,dag,client
Platform: all
Classifier: Development Status :: 2 - Pre-Alpha
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Utilities
Requires-Python: >=3.6.0
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: libnacl>=2.1.0
Requires-Dist: numpy>=2.1.3
Requires-Dist: base58>=2.1.1
Requires-Dist: setuptools>=75.1.0
Requires-Dist: aiohttp>=3.11.11
Requires-Dist: cryptography>=44.0.0
Requires-Dist: pycryptodome>=3.21.0
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: keywords
Dynamic: license
Dynamic: platform
Dynamic: project-url
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# 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:
```python
data = [
  {
    'key': 'name',
    'value': 'foo'
  },
  {
    'key': 'email',
    'value': 'bar'
  },
  #...
]
```
or
```python
data = {
  'name': 'foo',
  'email': 'bar',
  #...
}
```
3. 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.
4. Sign the molecule with the user secret: `molecule.sign()`
5. Make sure everything checks out by verifying the molecule:
```python
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
    }
  }
```
2. Use your favorite GraphQL client to send the mutation to a Knish.IO node with the molecule you've signed as the only parameter.
3. 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.
