Repository navigation
|
Question: What architecture would you recommend for implementing a robust Stellar RPC client in Stellar DevKit that supports live network interaction, transaction simulation and submission? I'm particularly interested in:
How can we design this so developers get a reliable and consistent experience across Stellar testnet and mainnet? |
Replies: 1 comment
|
I would implement the RPC integration as a transport-independent client with a clear separation between network configuration, request handling, transaction simulation and transaction lifecycle management. 1. RPC transport layer Create a dedicated RPC client responsible for JSON-RPC communication. It should support configurable endpoints, request timeouts, structured errors and controlled retries. Avoid embedding endpoint URLs directly into contract or transaction logic. 2. Network configuration Provide explicit network profiles for:
Each profile should define its RPC endpoint, network passphrase and configuration requirements. Credentials should be handled securely rather than hardcoded. 3. Transaction simulation Before submission, the SDK should:
Simulation should not be treated as a guarantee that a transaction will succeed on-chain because ledger state can change before execution. 4. Submission and status tracking After signing, submit the transaction through the RPC client. Handle pending, successful and failed states explicitly. Provide bounded polling with configurable intervals and clear timeout errors. Preserve transaction hashes and diagnostic information for troubleshooting. 5. Error handling Use structured error types for network failures, invalid requests, simulation failures, rejected transactions and expired polling windows. Retry only operations that are safe to retry, and avoid blindly resubmitting transactions. 6. Testing strategy Use mocked RPC responses for deterministic unit tests, local integration environments where available, and a smaller set of live testnet integration tests. Test network failures, malformed responses, simulation errors, transaction timeouts and successful submissions. My recommendation: Build the RPC transport and network configuration first, then add simulation, submission and lifecycle tracking as separate modules. This creates a maintainable foundation for the rest of Stellar DevKit. |
I would implement the RPC integration as a transport-independent client with a clear separation between network configuration, request handling, transaction simulation and transaction lifecycle management.
1. RPC transport layer
Create a dedicated RPC client responsible for JSON-RPC communication. It should support configurable endpoints, request timeouts, structured errors and controlled retries.
Avoid embedding endpoint URLs directly into contract or transaction logic.
2. Network configuration
Provide explicit network profiles for:
Each profile should define its RPC endpoint, network passphrase and configuration require…