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.4.tar.gz (22.0 kB view details)

Uploaded Source

Built Distribution

kaspad_client-1.0.4-py3-none-any.whl (25.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: kaspad_client-1.0.4.tar.gz
  • Upload date:
  • Size: 22.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.19

File hashes

Hashes for kaspad_client-1.0.4.tar.gz
Algorithm Hash digest
SHA256 193cdfe0626294b67c7c5e230e6ca2a5c471fcb958bb348844be59f7a14063f5
MD5 336b21bd7fb2451ed764281c65c393e2
BLAKE2b-256 cebffbd36bba2fc9a399fd9a1d74dfbd3d9ba304233919d6b20ef99936abb427

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for kaspad_client-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 a7fa6c6c08007b39cd548717ac3e63a6251990040f906770a993601b1a82497b
MD5 cd4dd44b24e1febec7681aaa5602f264
BLAKE2b-256 6cdf31c2463ea081db9771427eb7fa6ef3b3ae13b4c3c2ad28a48d192d5fbc5d

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