Skip to main content

async nano rpc library with dynamic method generation per node version

Project description

NanoRPC

NanoRPC is a Python library for interacting with Nano cryptocurrency nodes via their JSON-RPC API. It provides an easy-to-use interface to execute RPC (Remote Procedure Call) commands supported by different versions of Nano nodes.

Features

  • Compatible with Python 3.7 and higher.
  • Supports asynchronous operations using asyncio and aiohttp.
  • Automatically adjusts available RPC methods based on the version of the connected Nano node.
  • Provides a simple and intuitive API for executing RPC commands.

Requirements

  • Python 3.7 and higher
  • aiohttp library

Installation

You can install NanoRPC using pip:

pip install nanorpc

Usage

Here's a basic example of how to use NanoRPC to interact with a Nano node:

import asyncio
from nanorpc.client import NanoRpcTyped

async def main():
    # Connect to a Nano node
    rpc = NanoRpcTyped(url='http://localhost:7076')

    # Execute an RPC command
    block_count = await rpc.block_count()
    print(f"Current block count: {block_count}")

    # Execute another RPC command
    version_info = await rpc.version()
    print(f"Node version: {version_info}")

    #pass mandatory input as args* and optional as kwargs*
    account = "nano_3msc38fyn67pgio16dj586pdrceahtn75qgnx7fy19wscixrc8dbb3abhbw6"
    account_info = await rpc.account_info(account, include_confirmed="true", representative="true", receivable="true", weight="true")
    print(f"Account info: {account_info}")

# Run the main function within an asyncio event loop
asyncio.run(main())

Error Handling

NanoRPC includes several error handling mechanisms. If an RPC command fails or if a network issue is encountered, the library will retry the request for a specified number of times. If all retries are exhausted, the library will raise a MaxRetriesExceededError.

Available RPC Commands

NanoRPC provides access to various RPC commands based on the connected Nano node version. For a complete list of available commands and their parameters, please refer to the versions folder in this repository.

Official RPC Documentation

For detailed documentation on the Nano RPC protocol and available commands, please visit the Nano RPC Documentation page.

Contributing

Contributions to NanoRPC are welcome! If you find any issues, have suggestions, or would like to contribute enhancements or new features, please open an issue or submit a pull request.

License

NanoRPC is licensed under the MIT License. See the LICENSE file for more information.

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

nanorpc-0.1.6.tar.gz (12.1 kB view details)

Uploaded Source

Built Distribution

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

nanorpc-0.1.6-py3-none-any.whl (31.4 kB view details)

Uploaded Python 3

File details

Details for the file nanorpc-0.1.6.tar.gz.

File metadata

  • Download URL: nanorpc-0.1.6.tar.gz
  • Upload date:
  • Size: 12.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.6

File hashes

Hashes for nanorpc-0.1.6.tar.gz
Algorithm Hash digest
SHA256 3bc28a0379835cfc199e10b642bb7f2c03fd5396d9282fa3705b994f025ef999
MD5 9770ab9cf7cb261f258fb5c040029142
BLAKE2b-256 a9d8b497ba2ff9dc0895acf3df47c077aa046a6469974ed3b0ddd455046aba46

See more details on using hashes here.

File details

Details for the file nanorpc-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: nanorpc-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 31.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.6

File hashes

Hashes for nanorpc-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 ebb0403068777b862447769be35720d1fcb2836cd2eace086427f669f53aa6a3
MD5 144818ecd90a456f01871ba9ac487ef2
BLAKE2b-256 e5d1c84578dae5b2159e0a180abbd7bc3c5799af01412209e083718a93ccdfa1

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