LangChain tools for NEAR blockchain event subscriptions with filtering and reliable reconnection
Project description
near-langchain-event-listener
LangChain tools for monitoring NEAR blockchain events with account subscriptions, event-type filtering, parsed event payloads, callback triggering, and reliable RPC reconnection.
Features
- Subscribe to account-level events
- Filter by event type (
transfer,function_call,event_json,receipt_log) - Parse event data from transactions and
EVENT_JSONlogs - Trigger HTTP callbacks for matched events
- Retry and endpoint failover for resilient RPC access
Installation
pip install near-langchain-event-listener
Quick Start (LangChain)
import json
from near_langchain_event_listener import get_near_event_listener_tools
tools = {tool.name: tool for tool in get_near_event_listener_tools()}
sub = json.loads(tools["near_event_subscribe_account"].invoke({
"account_id": "example.near",
"event_types": ["transfer", "function_call"],
"callback_url": "https://example.com/callback"
}))
print(sub["subscription_id"])
poll = json.loads(tools["near_event_poll"].invoke({
"network": "mainnet",
"max_blocks": 10,
"max_events": 100
}))
print(poll["matched_events"])
Tool Names
near_event_subscribe_accountnear_event_unsubscribenear_event_list_subscriptionsnear_event_poll
API Notes
- Subscriptions are in-memory state by default.
- First poll starts at current head block to avoid large historical backfill.
- Callback delivery uses HTTP POST and retries on failure.
- RPC reconnection uses multiple endpoints and retry backoff.
Development
python -m venv .venv
source .venv/bin/activate
pip install -e .[dev]
pytest -q
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file near_langchain_event_listener-0.1.0.tar.gz.
File metadata
- Download URL: near_langchain_event_listener-0.1.0.tar.gz
- Upload date:
- Size: 7.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7f0007bd079a9055a886c2e0dd5ff586691d9066ea40e4eb4f427b841e634f21
|
|
| MD5 |
ffca98090863736e5ed9f25325a44fd4
|
|
| BLAKE2b-256 |
b9e835a1e96c5e2e8256fc0555b60316bac85794265102140cfe36d66a49638f
|
File details
Details for the file near_langchain_event_listener-0.1.0-py3-none-any.whl.
File metadata
- Download URL: near_langchain_event_listener-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6cc94f1a585f4ec6cf3916d5c3904b8ec39490b6ee380f307fa906cf979ab988
|
|
| MD5 |
d313f73a29486bacb46e65db3f0d817f
|
|
| BLAKE2b-256 |
b3b6f896abdf9cd5f18c39adb9c8f4c0faa339ffca4d82c687020be2055b3bfd
|