Skip to main content

This is a simple gRPC client for a python application which communiactes with the Kaspa node called KASPAD. Note: This module is created for the RUST version and might be not compatible with the go written node.

Project description

This is a simple gRPC client for a python application which communiactes with the Kaspa node called KASPAD.

The module is based on asyncio, since the Kaspa BlockDAG is unbelievable fast and also needs the support of notifications.

Usage: see playground.py

import asyncio

from kaspad_client.modules.KaspadClient import KaspadClient


async def main():
    kaspad_client = KaspadClient("127.0.0.1", 16110)

    # print the info message
    print(await kaspad_client.get_info())

    # returns
    # {'getInfoResponse': {'p2pId': 'a9728d7e-c07b-4641-936c-6c7442b819f8', 'serverVersion': '0.13.4',
    # 'isUtxoIndexed': True, 'isSynced': True, 'hasNotifyCommand': True, 'hasMessageId': True,
    # 'mempoolSize': '0'}, 'id': '0'}


    # now let's set up some notifications
    # the decorator registers an async callback function and requests the notification automatically

    @kaspad_client.notify_virtual_daa_score_changed
    async def received_new_daa_score(c):
        print(f"The DAA score is: {c['virtualDaaScoreChangedNotification']['virtualDaaScore']}")

    @kaspad_client.notify_virtual_daa_score_changed
    async def received_new_daa_score2(c):
        print(f"The DAA2 score is: {c['virtualDaaScoreChangedNotification']['virtualDaaScore']}")

    @kaspad_client.notify_block_added
    async def received_new_daa_score(c):
        print(f"New Kaspa block: {c['blockAddedNotification']['block']['verboseData']['hash']}")

    # wait to see some notifcations :-)
    await asyncio.sleep(60)



asyncio.run(main())

Donation

We are doing this in our free time. Please consider a donation if this helps! Thank you!

kaspa:qrlsm9tvmak6909pr9f35g6scapz5t689nhhls54sfxx5m46sn085ajhn9hn8

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

kaspad_client-1.0.6.tar.gz (25.0 kB view details)

Uploaded Source

Built Distribution

kaspad_client-1.0.6-py3-none-any.whl (28.6 kB view details)

Uploaded Python 3

File details

Details for the file kaspad_client-1.0.6.tar.gz.

File metadata

  • Download URL: kaspad_client-1.0.6.tar.gz
  • Upload date:
  • Size: 25.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.21

File hashes

Hashes for kaspad_client-1.0.6.tar.gz
Algorithm Hash digest
SHA256 89de7d2d3a2cabd44ad15a84be2ba08f1e8800c8e102dddaf9a9b82a35216f09
MD5 a4706fc559101a8ced63d825badaf4ad
BLAKE2b-256 475ce5bb3613a7e059ba23e4ab45aabf6c55bc1e335fd9ba99d0175f71219ba1

See more details on using hashes here.

File details

Details for the file kaspad_client-1.0.6-py3-none-any.whl.

File metadata

  • Download URL: kaspad_client-1.0.6-py3-none-any.whl
  • Upload date:
  • Size: 28.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.21

File hashes

Hashes for kaspad_client-1.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 a31ccbd216ee78b754cf81a48cba5c992ed02d35aff30c71683e458d6aae9ea3
MD5 c2ecdf8a6df9fc860281d6927ed745ca
BLAKE2b-256 bdbb0b3aff8b93f43f80a6b34ea5e3908a3b70a5794959d47dfc5b3cbb680bab

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