Quick Recommendation: Which Scroll Endpoint Should You Use?
If you're building a dApp, running a backend service, or just testing on Scroll, the choice of endpoint can affect your app's reliability and performance. For development and light usage, the public endpoint is fine. For production workloads, you should consider a dedicated or private RPC endpoint to avoid rate limits and ensure consistent uptime.
-
For quick tests and prototypes: Use the public endpoint
https://scroll.api.onfinality.io/public. - For production dApps: Use a private RPC endpoint from a provider like OnFinality, which offers dedicated nodes and higher throughput.
- For wallet configuration: Use the chain settings below to add Scroll to MetaMask or other wallets.
What Is the Scroll Endpoint?
The Scroll endpoint is the JSON-RPC API endpoint for the Scroll network, an Ethereum Layer 2 scaling solution that uses zk-rollups. It allows you to interact with the Scroll blockchain—sending transactions, querying data, and deploying smart contracts—using standard Ethereum tooling like ethers.js, viem, or curl.
Scroll is designed to be EVM-compatible, meaning most Ethereum code works without modification. The endpoint serves as the gateway to the network, and its performance directly impacts your application's user experience.
Scroll Chain Settings at a Glance
Here are the key network parameters you need to configure your wallet or dApp:
| Parameter | Value |
|---|---|
| Network Name | Scroll |
| Chain ID | 534352 |
| Native Currency | ETH (Ether) |
| Symbol | ETH |
| Decimals | 18 |
| Block Explorer | https://scrollscan.com |
| Public RPC URL | https://scroll.api.onfinality.io/public |
| WebSocket URL | wss://scroll.api.onfinality.io/public-ws |
These settings are essential for adding Scroll to your wallet or configuring your application.
How to Configure Your Wallet with the Scroll Endpoint
To add Scroll to MetaMask or another wallet, follow these steps:
- Open your wallet and navigate to the network settings.
- Click "Add Network" or "Custom RPC."
- Enter the details from the table above.
- Save and switch to the Scroll network.
Here's an example of a wallet configuration snippet (e.g., for MetaMask):
{
"chainId": "0x82750", // 534352 in hex
"chainName": "Scroll",
"nativeCurrency": {
"name": "Ether",
"symbol": "ETH",
"decimals": 18
},
"rpcUrls": ["https://scroll.api.onfinality.io/public"],
"blockExplorerUrls": ["https://scrollscan.com"]
}
Making Your First JSON-RPC Request to Scroll
Once you have the endpoint, you can test it with a simple curl command. For example, to get the current block number:
curl https://scroll.api.onfinality.io/public \
-X POST \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}'
The response will look something like:
{"jsonrpc":"2.0","id":1,"result":"0x..."}
The result is the latest block number in hexadecimal. You can convert it to decimal to see the current block height.
Using the Scroll Endpoint with ethers.js and viem
Most developers use libraries like ethers.js or viem to interact with the Scroll network. Here's how to connect using ethers.js:
const { ethers } = require("ethers");
const provider = new ethers.JsonRpcProvider("https://scroll.api.onfinality.io/public");
async function getBlockNumber() {
const blockNumber = await provider.getBlockNumber();
console.log("Current block number:", blockNumber);
}
getBlockNumber();
And with viem:
import { createPublicClient, http } from 'viem';
const client = createPublicClient({
chain: {
id: 534352,
name: 'Scroll',
network: 'scroll',
nativeCurrency: { name: 'Ether', symbol: 'ETH', decimals: 18 },
rpcUrls: {
default: { http: ['https://scroll.api.onfinality.io/public'] },
public: { http: ['https://scroll.api.onfinality.io/public'] },
},
blockExplorers: {
default: { name: 'ScrollScan', url: 'https://scrollscan.com' },
},
},
transport: http(),
});
const blockNumber = await client.getBlockNumber();
console.log("Current block number:", blockNumber);
WebSocket Support for Real-Time Applications
If your application needs real-time updates—like transaction receipts or new blocks—you can use the WebSocket endpoint. This is useful for indexers, monitoring tools, or dApps that need to react to on-chain events instantly.
Here's an example of subscribing to new block headers using WebSocket:
const WebSocket = require('ws');
const ws = new WebSocket('wss://scroll.api.onfinality.io/public-ws');
ws.on('open', () => {
ws.send(JSON.stringify({
jsonrpc: '2.0',
method: 'eth_subscribe',
params: ['newHeads'],
id: 1
}));
});
ws.on('message', (data) => {
console.log('New block:', JSON.parse(data));
});
Public vs. Private Scroll Endpoints: What's the Difference?
Public endpoints are free and open to everyone, but they come with limitations:
- Rate limits: Public endpoints often have request limits to prevent abuse.
- Reliability: They may be less reliable under heavy load.
- Privacy: Your requests are not private; they can be seen by the provider.
Private endpoints, on the other hand, offer:
- Higher throughput: You get dedicated resources, so you can handle more requests per second.
- Better reliability: Dedicated nodes are less likely to be affected by other users' traffic.
- Privacy: Your requests are not shared with other users.
For production applications, a private endpoint is usually the right choice. OnFinality offers dedicated Scroll nodes and private RPC endpoints that can be tailored to your needs. Check our RPC pricing for more details.
Common Pitfalls and Troubleshooting with Scroll Endpoints
Here are some common issues developers face when using Scroll endpoints and how to resolve them:
| Symptom | Likely Cause | Solution |
|---|---|---|
eth_blockNumber returns an error |
Incorrect endpoint URL | Double-check the URL and ensure it's the correct network |
| Rate limit errors (HTTP 429) | Too many requests | Use a private endpoint or implement retry logic |
| WebSocket connection drops | Network instability | Implement reconnection logic |
| Transaction not found | Wrong chain ID | Ensure your chain ID is 534352 |
How to Choose a Scroll RPC Provider for Production
When selecting a Scroll RPC provider, consider the following criteria:
- Uptime and reliability: Look for providers with a track record of high availability.
- Throughput: Ensure the provider can handle your expected request volume.
- Support for WebSocket: If you need real-time data, make sure WebSocket is supported.
- Archive data: If you need historical state, check if the provider offers archive nodes.
- Pricing: Compare pricing models to find one that fits your budget.
OnFinality is a good option to consider, as it offers dedicated nodes and flexible pricing. You can explore our supported networks to see if Scroll is listed and what services are available.
Key Takeaways
- The Scroll endpoint is the JSON-RPC API for the Scroll Layer 2 network.
- Use the public endpoint for testing, but consider a private endpoint for production.
- Configure your wallet with the correct chain ID (534352) and RPC URL.
- WebSocket support is available for real-time applications.
- Choose a provider that meets your reliability, throughput, and budget needs.
Frequently Asked Questions
What is the Scroll chain ID?
The Scroll chain ID is 534352.
What is the native currency of Scroll?
Scroll uses ETH as its native currency, with 18 decimals.
Can I use the Scroll endpoint with MetaMask?
Yes, you can add Scroll as a custom network using the chain settings provided above.
Does OnFinality offer a dedicated Scroll endpoint?
OnFinality provides dedicated node infrastructure for various networks. Check our network page for availability and details.
How do I get support for Scroll RPC issues?
If you're using OnFinality, you can reach out to our support team. For general issues, refer to the Scroll documentation and community forums.
Related resources
Originally published at OnFinality.
Top comments (0)