https://github.com/aaroncox/chainsync
a framework for streaming blockchain transactions/operations into other mediums
https://github.com/aaroncox/chainsync
blockchain json-rpc python3 steem
Last synced: 5 months ago
JSON representation
a framework for streaming blockchain transactions/operations into other mediums
- Host: GitHub
- URL: https://github.com/aaroncox/chainsync
- Owner: aaroncox
- License: mit
- Created: 2018-03-09T02:45:09.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-06-15T04:17:30.000Z (almost 8 years ago)
- Last Synced: 2026-01-05T00:17:16.028Z (5 months ago)
- Topics: blockchain, json-rpc, python3, steem
- Language: Python
- Homepage:
- Size: 123 KB
- Stars: 16
- Watchers: 1
- Forks: 6
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
## ChainSync
[](https://github.com/aaroncox/chainsync)
[](https://github.com/aaroncox/chainsync/issues)
[](https://travis-ci.org/aaroncox/chainsync)
A simple library to stream blocks and operations for digesting into other mediums.
### Install
`pip install chainsync`
#### Requirements
`pip install -r requirements.txt`
- [jsonrpcclient](https://github.com/bcb/jsonrpcclient)
### Example - streaming blocks
``` python
from chainsync import ChainSync
from chainsync.adapters.steemv2 import SteemV2Adapter
adapter = SteemV2Adapter(endpoints=['https://api.steemit.com'])
chainsync = ChainSync(adapter)
for dataType, data in chainsync.stream(['blocks']):
print("{} - {}".format(data['block_num'], data['witness']))
```
### Example - streaming operations
``` python
from chainsync import ChainSync
from chainsync.adapters.steemv2 import SteemV2Adapter
adapter = SteemV2Adapter(endpoints=['https://api.steemit.com'])
chainsync = ChainSync(adapter)
for dataType, data in chainsync.stream(['ops']):
print("{} - {}".format(data['block_num'], data['operation_type']))
```
### Example - streaming operations with a whitelist
``` python
from chainsync import ChainSync
from chainsync.adapters.steemv2 import SteemV2Adapter
adapter = SteemV2Adapter(endpoints=['https://api.steemit.com'])
chainsync = ChainSync(adapter)
for dataType, op in chainsync.stream(['ops'], whitelist=['vote']):
print("{} - {} by {}".format(op['block_num'], op['operation_type'], op['voter']))
```
### Example - custom adapters
A custom adapter can be supplied to allow parsing of a specific blockchain
``` python
from chainsync import ChainSync
from chainsync.adapters.decent import DecentAdapter
adapter = DecentAdapter(endpoints=['http://api.decent-db.com:8090'])
chainsync = ChainSync(adapter)
for block in chainsync.stream(['blocks']):
print("{} - {}".format(block['block_num'], block['witness']))
```
## Adapters
Adapters can be added and configured to allow access to other similar blockchains.
A current list of adapters can be found in the `./chainsync/adapters` folder.