Astar RPC Guide
Astar RPC
With Dwellir, you get access to our global Astar network which always routes your API requests to the nearest available location, ensuring low latency and the fastest speeds.
Why Build on Astar?#
🚀 Multichain smart-contract hub#
- Dual EVM + WASM runtimes let teams deploy Solidity and ink! contracts side by side while inheriting Polkadot relay-chain security (Astar build docs).
- Build2Earn dApp staking shares block rewards with developers who attract stakers, turning usage into sustainable funding (Astar dApp staking guide).
⚙️ Optimized for Polkadot 2.0#
- Astar adopted Agile Coretime so parachain capacity scales with demand instead of multi-year lease slots, reducing operating costs for long-lived apps (Polkadot Ecosystem update, Aug 13 2025).
- Asynchronous Backing on mainnet brings ~6-second block production with larger block weight limits for latency-sensitive DeFi and gaming flows (Astar mainnet upgrade announcement).
🧑💻 Enterprise-ready infrastructure#
- Dwellir, Chainstack, and other managed providers expose archive-grade RPC endpoints so teams can launch without running collators on day one (Dwellir Astar network page, Chainstack support announcement).
Quick Start with Astar#
Connect to Astar, Shibuya testnet, or Shiden canary through Dwellir-managed endpoints.
🔗 RPC Endpoints
Quick Connect:
curl -X POST https://api-astar.n.dwellir.com/YOUR_API_KEY \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"chain_getBlock","params":[],"id":1}'
Sign up with Dwellir or your preferred infrastructure partner to replace YOUR_API_KEY before sending requests.
Installation & Setup#
- cURL
- Rust (subxt)
- Python (py-substrate-interface)
curl https://api-astar.n.dwellir.com/YOUR_API_KEY \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "chain_getHeader",
"params": []
}'
Sample response (2025-10-03 10:13 UTC):
{
"jsonrpc": "2.0",
"result": {
"number": "0x9fbc28",
"parentHash": "0x3f484429ad05365b32f643a9e825794961c1e6f92cde48a2c73935d7773dd5e1",
"stateRoot": "0x1b983c37356b175bcf38dc1afcc8e31fa893e561f605fcad473697a68ac92169",
"extrinsicsRoot": "0x783e75691edc604a3f13e1b5c558dd3ca5870ac07ce799c781713219a4a56224",
"digest": {
"logs": [
"0x066175726120159b7a1100000000",
"0x0452505352902bb51614ab3779fc4f4892aa8e21582a05a3162aef145209312f48c3b37fc7909618af06",
"0x0466726f6e88015cd52a32691b3d44a3cef762382d728668dbee8c4509c697efe25708d5e6ffd400",
"0x05617572610101809dd98345fce7c411d130f73a50b2e37d73efe027964dd63ce064275257cc1afb3192c7885ec1813c89350463bce9cd8b4f183b6e8cd779643ff4c476795e83"
]
}
},
"id": 1
}
</TabItem>
<TabItem value="polkadotjs" label="JavaScript (polkadot.js)">
```typescript
import { ApiPromise, WsProvider } from '@polkadot/api';
async function main() {
const provider = new WsProvider('wss://api-astar.n.dwellir.com/YOUR_API_KEY');
const api = await ApiPromise.create({ provider });
const [chain, nodeName, nodeVersion, runtime] = await Promise.all([
api.rpc.system.chain(),
api.rpc.system.name(),
api.rpc.system.version(),
api.rpc.state.getRuntimeVersion()
]);
console.log(`Connected to ${chain.toString()} via ${nodeName} ${nodeVersion}`);
console.log(`specVersion=${runtime.specVersion.toString()}, transactionVersion=${runtime.transactionVersion}`);
const header = await api.rpc.chain.getHeader();
console.log(`Latest block #${header.number} (${header.hash.toHex()})`);
await api.disconnect();
}
main().catch(console.error);
use subxt::{config::substrate::SubstrateConfig, OnlineClient};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let api = OnlineClient::<SubstrateConfig>::from_url(
"wss://api-astar.n.dwellir.com/YOUR_API_KEY"
).await?;
let block_hash = api.rpc().finalized_head().await?;
let header = api.rpc().header(Some(block_hash)).await?.expect("header");
println!("Finalized block #{:?}", header.number);
println!("State root {:?}", header.state_root);
Ok(())
}
from substrateinterface import SubstrateInterface
api = SubstrateInterface(
url="wss://api-astar.n.dwellir.com/YOUR_API_KEY",
ss58_format=5,
type_registry_preset="substrate-node-template"
)
runtime = api.get_runtime_version()
print("specVersion", runtime['specVersion'], "transactionVersion", runtime['transactionVersion'])
account = api.query(
module='System',
storage_function='Account',
params=['ZEyDXf6563rc78ibEtYQAkHTSKLzMES1m2BrPNdLcma57Tg']
)
print("Free balance", account.value['data']['free'])
Network Information#
| Parameter | Astar Mainnet | Shiden Canary | Shibuya Testnet |
|---|---|---|---|
| Relay chain | Polkadot | Kusama | Tokyo (Astar-managed) |
| Parachain ID | 2006 | 2007 | 1000 |
| Genesis hash | 0x9eb76c5184c4ab8679d2d5d819fdf90b9c001403e9e17da2e14b6d8aec4029c6 | — | — |
| Runtime (2025-10-03) | specVersion 1700, transactionVersion 3 | specVersion 1700 | specVersion 1700 |
| Unit symbol | ASTR | SDN | SBY |
| Decimals | 18 | 18 | 18 |
| SS58 prefix | 5 | 5 | 5 |
| Explorer | astar.subscan.io | shiden.subscan.io | shibuya.subscan.io |
- Genesis hash recorded via
chain_getBlockHash(0)on 2025-10-03. - Shiden (Kusama canary) and Shibuya (public testnet) provide staging environments for runtime upgrades before they reach mainnet (Astar network overview).
Available JSON-RPC Methods#
Astar exposes the full Substrate RPC surface, plus Frontier EVM methods. Core namespaces documented in this section:
| Group | Purpose | Key Methods |
|---|---|---|
system_* | Node health, metadata, peer info | system_health, system_version, system_chain |
chain_* | Blocks, headers, finality, subscriptions | chain_getHeader, chain_getBlock, chain_subscribeFinalizedHeads |
state_* | Storage queries, metadata, runtime data | state_getStorage, state_getRuntimeVersion, state_getKeysPaged |
author_* | Extrinsic submission and queue inspection | author_submitExtrinsic, author_pendingExtrinsics |
payment_* | Fee estimation for Substrate extrinsics | payment_queryInfo, payment_queryFeeDetails |
rpc_methods | Enumerate RPC namespaces exposed by the node | rpc_methods |
Frontier also enables Ethereum-compatible eth_*, net_*, and web3_* endpoints for EVM wallets.
Common Integration Patterns#
Subscribe to new heads for live indexing#
import { ApiPromise, WsProvider } from '@polkadot/api';
const provider = new WsProvider('wss://api-astar.n.dwellir.com/YOUR_API_KEY');
const api = await ApiPromise.create({ provider });
api.rpc.chain.subscribeNewHeads((header) => {
console.log(`Astar block #${header.number.toString()} => ${header.hash.toHex()}`);
});
Fetch native balances via raw storage key#
# System.Account for 5-digit treasury account
curl https://api-astar.n.dwellir.com/YOUR_API_KEY \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "state_getStorage",
"params": [
"0x26aa394eea5630e07c48ae0c9558cef7b99d880ec681799c0cf30e8886371da9e3a5c81a65b0e6ba8e72e48e58704482922ee694ea772dc63a575845fa57a0c5ea93dfdc2a93ec631d9e426962f1e311"
],
"id": 42
}'
Decode the SCALE-encoded result with polkadot.js or py-substrate-interface to access data.free, data.reserved, and staking locks.
Pre-flight fees before submitting extrinsics#
import { ApiPromise, WsProvider } from '@polkadot/api';
const api = await ApiPromise.create({ provider: new WsProvider('wss://api-astar.n.dwellir.com/YOUR_API_KEY') });
const tx = api.tx.balances.transferKeepAlive(
'5DAAnrj7VHTz5xy1mJQp7vR8J33ePZ8WqWnVfHfV9bPp7PPV',
1_000_000_000_000
);
const info = await api.rpc.payment.queryInfo(tx.toHex());
console.log(info.toHuman());
Performance Best Practices#
- Prefer WebSocket connections for subscriptions and batched queries; fall back to HTTPS for stateless workloads.
- Cache runtime metadata keyed by the latest
specVersionto avoid re-fetching on every request. - Use
state_getKeysPagedorstate_getStoragePagedwith bounded page sizes when crawling large maps such as staking ledgers. - Track upgrade announcements on the Astar forum and rehearse changes on Shiden before promoting them to mainnet.
- Implement exponential backoff around
author_submitExtrinsic; Frontier queues may temporarily reject payloads when Ethereum traffic spikes.
Troubleshooting#
| Symptom | Likely Cause | Resolution |
|---|---|---|
API key does not exist errors | Misconfigured Dwellir endpoint or expired key | Re-issue the key via the Dwellir dashboard and update environment variables. |
| WebSocket disconnects on idle workloads | Provider closes idle connections | Enable heartbeat pings or reconnect logic every 30 seconds. |
Smoke Tests#
Run these checks before promoting to production:
- system_health — expect
isSyncing: falseand peer count > 8. - chain_getHeader — confirm block numbers advance every ~6 seconds.
- state_getStorage(System.Account) — verify SCALE decoding of balances for a known treasury or team account.
- payment_queryInfo on a signed extrinsic — validate fee model before broadcasting from CI/CD.
Resources & Tools#
- Astar Documentation — network architecture, node operations, and dApp staking guides.
- Astar GitHub Releases — runtime and client binaries.
- Dwellir Astar Network Page — managed endpoints and quick-start snippets.
- Astar Subscan Explorer — block, extrinsic, and account analytics for monitoring deployments.
Ready to deploy? Spin up a staging environment on Shibuya, soak test on Shiden, then cut over to Astar mainnet with confidence.