Skip to main content

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_JSON logs
  • 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_account
  • near_event_unsubscribe
  • near_event_list_subscriptions
  • near_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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

near_langchain_event_listener-0.1.0.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

near_langchain_event_listener-0.1.0-py3-none-any.whl (9.7 kB view details)

Uploaded Python 3

File details

Details for the file near_langchain_event_listener-0.1.0.tar.gz.

File metadata

File hashes

Hashes for near_langchain_event_listener-0.1.0.tar.gz
Algorithm Hash digest
SHA256 7f0007bd079a9055a886c2e0dd5ff586691d9066ea40e4eb4f427b841e634f21
MD5 ffca98090863736e5ed9f25325a44fd4
BLAKE2b-256 b9e835a1e96c5e2e8256fc0555b60316bac85794265102140cfe36d66a49638f

See more details on using hashes here.

File details

Details for the file near_langchain_event_listener-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for near_langchain_event_listener-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6cc94f1a585f4ec6cf3916d5c3904b8ec39490b6ee380f307fa906cf979ab988
MD5 d313f73a29486bacb46e65db3f0d817f
BLAKE2b-256 b3b6f896abdf9cd5f18c39adb9c8f4c0faa339ffca4d82c687020be2055b3bfd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page