Skip to main content

Mersennet

Mersennet Python SDK

MIT license CI Docs Telegram

Python client for Mersennet - JSON-RPC, CLOB (order book), and WebSocket subscriptions.

Installation

pip install "git+https://github.com/mersennet/sdk-python.git@v0.1.0"   # PyPI publication pending

Or from source:

cd sdk-python
pip install -e .

Quick Start

from mersennet import MersennetProvider, MersennetOrders

provider = MersennetProvider("http://localhost:8545")

# Chain info
print("Chain ID:", provider.chain_id())
print("Block:", provider.block_number())
print("Gas price:", provider.gas_price())

# Account
balance = provider.get_balance("0xYourAddress")
print("Balance:", balance)

# Order book
orders = MersennetOrders(provider)
book = orders.get_order_book(1)
print("Bids:", book.bids)
print("Asks:", book.asks)

API Reference

MersennetProvider

Method Description
get_block(number, include_txs) Get block by number or "latest"
get_block_by_hash(hash, include_txs) Get block by hash
get_transaction(hash) Get transaction by hash
get_balance(address) Get balance (hex string)
get_nonce(address) Get nonce
send_raw_transaction(raw_tx) Send signed transaction
call(tx_object) Simulate call (eth_call)
chain_id() Chain ID
block_number() Latest block number
view_notes(grant_id_hex, limit, cursor_hex) Grant-gated encrypted note export
gas_price() Current gas price

MersennetOrders

Method Description
add_market(base, quote, lot, tick) Add market (admin)
place_order(market, side, price, amount, tif, owner) Place order
cancel_order(order_id) Cancel order
get_order_book(market) Get order book
get_trades(market) Get recent trades
get_positions(address, market) Get positions

MersennetSubscriber (WebSocket)

Method Description
connect() Connect to WebSocket
disconnect() Disconnect
subscribe_blocks(callback) Subscribe to new blocks
subscribe_trades(market, callback) Subscribe to trades
subscribe_logs(callback, topics, address) Subscribe to logs
unsubscribe(id) Unsubscribe

Shielded Notes

Use view_notes to fetch encrypted note envelopes, then call scan_granted_notes with a decrypt function that applies your granted viewing material locally.

from mersennet import GrantedViewingMaterial, MersennetProvider, make_mock_note_decryptor, scan_granted_notes

provider = MersennetProvider("http://localhost:8545")

material = GrantedViewingMaterial(
    grant_id_hex="0x...",
    recipient_public_key="0x...",
    decrypt_note_ciphertext=make_mock_note_decryptor("0x..."),
)

result = scan_granted_notes(provider, material, limit=64)
print("Decrypted notes:", len(result.notes))

See the runnable end-to-end example in examples/view_notes_end_to_end.py.

WebSocket Example

from mersennet import MersennetSubscriber

sub = MersennetSubscriber("ws://localhost:8545")
sub.connect()

def on_block(block):
    print("New block:", block)

sub_id = sub.subscribe_blocks(on_block)
# ...
sub.unsubscribe(sub_id)
sub.disconnect()

Error Handling

from mersennet.provider import MersennetError

try:
    balance = provider.get_balance("0x...")
except MersennetError as e:
    print(f"Error {e.code}: {e}")

Part of the Mersennet ecosystem — trade · explorer · docs · run a node · Telegram
© 2026 Mersennet Foundation · MIT License · security@mersennet.com

Release files for mersennet-sdk 0.1.1

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

Source distribution (sdist)

Source distribution for mersennet-sdk 0.1.1
File Size Uploaded
mersennet_sdk-0.1.1.tar.gz 25.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mersennet-sdk 0.1.1
File Interpreter ABI Platform
mersennet_sdk-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 50.6 kB

Release files / mersennet_sdk-0.1.1.tar.gz

Download URL mersennet_sdk-0.1.1.tar.gz
Size 25.8 kB
Tags Source
SHA-256 checksum
How to use checksums
1d68c693411628ba86d25570380bcf51d9d99b1900cbfe40781ac8dbf8b6a4aa
BLAKE2b-256 checksum
How to use checksums
8e177dec7929a412bf7160c0c238da35b4010b1bff3a95e1bddbf01621724c94
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 26, 2026.

Transparency log

Release files / mersennet_sdk-0.1.1-py3-none-any.whl

Download URL mersennet_sdk-0.1.1-py3-none-any.whl
Size 24.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5794678ed18955fce287efbc6cbe296c3e8100cf021036988b82e395d662fc5f
BLAKE2b-256 checksum
How to use checksums
a75b601e4d49f383025d55d959751e6499bee5a44f80cbc17c3a269ce1323246
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 26, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

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