# Astar RPC Guide

## Astar RPC plans and rate limits

- **Free plan:** 20 responses per second, up to 100,000 responses a day.
- **Plans:** $49/mo, $299/mo, $999/mo with 25M, 150M, and 500M included responses. Overages billed at $5/$3/$2 per million responses respectively.
- **Paid rate limits:** 100 to 5,000 responses per second (bursts from 500 to 10,000), no daily limit.
- **Billing:** 1 response = 1 API credit on every shared plan, over HTTPS or WebSocket (WSS) where Astar supports it.

Details: [Pricing](https://www.dwellir.com/docs/getting-started/pricing) · [Rate limits](https://www.dwellir.com/docs/getting-started/rate-limits) · [Authentication](https://www.dwellir.com/docs/getting-started/authentication) · [Archive nodes](https://www.dwellir.com/docs/getting-started/archive-nodes)

## 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](https://docs.astar.network/docs/build)).
- Build2Earn dApp staking shares block rewards with developers who attract stakers, turning usage into sustainable funding ([Astar dApp staking guide](https://docs.astar.network/docs/learn/dapp-staking/)).

### 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](https://polkadotecosystem.com/pt/dapps/smart-contracts/astar-network/)).
- Asynchronous Backing on mainnet brings \~6-second block production with larger block weight limits for latency-sensitive DeFi and gaming flows.

### ‍ 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](https://www.dwellir.com/networks/astar), [Chainstack support announcement](https://chainstack.com/chainstack-introduces-support-for-astar/)).

## Quick Start with Astar

Connect to Astar, Shibuya testnet, or Shiden canary through Dwellir-managed endpoints.

Sign up with [Dwellir](https://dashboard.dwellir.com/register) or your preferred infrastructure partner to replace `YOUR_API_KEY` before sending requests.

### Installation & Setup

cURL
JavaScript (polkadot.js)
Rust (subxt)
Python (py-substrate-interface)

```bash
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):**

```json
{
  "jsonrpc": "2.0",
  "result": {
    "number": "0x9fbc28",
    "parentHash": "0x3f484429ad05365b32f643a9e825794961c1e6f92cde48a2c73935d7773dd5e1",
    "stateRoot": "0x1b983c37356b175bcf38dc1afcc8e31fa893e561f605fcad473697a68ac92169",
    "extrinsicsRoot": "0x783e75691edc604a3f13e1b5c558dd3ca5870ac07ce799c781713219a4a56224",
    "digest": {
      "logs": [
        "0x066175726120159b7a1100000000",
        "0x0452505352902bb51614ab3779fc4f4892aa8e21582a05a3162aef145209312f48c3b37fc7909618af06",
        "0x0466726f6e88015cd52a32691b3d44a3cef762382d728668dbee8c4509c697efe25708d5e6ffd400",
        "0x05617572610101809dd98345fce7c411d130f73a50b2e37d73efe027964dd63ce064275257cc1afb3192c7885ec1813c89350463bce9cd8b4f183b6e8cd779643ff4c476795e83"
      ]
    }
  },
  "id": 1
}
```

```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);
```

```rust
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(())
}
```

```python
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    |

### Notes

| Parameter                 | Value                                                                                                                           | Details                                                                   |
| ------------------------- | ------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------- |
| Genesis Hash Verification | Recorded via `chain_getBlockHash(0)` on 2025-10-03                                                                              |                                                                           |
| Canary & Testnet Role     | Shiden (Kusama canary) and Shibuya (public testnet) provide staging environments for runtime upgrades before they reach mainnet | [Astar network overview](https://docs.astar.network/docs/learn/networks/) |

## API Reference

Astar exposes the full Substrate RPC surface for block data, storage, extrinsics, and fee estimation, with Frontier also enabling Ethereum-compatible `eth_*`, `net_*`, and `web3_*` endpoints for EVM tooling.

## Common Integration Patterns

### Subscribe to new heads for live indexing

```typescript
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

```bash
# 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

```typescript
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 `specVersion` to avoid re-fetching on every request.
- Use `state_getKeysPaged` or `state_getStoragePaged` with bounded page sizes when crawling large maps such as staking ledgers.
- Track upgrade announcements on the [Astar forum](https://forum.astar.network/) 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](https://dashboard.dwellir.com/register) 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:

1. **system\_health:** Expect `isSyncing: false` and peer count > 8.
2. **chain\_getHeader:** Confirm block numbers advance every \~6 seconds.
3. **state\_getStorage(System.Account):** Verify SCALE decoding of balances for a known treasury or team account.
4. **payment\_queryInfo on a signed extrinsic:** Validate the fee model before broadcasting from CI/CD.

## Resources & Tools

- [Astar Documentation](https://docs.astar.network/): network architecture, node operations, and dApp staking guides.
- [Astar GitHub Releases](https://github.com/AstarNetwork/Astar/releases): runtime and client binaries.
- [Dwellir Astar Network Page](https://www.dwellir.com/networks/astar): managed endpoints and quick-start snippets.
- [Astar Subscan Explorer](https://astar.subscan.io): 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.
