Skip to main content

A Python JSON-RPC client for the NEO blockchain.

Project description

NeoJsonRPC is a Python JSON-RPC client for the NEO blockchain. It implements the JSON-RPC methods of the API interface provided by NEO nodes (minus the methods requiring an opened wallet). The client also provides a high-level interface to invoke contract methods on the NEO blockchain.

Documentation

Online browsable documentation is available at https://neojsonrpc.readthedocs.io.

Requirements

Python 3.4+, Requests 2.0+.

Installation

To install NeoJsonRPC, please use pip (or pipenv) as follows:

$ pip install neojsonrpc

Basic usage

The first step to interact with the NEO JSON-RPC interface is to initialize a neojsonrpc.Client instance. The following examples respectively show how to get clients for the TestNet, the MainNet and an hypothetical local PrivNet:

>>> from neojsonrpc import Client
>>> testnet_client = Client.for_testnet()
>>> mainnet_client = Client.for_mainnet()
>>> privnet_client = Client(host='localhost', port='30333')

Then you can easily call some of the JSON-RPC methods provided by NEO nodes. Here are some examples:

>>> from neojsonrpc import Client
>>> client = Client.for_testnet()
>>> client.get_block_count()
973369
>>> client.get_contract_state('2c0fdfa9592814b0a938219e218e3a6b08615acd')
{'author': 'foobar',
 'code_version': '0.3',
# [...]
}

You can also invoke smart contract functions using the following methods:

>>> from neojsonrpc import Client
>>> client = Client.for_testnet()
>>> result = client.invoke_function('34af1b6634fcd7cfcff0158965b18601d3837e32', 'symbol', [])
{'gas_consumed': '0.217',
 'stack': [{'type': 'ByteArray', 'value': bytearray(b'TKN')}],
 'state': 'HALT, BREAK'}
>>> # Another convenient way to do the same operation is as follows:
>>> client.contract('34af1b6634fcd7cfcff0158965b18601d3837e32').symbol()
{'gas_consumed': '0.217',
 'stack': [{'type': 'ByteArray', 'value': bytearray(b'TKN')}],
 'state': 'HALT, BREAK'}

Authors

Morgan Aubert (@ellmetha) and contributors. See AUTHORS for more details.

License

MIT. See LICENSE for more details.

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

neojsonrpc-0.1.0.tar.gz (20.9 kB view details)

Uploaded Source

Built Distribution

neojsonrpc-0.1.0-py2.py3-none-any.whl (12.7 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file neojsonrpc-0.1.0.tar.gz.

File metadata

  • Download URL: neojsonrpc-0.1.0.tar.gz
  • Upload date:
  • Size: 20.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for neojsonrpc-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8c7d5576d493e0eb66b93602b5ea95304a930e1f163ce80102433fbab17b13f2
MD5 8304fb49418058a4a86de5f8585b04e7
BLAKE2b-256 8537f24dacc5dcbb4278f9b329ebabdcbc9f416c737f4d89442121177ec4c878

See more details on using hashes here.

File details

Details for the file neojsonrpc-0.1.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for neojsonrpc-0.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 7b80603284c09c07996925b54215c25ebe3b6d200a4bf5d3162a1240020ec458
MD5 ce634ed50bebfb015c43cdad6670622e
BLAKE2b-256 76392909a39b30d360cf1d7f0e586a9a400fdad798f9b31ae93d1c981f927d1d

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