Summary
Learn how to configure a custom Sui RPC endpoint for your dApp, whether you're using the public endpoint, a managed provider like OnFinality, or your own node. This guide covers endpoint configuration, JSON-RPC examples, and common troubleshooting steps to keep your Sui application reliable.
Quick Recommendation: Choose Your Sui RPC Setup
Before diving into configuration, decide which Sui RPC setup fits your project. The right choice depends on your traffic, budget, and control needs.
- Public endpoint: Free, but rate-limited and not suitable for production. Use for testing and prototyping.
- Managed provider (e.g., OnFinality): Reliable, scalable, and easy to integrate. Best for most production dApps.
- Self-hosted node: Full control and clear rate limits, but requires infrastructure expertise and ongoing maintenance.
For most teams, a managed provider like OnFinality offers the best balance of performance and simplicity. If you need dedicated resources or have high throughput, consider a dedicated node from OnFinality.
What Is a Custom Sui RPC?
A Sui RPC endpoint is a URL that your dApp uses to communicate with the Sui blockchain. By default, Sui provides a public endpoint, but you can configure a custom endpoint to point to a different provider or your own node. This is useful for:
- Avoiding rate limits on public endpoints
- Improving latency by choosing a geographically closer server
- Accessing archive data or enhanced APIs
- Ensuring uptime with a reliable provider
Sui Chain Settings at a Glance
Here are the key details you need to configure your Sui RPC:
| Setting | Value |
|---|---|
| Network | Sui Mainnet |
| RPC URL (public) | https://rpc.ankr.com/sui (example) |
| Chain ID | 35834a34a26ab4b4c3589a2c4f6d1f3f |
| Explorer | https://suiscan.xyz/ |
| WebSocket Support | Yes (via provider) |
Note: The public endpoint above is for illustration; for production, use a managed provider like OnFinality. Check the Sui network page for the latest endpoint information.
How to Configure a Custom Sui RPC Endpoint
Using a Managed Provider (OnFinality)
OnFinality provides a reliable Sui RPC endpoint that you can use in your dApp. Here's how to set it up:
- Sign up at OnFinality and create an API key.
- Get your endpoint from the dashboard. It will look like
https://sui-mainnet.onfinality.io/v1/your-api-key. - Configure your dApp to use this endpoint.
Using a Self-Hosted Node
If you run your own Sui node, you can use its local RPC endpoint, typically http://localhost:9000. Configure your dApp to point to this address.
JSON-RPC Examples for Sui
Sui uses JSON-RPC 2.0. Here's a basic curl example to get the latest checkpoint:
curl -X POST https://sui-mainnet.onfinality.io/v1/your-api-key \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "sui_getLatestCheckpointSequenceNumber",
"params": [],
"id": 1
}'
For JavaScript (using fetch):
const rpcUrl = 'https://sui-mainnet.onfinality.io/v1/your-api-key';
const response = await fetch(rpcUrl, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
jsonrpc: '2.0',
method: 'sui_getLatestCheckpointSequenceNumber',
params: [],
id: 1
})
});
const data = await response.json();
console.log(data.result);
Common Pitfalls and Troubleshooting
1. Rate Limiting on Public Endpoints
Public endpoints often have strict rate limits. If you see 429 Too Many Requests, switch to a managed provider or self-hosted node.
2. Incorrect Endpoint URL
Double-check your endpoint URL for typos. A missing /v1/ or wrong API key can cause connection errors.
3. WebSocket Connection Drops
For real-time updates, use WebSocket. Ensure your provider supports it and your client handles reconnection.
4. Method Not Found
If you call a method that doesn't exist, you'll get an error. Refer to the Sui JSON-RPC documentation for available methods.
When to Use a Dedicated Sui Node
If your dApp has high traffic or requires consistent performance, a dedicated node from OnFinality might be the right choice. Benefits include:
- clear rate limits
- Guaranteed resources
- Customizable configuration
- Enhanced reliability
Consider a dedicated node if you experience frequent rate limiting or need to run heavy queries like suix_getDynamicFields.
Monitoring Your Sui RPC
To ensure your dApp stays healthy, monitor your RPC endpoint. Here's a simple health check using curl:
curl -X POST https://sui-mainnet.onfinality.io/v1/your-api-key \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "sui_getChainIdentifier",
"params": [],
"id": 1
}'
If you get a response, your endpoint is up. Set up alerts for downtime and latency.
Key Takeaways
- A custom Sui RPC endpoint gives you control over performance and reliability.
- Public endpoints are fine for testing but not for production.
- Managed providers like OnFinality offer a balance of ease and performance.
- Self-hosting gives full control but requires more effort.
- Always monitor your RPC endpoint to catch issues early.
Frequently Asked Questions
What is the default Sui RPC endpoint?
The default public endpoint is https://fullnode.mainnet.sui.io/, but it's rate-limited. For production, use a managed provider.
Can I use a custom Sui RPC with the Sui SDK?
Yes, you can pass a custom RPC URL when initializing the Sui client. For example, in the TypeScript SDK:
import { SuiClient } from '@mysten/sui/client';
const client = new SuiClient({ url: 'https://sui-mainnet.onfinality.io/v1/your-api-key' });
How do I get an API key from OnFinality?
Sign up at OnFinality, create a project, and you'll get an API key.
What are the benefits of a dedicated Sui node?
A dedicated node provides dedicated resources, clear rate limits, and better performance for high-traffic applications. Learn more about dedicated nodes.
Where can I see the list of supported networks?
Check the supported networks page for all available networks, including Sui.
For more details on pricing, visit our RPC pricing page.