async nano library for easy account management
Project description
Nano Wallet Library (nanowallet)
A modern, asynchronous Python library for interacting with the Nano cryptocurrency network. nanowallet supports read-only monitoring and authenticated operations via private key or seed+index, providing full transaction capabilities including sending, receiving, and sweeping funds.
Designed with type safety and robust error handling in mind.
Key Features
- Asynchronous: Built with
asynciofor efficient network communication. - Typed: Fully type-hinted for better developer experience and static analysis.
- Wallet Types:
NanoWalletReadOnly: Monitor accounts without exposing keys.NanoWalletAuthenticated: Operate a wallet using a private key (viacreate_wallet_from_private_key) or seed+index (viacreate_wallet_from_seed).
- Comprehensive Operations: Send, receive (specific blocks or all pending), sweep funds, check history, get account info.
- Safe Error Handling: Uses a
NanoResult[T]wrapper to prevent unexpected crashes, promoting explicit error checks. - Automatic State Management: Handles Nano's sequential block requirements automatically after operations.
- Configurable: Set default representatives, control work generation sources.
- Automatic Retry: Includes methods like
send_with_retryfor handling transient network/RPC issues.
Installation
pip install nanowallet
Requires Python 3.8+
Quick Start
import asyncio
from nanowallet import create_wallet_from_seed, NanoWalletRpc, WalletConfig
from nanowallet.utils import sum_received_amount
async def main():
# Connect to a Nano node
rpc = NanoWalletRpc(url="http://localhost:7076")
wallet_config = WalletConfig(use_work_peers=False) # Optional configuration
# Create wallet from seed and index
# ------------------------------------------------------------
wallet = create_wallet_from_seed(
rpc=rpc,
seed="0000000000000000000000000000000000000000000000000000000000000000",
index=0,
config=wallet_config,
)
# Check balance
# ------------------------------------------------------------
response = await wallet.balance_info()
balance_info = response.unwrap() # Option 1 - .unwrap() to handle the response
print(f"Balance: {balance_info.balance} NANO")
print(f"Receivable Balance: {balance_info.receivable} NANO")
# Receive all pending transactions
# ------------------------------------------------------------
result = await wallet.receive_all()
if result.success: # Option 2 - check success
received_amount = sum_received_amount(result.value)
print(f"Received {len(result.value)} blocks!")
print(f"Received amount: {received_amount.amount} NANO")
else:
print(f"Error receiving blocks: {result.error}")
# Send entire balance to another account
# ------------------------------------------------------------
destination = "nano_3msc38fyn67pgio16dj586pdrceahtn75qgnx7fy19wscixrc8dbb3abhbw6"
send_result = await wallet.sweep(
destination, sweep_pending=True
) # Sweeps pending/receivable balance + confirmed balance
try:
send_hash = send_result.unwrap()
print(f"Sent! Block hash: {send_hash}")
except Exception as e:
print(f"Error sending: {e}")
asyncio.run(main())
That's it! The library handles all the complexity of work generation, block signing, and state management for you.
Documentation
For full details on wallet types, methods, error handling, and configuration, see the Full Documentation.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nanowallet-0.1.6.tar.gz.
File metadata
- Download URL: nanowallet-0.1.6.tar.gz
- Upload date:
- Size: 56.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5da5aa8655b1a7784f5129b00a45b037cea4b07a933a53ef3dbf3b25ea4dfd64
|
|
| MD5 |
6ce4fb0559b2f23d5573aa54cc846889
|
|
| BLAKE2b-256 |
4fb6bd724c87755ee6ee35effb459ab19301e9fce879010f03e7cb769ed3bd81
|
File details
Details for the file nanowallet-0.1.6-py3-none-any.whl.
File metadata
- Download URL: nanowallet-0.1.6-py3-none-any.whl
- Upload date:
- Size: 40.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
76f671f8860f3f26fb5254d6f8c67da82fa72fee08e5de3a2c1d2f279ac65581
|
|
| MD5 |
75e104c4db53fcc8379de61af57ad551
|
|
| BLAKE2b-256 |
089ef5e327eccf177a1752e8ecd7aa27ef7487509e1cd6f2e51c9ba42718b190
|