Summary
A Starknet node is software that syncs with the Starknet network, validates state transitions, and serves JSON-RPC requests for dApps and indexers. Running a full node gives you direct access and control, but it requires significant hardware, storage, and maintenance. For most production workloads, a managed RPC service like OnFinality provides reliable endpoints without the operational overhead.
Quick decision: run your own Starknet node or use a managed RPC?
Before diving into node architecture, decide what your project actually needs. Running a Starknet node gives you full control and data ownership, but it comes with real costs: hardware, storage, sync time, and ongoing maintenance. A managed RPC service like OnFinality abstracts that away, letting you focus on your application.
| Consideration | Run your own node | Use a managed RPC (e.g., OnFinality) |
|---|---|---|
| Setup time | Days to weeks (sync + config) | Minutes (API key + endpoint) |
| Hardware cost | High (SSD, RAM, bandwidth) | Predictable subscription |
| Maintenance | You handle upgrades, monitoring, backups | Provider handles it |
| Scalability | Manual capacity planning | Automatic scaling |
| Control | Full data access and custom queries | Limited to provided APIs |
| Best for | Research, custom indexing, maximum privacy | Production dApps, startups, teams without infra expertise |
If you need to inspect raw state or run custom queries that the public API doesn't support, a self-hosted node is the way. For most dApps, wallets, and indexers, a managed RPC is the pragmatic choice. Check RPC pricing and supported networks to see if OnFinality fits your workload.
What is a Starknet node?
Starknet is a Layer 2 (L2) scaling solution on Ethereum that uses zk-rollups to batch transactions off-chain and post validity proofs to Ethereum. A Starknet node is a client that connects to the Starknet network, syncs the state, and exposes a JSON-RPC interface for querying and submitting transactions.
Nodes are essential infrastructure for any Starknet dApp. They allow you to read contract state, simulate transactions, and broadcast new transactions. Without a node, you can't interact with the network programmatically.
How does a Starknet node work?
Starknet nodes communicate with sequencers and other nodes to maintain a consistent view of the network. They process blocks, execute transactions, and store the resulting state. The node's JSON-RPC API lets clients query data like block numbers, transaction receipts, and contract storage.
Key components of a Starknet node:
- Sync layer: Downloads and validates blocks from the network.
- State management: Tracks the current state of all contracts.
- JSON-RPC server: Serves requests from clients.
- Transaction pool: Holds pending transactions before they're included in a block.
Running your own Starknet node
If you decide to run your own node, here's what you need to know.
Hardware requirements
Starknet nodes are resource-intensive. You'll need:
- A modern CPU with multiple cores
- At least 16GB of RAM (32GB recommended)
- A fast SSD with at least 500GB of free space (grows over time)
- A stable internet connection with high bandwidth
Software options
There are several Starknet node implementations, including:
- Pathfinder: Written in Rust, maintained by the Starknet ecosystem.
- Junō: A Go implementation, focused on performance.
- Papyrus: A Rust implementation with a focus on full node capabilities.
Choose one based on your familiarity and performance needs. Most documentation is available in the respective GitHub repositories.
Setup steps
- Install the node software (e.g., download the binary or build from source).
- Configure the node to connect to the Starknet network (mainnet or testnet).
- Start the node and wait for it to sync. This can take hours or days depending on hardware and network conditions.
- Verify the node is synced by checking the latest block number against a block explorer.
- Expose the JSON-RPC endpoint (usually
http://localhost:9545) to your application.
Common pitfalls
- Insufficient storage: The blockchain grows quickly; plan for expansion.
- Sync issues: If your node falls behind, it may need to resync.
- Security: Exposing your node publicly without proper authentication can lead to abuse.
Connecting to a Starknet node with JSON-RPC
Once you have a node (self-hosted or managed), you interact with it via JSON-RPC. Here's a basic example using curl:
curl -X POST http://localhost:9545 \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"starknet_blockNumber","params":[],"id":1}'
This returns the latest block number. Other common methods include:
starknet_getBlockWithTxHashesstarknet_getTransactionReceiptstarknet_callstarknet_addInvokeTransaction
For a managed endpoint, you'd replace the URL with the one provided by your RPC provider. OnFinality offers public and private endpoints for Starknet; see the Starknet network page for details.
Using a Starknet node in your dApp
Most developers use a library like starknet.js to interact with the node. Here's a quick example:
import { Provider } from 'starknet';
const provider = new Provider({
nodeUrl: 'https://starknet-mainnet.public.blastapi.io' // Replace with your node URL
});
const blockNumber = await provider.getBlockNumber();
console.log('Latest block:', blockNumber);
Replace the nodeUrl with your own endpoint. If you're using OnFinality, you'll get a dedicated URL after creating an API key.
Managed Starknet nodes: when to use them
Managed RPC services like OnFinality provide several advantages:
- No infrastructure management: You don't need to worry about hardware, uptime, or scaling.
- Reliable endpoints: Providers ensure high availability and performance.
- Easy scaling: As your dApp grows, you can upgrade your plan without downtime.
- Support: Get help from infrastructure experts when you need it.
OnFinality supports Starknet as part of its network offerings. You can get started with a free tier and scale as needed. Check pricing for details.
Key Takeaways
- A Starknet node is essential for interacting with the Starknet network programmatically.
- Running your own node gives you control but requires significant resources and maintenance.
- Managed RPC services like OnFinality offer a convenient, scalable alternative for production dApps.
- Use JSON-RPC methods to query and submit transactions, and libraries like
starknet.jsfor easier integration.
Frequently Asked Questions
What is the difference between a Starknet full node and a light node?
A full node stores the entire state and validates all transactions, while a light node only verifies block headers and relies on full nodes for data. Full nodes are more resource-intensive but provide complete data access.
How long does it take to sync a Starknet node?
Sync time varies based on hardware and network conditions. On a fast machine with good bandwidth, it can take a few hours to a day. Slower setups may take several days.
Can I use a Starknet node for free?
Yes, you can run your own node for free (excluding hardware costs), or use public RPC endpoints that are rate-limited. For production, consider a managed service with a free tier, like OnFinality.
What are the hardware requirements for a Starknet node?
You'll need at least 16GB RAM, a multi-core CPU, and a fast SSD with 500GB+ free space. Requirements may increase as the network grows.
How do I choose between running my own node and using a managed RPC?
If you need full control, custom queries, or are doing research, run your own. If you want to focus on building your dApp without infrastructure worries, use a managed RPC service.