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)
  • Advanced EVENT_JSON filtering (event_json:ft_transfer, event_json:nep141:ft_transfer)
  • 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_listener_status
  • 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.
  • Callback URLs are validated (http:// or https://).

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.1.tar.gz (8.4 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.1-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for near_langchain_event_listener-0.1.1.tar.gz
Algorithm Hash digest
SHA256 226253fccde0e723b7a68b2ea58ec186540795ca7f73f02aea36b9caad2232c7
MD5 67d0dd5fd778f4e49ad0e003a0078296
BLAKE2b-256 884a970920593ca05568cfefe091fe28a6dd366f1c9aee83f4f89ca17a711d3d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for near_langchain_event_listener-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 719b8b94fbea2618c1cbf48570b007d73612bb302486548a4b9789032a9c8b86
MD5 0f46eb4e6d1846a128eccd57a4835474
BLAKE2b-256 df6031994fe675e69f9e3b6583a2b117b86a7d04dfaa2864f2502436960dcd40

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