How reya-labs/reya-python-sdk works
Project type and purpose
• This is an open-source Python SDK (library + examples) for interacting with the Reya blockchain ecosystem.
• It provides two orthogonal capabilities:
• A WebSocket-based market data feed client (reya_data_feed)
• An RPC-based on-chain action library (reya_actions)
• The examples/ folder ties them together with runnable scripts showcasing common use-cases (trading, bridging, staking, etc.).
File structure
• Top level
• .env.example, .gitignore, README.md – configuration & project metadata
• examples/ – executable scripts orchestrating the SDK
• reya_actions/ – core on-chain command library
• reya_data_feed/ – market data WebSocket consumer
• reya_actions/ substructure
• abis/ – JSON ABI definitions for on-chain Proxy contracts
• actions/ – one module per supported on-chain operation (trade, deposit, bridge_in, etc.)
• config.py, consts.py, types.py – SDK configuration, constants, type definitions
• utils/execute_core_commands.py – low-level helper to assemble and send RPC calls
• reya_data_feed/consumer.py – connects to the Reya WebSocket API, subscribes to market channels
README for additional insights
• Lists features, prerequisites (private key, chain_id, account_id), and usage patterns
• Describes how data-feed and action modules are consumed by example scripts
• Emphasizes Poetry for dependency management and running the examples
Main components
a. Examples Runner
• Each examples/*.py script
• Orchestrates calls into reya_data_feed and/or reya_actions
b. Data-Feed Module (reya_data_feed)
• WebSocket client → Reya WebSocket API (external)
• Subscriptions: candles, spot prices, funding rates
c. Actions Module (reya_actions)
• Config & environment loader (.env)
• ABI loader → Proxy contracts on-chain
• Action handlers (trade, deposit, withdraw, stake, bridge)
• RPC client → JSON-RPC endpoint (external)
d. External Services
• Reya WebSocket Server
• Reya JSON-RPC Node
• On-chain Proxy contracts (addresses loaded from config)
Relationships and interactions
• Examples → import & invoke Data-Feed or Action functions
• Data-Feed → opens WebSocket connection → streams data → propagates events to examples
• Actions → assemble transactions using ABIs → send JSON-RPC calls → await on-chain confirmations
• Environment variables (private key, chain_id, account_id, RPC URL) flow into both modules via config.py
Architectural patterns and design principles
• Modular separation: data feed vs on-chain commands
• Command pattern in actions/ (one file per action)
• Clear abstraction around ABIs and RPC/WS transport
• Extensible: drop-in new actions/ or abis/ for additional smart contracts
Essential elements to capture
• Components: examples, modules, external endpoints
• Data flow: subscription & event streaming vs transaction submission & confirmation
• Configuration boundary: where .env values are consumed
• Technology call-outs: Python, WebSocket API, JSON-RPC, smart-contract ABIs