Skip to main content

Another unofficial Python package for managing Nano Cryptocurrency

Project description

https://github.com/ipazc/nanoblocks/raw/main/docs/source/tutorial/images/logo_big.png https://badge.fury.io/py/nanoblocks.svg

NanoBlocks is an unofficial Python package built to ease the access to NANO cryptocurrency. It is intended to give an easy interface for programmers to play with the Nano Network, allowing most Nano common operations which includes creating new wallets and accounts, checking accounts information, making transactions and more.

An extensive documentation of the package can be found by reading the docs.

Installation

NanoBlocks can be installed through pip:

pip install nanoblocks

Getting started

It is required to have a Nano node installed and configured in order to release all the functionalities that this package can give; even though it can still work offline for certain operations (like creating wallets, accounts, and building and signing blocks).

It is highly encouraged to get access to the node RPC and WebSocket servers. A guide for installation of the node can be found here. Furthermore, a nano-work-server access for work generation is also recommended to enable transactions.

Everything starts with the NanoNode and the NanoNetwork classes:

>>> from nanoblocks.node import NanoNode
>>> from nanoblocks.network import NanoNetwork

>> node = NanoNode("http://localhost:7076", "ws://localhost:7078")
>> node
[Node http://localhost:7076 (Nano V21.2)]

>> network = NanoNetwork(node)
>> network
[Node http://localhost:7076 (Nano V21.2)] (270 peers; 15362838 account)

Having a NanoNetwork class instance, accounts in the network can be accessed as easy as follows:

>>> account = network.accounts["nano_39a73oy5ungrhxy5z5oao1xso4zo7dmgpjd4u74xcrx3r1w6rtazuouw6qfi"]
>>> account
nano_39a73oy5ungrhxy5z5oao1xso4zo7dmgpjd4u74xcrx3r1w6rtazuouw6qfi (
    Total blocks: 733
    Total balance: 0.000002000000000000000000000002 NANO
    Confirmed balance: 0.000000000000000000000000000000 NANO
    Pending balance: 0.000002000000000000000000000002 NANO
    Last confirmed payment: 2020-12-02 01:30:39+01:00
    Is virtual: False

Blocks can be accessed as follows:

>>> block = network.blocks["4FEC4BDD078C741F599221C67C8BE6493C872EF9B30968BBF4991640FFF42DA2"]
>>> block
[Block #4 from account nano_39a73oy5ungrhxy5z5oao1xso4zo7dmgpjd4u74xcrx3r1w6rtazuouw6qfi]
    Type: receive
    Hash: 4FEC4BDD078C741F599221C67C8BE6493C872EF9B30968BBF4991640FFF42DA2
    Source account: nano_39a73oy5ungrhxy5z5oao1xso4zo7dmgpjd4u74xcrx3r1w6rtazuouw6qfi
    Amount: 0.000040000000000000000000000000
    Local date: 1970-01-01 01:00:00+01:00

And wallets can be accessed as follows:

# To access an existing wallet by using the 64-Bytes seed:
>>> wallet = network.wallets["7F632A80ECCC54A058602CD64A81D23A6B4D7320562E4767C9EB0BBB1151CDF2"]

# Alternatively, it can be accessed with the BIP-39 24 words:
>>> wallet = network.wallets[['legal', 'bone', 'parent', 'sunset', 'shed', 'expand', 'ghost', 'airport', 'stone', 'favorite', 'innocent', 'inquiry', 'regular', 'ridge', 'life', 'shift', 'electric', 'dinner', 'kiss', 'blast', 'rain', 'pottery', 'daughter', 'execute']]

# Wallet information can be printed out
>>> print(wallet.seed)
7F632A80ECCC54A058602CD64A81D23A6B4D7320562E4767C9EB0BBB1151CDF2

>>> print(wallet.mnemonic)
['legal', 'bone', 'parent', 'sunset', 'shed', 'expand', 'ghost', 'airport', 'stone', 'favorite', 'innocent', 'inquiry', 'regular', 'ridge', 'life', 'shift', 'electric', 'dinner', 'kiss', 'blast', 'rain', 'pottery', 'daughter', 'execute']

Which allows to access accounts as follows:

>>> account_0 = wallet.accounts[0]

Easy, right? Check all what you can do by reading the docs!

LICENSE

This package is license under the MIT license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

nanoblocks-0.0.5-py3-none-any.whl (47.9 kB view details)

Uploaded Python 3

File details

Details for the file nanoblocks-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: nanoblocks-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 47.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.5.0.1 requests/2.25.1 setuptools/52.0.0.post20210125 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.7.10

File hashes

Hashes for nanoblocks-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 821f9b0650a70de319a8edae90de62622a5eee6d6b720f960258cfe08b02b81b
MD5 68be2ee4a77d02306ae177e0a13a4282
BLAKE2b-256 23810ecf1d08b3bebec9f9b469accd419fac964d9211f653dd7f7ac66e5932fb

See more details on using hashes here.

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