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.


Online browsable documentation is available at


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()
>>> 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'}


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


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.

Files for neojsonrpc, version 0.1.1
Filename, size File type Python version Upload date Hashes
Filename, size neojsonrpc-0.1.1-py2.py3-none-any.whl (12.7 kB) File type Wheel Python version 3.6 Upload date Hashes View
Filename, size neojsonrpc-0.1.1.tar.gz (21.1 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page