Skip to main content


OBM

Async blockchain nodes interacting tool with ORM-like API
Documentation • Releases



Build Status PyPi Version Documentation Status Code style: Black

Motivation

There are a lot of cryprocurrencies and many of them maintain their own blockchain. Essentially, blockchain is a database, therefore you can interact with it in the same way as with the ordinary database. If you follow how the database interacting tools evolved, you can see that at low-level there are database adapters (such as psycopg2, pymongo, etc.) on top of which are built more abstract and convenient ORMs/ODMs (sqlalchemy, mongo-engine, etc.) Blockchain technology, that is still in its infancy, really lacks similar tools for developers. The goal of this project is to become such a tool. It provides both low-level adapters and high-level ORM-like API for interacting with blockchain node. Also, it's worth clarifying, that ordinary databases have already reached stable APIs unlike blockchain nodes that just provide scattered JSON RPC or/and other non-standard API. OBM is trying to do typically things in universal way. Thereby standardization and unification become the second project goal.

Installation

pip install obm

Requirements

Features

  • Async and sync top-level ORM-like API
  • BTC (bitcoin-core) and ETH (geth) support
  • Implemented transaction fetching for Ethereum
  • Unified API for sending/receiving transactions, addresses creation and fee estimating

In future

  • NodePool model for node horizontal scaling
  • Support for: ETH, ETC, DASH, BCH, LTC, ZEC, XEM, XRP, etc.

Example

It uses python built-in async REPL to show asynchronous API features. Use to launch python -m asyncio (Python 3.8 or higher).

>>> import asyncio
>>> from obm import models
>>> btc = models.Node(
...     name="bitcoin-core",
...     rpc_port=18332,
...     rpc_username="testnet_user",
...     rpc_password="testnet_pass",
... )
>>> eth = models.Node(
...     name="geth",
...     rpc_port=8545,
... )
>>> # Transaction fetching
>>> await btc.fetch_recent_transactions(limit=1)
[
    {
        "txid": "cc8c9f7a86261fcb00d68b62073c740b8a0e14079d67e44fd726e0de2954c69a",
        "from_address": "2NAmne8BsSXWbV5iStkVzL4vW7Z4F6a5o68",
        "to_address": "2NAmne8BsSXWbV5iStkVzL4vW7Z4F6a5o68",
        "amount": Decimal("0.00000866"),
        "fee": Decimal("0.00000134"),
        "block_number": 1722208,
        "category": "oneself",
        "timestamp": 1588076404,
        "info": {...},  # original content
    }
]
>>> await eth.fetch_recent_transactions(limit=1)
[
    {
        "txid": "0x4831820db0de1aad336c7a083b2504ad0b91eba293e5d7a6fa3bef49f660766c",
        "from_address": "0xe1082e71f1ced0efb0952edd23595e4f76840128",
        "to_address": "0xb610de1be67b10c746afec8fe74ad14d97e34146",
        "amount": Decimal("0.000029"),
        "fee": Decimal("0.000021"),
        "block_number": 6394779,
        "category": "oneself",
        "timestamp": None,
        "info": {...},  # original content
    }
]
>>> # Transaction sending
>>> await btc.send_transaction(
...     amount=0.00001,
...     to_address='2NAmne8BsSXWbV5iStkVzL4vW7Z4F6a5o68',
...     subtract_fee_from_amount=True,
... )
{
    "txid": "cc8c9f7a86261fcb00d68b62073c740b8a0e14079d67e44fd726e0de2954c69a",
    "from_address": "2NAmne8BsSXWbV5iStkVzL4vW7Z4F6a5o68",
    "to_address": "2NAmne8BsSXWbV5iStkVzL4vW7Z4F6a5o68",
    "amount": Decimal("0.00000866"),
    "fee": Decimal("0.00000134"),
    "block_number": None,
    "category": "oneself",
    "timestamp": 1588076404,
    "info": {...},
}
>>> await eth.send_transaction(
...     amount=0.00005,
...     from_address='0xe1082e71f1ced0efb0952edd23595e4f76840128',
...     to_address='0xb610de1be67b10c746afec8fe74ad14d97e34146',
...     subtract_fee_from_amount=True,
...     password="abc",
... )
{
    "txid": "0x4831820db0de1aad336c7a083b2504ad0b91eba293e5d7a6fa3bef49f660766c",
    "from_address": "0xe1082e71f1ced0efb0952edd23595e4f76840128",
    "to_address": "0xb610de1be67b10c746afec8fe74ad14d97e34146",
    "amount": Decimal("0.000029"),
    "fee": Decimal("0.000021"),
    "block_number": None,
    "category": "oneself",
    "timestamp": None,
    "info": {...},
}

Is OBM production ready?

The project is now under active development and it haven't reached the stable API yet. Use at your own risk and lock dependency version on minore.

Contributing

See CONTRIBUTING.rst for instructions.

Support the developer

Sponsors

Special thanks for Swapzilla project that paid me part of the development.

swapzilla-logo

You can also become the sponsor and get priority development of the features you require. Just contact me.

Buy me a beer

BTC 179B1vJ8LvAQ2r9ABNhp6kDE2yQZfm1Ng3

Metadata

Release files for obm 0.0.27

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for obm 0.0.27
File Size Uploaded
obm-0.0.27.tar.gz 19.2 kB Details

Release files / obm-0.0.27.tar.gz

Download URL obm-0.0.27.tar.gz
Size 19.2 kB
Tags Source
SHA-256 checksum
How to use checksums
1ba78f066f3b75c2e87046c60e80e17843758c46f6bb774fd034357dc8198e84
BLAKE2b-256 checksum
How to use checksums
02c9b1ca1979a18b1906918622c789e13e5ceb1ceae815511e925478b125a997
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3+

Release history Release notifications | RSS feed

This release

0.0.27 This release

1 release file

0.0.26

1 release file

0.0.25

1 release file

0.0.24

1 release file

0.0.23

1 release file

0.0.22

1 release file

0.0.21

1 release file

0.0.20

1 release file

0.0.19

1 release file

0.0.16

1 release file

0.0.15

1 release file

0.0.14

1 release file

0.0.13

1 release file

0.0.12

1 release file

0.0.11

1 release file

0.0.10

1 release file

0.0.9

1 release file

0.0.8

1 release file

0.0.7

1 release file

0.0.6

1 release file

0.0.5

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page