Summary
Astar Network is a Polkadot parachain focused on smart contracts, supporting both EVM and WebAssembly. It uses ASTR for gas and governance, and features dApp Staking to reward developers. This page covers the network's core concepts and how to connect via RPC endpoints for development and production.
Quick decision guide: connecting to Astar Network
Before you write your first query, decide which Astar endpoint you need. For a prototype or a hackathon, a public endpoint is fine. For a production dApp, a dedicated RPC node gives you more predictable throughput and avoids shared rate limits. If you need historical state, check whether the provider offers archive data. Astar is a Substrate-based chain with an EVM layer, so you can interact with it using both Substrate RPC methods and Ethereum-style JSON-RPC. OnFinality provides Astar RPC endpoints and dedicated nodes that support both interfaces.
What is Astar Network?
Astar Network is a smart contract platform built on Substrate and connected to Polkadot as a parachain. It launched mainnet in January 2022, originally under the name Plasm Network. Astar's goal is to be a hub for dApps, supporting both EVM and WebAssembly (Wasm) smart contracts. This dual support lets developers choose the execution environment that fits their project, while still benefiting from Polkadot's shared security and interoperability.
The native token, ASTR, is used for transaction fees, governance, and staking. A distinctive feature is dApp Staking, where ASTR holders stake their tokens to support specific dApps and their developers. This mechanism aims to align incentives between builders and the community, providing a sustainable funding model for projects.
Astar has gained attention for its partnerships with Japanese enterprises, including Sony Network Communications, Toyota, and NTT Docomo, exploring Web3 use cases like NFTs and incubation programs. The network is also part of the Astar Collective, which builds products like Astar Portal and Astar Fi.
Astar Network architecture: Substrate and EVM
Astar is built on Substrate, the framework that powers Polkadot. This means it uses Substrate's RPC interface for core operations like querying chain metadata and submitting transactions. However, Astar also includes an EVM compatibility layer, allowing Ethereum developers to deploy Solidity contracts with minimal changes. This dual nature is important for RPC usage: you can use both eth_* methods (like eth_call and eth_sendRawTransaction) and Substrate-specific methods (like state_getStorage).
For developers, this means you can use familiar Ethereum tools like ethers.js or viem, as well as Polkadot tools like polkadot.js. The choice depends on whether you're building an EVM-based dApp or a Substrate-native one.
Chain settings at a glance
Here are the key parameters you need to configure your wallet or dApp to connect to Astar mainnet:
| Parameter | Value |
|---|---|
| Network Name | Astar |
| RPC URL | https://astar.api.onfinality.io/public (example) |
| Chain ID | 592 |
| Currency Symbol | ASTR |
| Block Explorer | https://astar.subscan.io |
| Type | Substrate + EVM |
Note that the RPC URL above is a public endpoint; for production, consider a dedicated endpoint from a provider like OnFinality. Always check the latest official documentation for the most current settings.
How to connect to Astar Network
You can connect to Astar in several ways, depending on your use case.
Using a wallet
To add Astar to MetaMask or another EVM wallet, use the chain settings above. The Chain ID is 592, and the currency is ASTR. This allows you to send transactions and interact with EVM dApps.
Using ethers.js or viem
For EVM-based development, you can use ethers.js or viem with the Astar RPC endpoint. Here's an example using ethers.js:
const { ethers } = require("ethers");
const provider = new ethers.JsonRpcProvider("https://astar.api.onfinality.io/public");
async function getBlockNumber() {
const blockNumber = await provider.getBlockNumber();
console.log("Current block number:", blockNumber);
}
getBlockNumber();
Using polkadot.js
For Substrate-native interactions, you can use polkadot.js:
const { ApiPromise, WsProvider } = require("@polkadot/api");
const wsProvider = new WsProvider("wss://astar.api.onfinality.io/public-ws");
const api = await ApiPromise.create({ provider: wsProvider });
const chain = await api.rpc.system.chain();
console.log("Connected to:", chain.toString());
Using curl for JSON-RPC
You can also test the endpoint with a simple curl command:
curl -X POST https://astar.api.onfinality.io/public \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}'
This returns the latest block number, confirming the endpoint is responsive.
RPC methods and use cases
Astar supports a wide range of RPC methods, including both Ethereum and Substrate APIs. Common use cases include:
- Reading blockchain data: Use
eth_getBalance,eth_call, orstate_getStorageto query on-chain state. - Sending transactions: Use
eth_sendRawTransactionfor EVM transactions orauthor_submitExtrinsicfor Substrate ones. - Subscribing to events: Use WebSocket subscriptions like
eth_subscribeorchain_subscribeNewHeadsto monitor new blocks. - Interacting with smart contracts: Use
eth_callto read contract data andeth_sendRawTransactionto write.
For analytics or indexing, you might need archive data to access historical state. Not all providers offer archive nodes, so check before you build.
Public vs. dedicated RPC: what to consider
Public RPC endpoints are convenient for development, but they have limitations:
- Rate limits: Public endpoints often throttle requests, which can break production apps.
- Reliability: They may go down or become slow during peak usage.
- Privacy: Your requests are visible to the provider.
For production, a dedicated RPC node offers:
- Higher throughput: You get a private endpoint with more capacity.
- Custom configuration: You can enable archive data, WebSocket, or specific methods.
- Better reliability: Dedicated infrastructure is designed for uptime.
OnFinality provides dedicated nodes for Astar and other networks, with flexible pricing. You can also compare RPC pricing to find a plan that fits your needs.
Common pitfalls and troubleshooting
Here are some issues you might encounter when connecting to Astar:
| Symptom | Likely Cause | Fix |
|---|---|---|
eth_chainId returns wrong value | Using a different network | Check that Chain ID is 592 |
| Transaction stuck | Nonce too low or gas price too low | Resubmit with higher gas or correct nonce |
| WebSocket connection drops | Network instability or provider limits | Use a dedicated WebSocket endpoint |
eth_call returns error | Contract address or ABI incorrect | Verify the contract address and ABI |
| Rate limit errors | Too many requests to public endpoint | Upgrade to a dedicated node |
If you're using a public endpoint and hitting rate limits, consider a dedicated node from OnFinality. For debugging, you can also use the debug_traceTransaction method if the provider supports it.
Key Takeaways
- Astar Network is a Polkadot parachain supporting both EVM and Wasm smart contracts.
- ASTR is the native token for gas, governance, and dApp Staking.
- You can connect via Ethereum-compatible RPC or Substrate RPC, depending on your stack.
- For production, use a dedicated RPC node to avoid rate limits and ensure reliability.
- Always verify chain settings like Chain ID (592) and RPC URL before deploying.
Frequently Asked Questions
What is the Astar Network Chain ID?
The Chain ID for Astar mainnet is 592. This is used for EVM-based transactions and wallet configuration.
Is Astar Network an Ethereum layer 2?
No, Astar is a parachain on Polkadot, not an Ethereum layer 2. It has an EVM compatibility layer, so Ethereum tools work, but it's a separate network.
What is dApp Staking on Astar?
dApp Staking allows ASTR holders to stake their tokens to support specific dApps. In return, they earn rewards, and developers get funding for their projects.
Can I use Astar with MetaMask?
Yes, you can add Astar to MetaMask using the chain settings: RPC URL, Chain ID 592, and ASTR as the currency symbol.
Where can I find a reliable Astar RPC endpoint?
You can use public endpoints for testing, but for production, consider a dedicated RPC node from a provider like OnFinality. Check the Astar network page for available options.