## Why Build on Moonriver?

Moonriver is Moonbeam’s canary network on Kusama, delivering the same Substrate foundation and EVM compatibility with faster iteration cycles. It is ideal for deploying and testing EVM and Substrate-based functionality under real economic conditions before promoting to Moonbeam.

### Fast Iteration, Real Economics

- Rapid runtime upgrade cadence enables shipping features earlier than Moonbeam.
- Real MOVR token economics and on-chain governance for production-like validation.
- Shared Kusama security provides fast finality while enabling experimentation.

### EVM + Substrate Interop

- Full EVM compatibility via Frontier with MetaMask, Hardhat, and Solidity tooling.
- Native Substrate interfaces for storage, blocks, and runtime APIs.
- Seamless migration path to Moonbeam after validation on Moonriver.

## Quick Start with Moonriver

Connect to Moonriver production endpoints with Dwellir’s global network.

### Installation & Setup

curl (HTTP JSON-RPC)
JavaScript (polkadot.js)
Rust (subxt)
Python (py-substrate-interface)

```bash
curl -s https://api-moonriver.n.dwellir.com/YOUR_API_KEY \
  -H 'Content-Type: application/json' \
  -d '{
    "jsonrpc": "2.0",
    "method": "chain_getHeader",
    "params": [],
    "id": 1
  }'
```

```typescript
import { ApiPromise, WsProvider } from '@polkadot/api';

async function main() {
  const provider = new WsProvider('wss://api-moonriver.n.dwellir.com/YOUR_API_KEY');
  const api = await ApiPromise.create({ provider });

  const [chain, version] = await Promise.all([
    api.rpc.system.chain(),
    api.rpc.system.version(),
  ]);

  console.log(`Connected to ${chain.toString()} v${version.toString()}`);

  // Subscribe to new blocks
  const unsub = await api.rpc.chain.subscribeNewHeads((header) => {
    console.log(`New block #${header.number} at ${header.hash}`);
  });

  // Stop after a short period
  setTimeout(async () => {
    await unsub();
    await api.disconnect();
  }, 15000);
}

main().catch(console.error);
```

```rust
use subxt::{OnlineClient, PolkadotConfig};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let api = OnlineClient::<PolkadotConfig>::from_url(
        "wss://api-moonriver.n.dwellir.com/YOUR_API_KEY"
    ).await?;

    let header = api.rpc().block_header(None).await?.expect("latest header");
    println!("Latest block: #{:?} (hash {:?})", header.number, header.hash());

    Ok(())
}
```

```python
from substrateinterface import SubstrateInterface

substrate = SubstrateInterface(
    url="wss://api-moonriver.n.dwellir.com/YOUR_API_KEY"
)

chain = substrate.rpc_request("system_chain", [])
print(f"Connected to {chain['result']}")

head = substrate.rpc_request("chain_getFinalizedHead", [])
print(f"Finalized head: {head['result']}")
```

## Network Information

| Parameter            | Value            | Details                  |
| -------------------- | ---------------- | ------------------------ |
| Genesis Hash         | 0x401a1f9d…1474b | chain\_getBlockHash(0)   |
| Native Token         | MOVR             | 18 decimals              |
| SS58 Prefix          | 1285             | system\_properties       |
| Relay / Para ID      | Kusama / 2023    | Parachain on Kusama      |
| Runtime Spec Version | 3900             | As of 9 Oct 2025         |
| Transaction Version  | 3                | state\_getRuntimeVersion |
| Explorer             | Moonscan         | moonriver.moonscan.io    |

### Example Values Used in Docs

These chain-specific variables are used across Moonriver examples:

## API Reference

Moonriver exposes standard Substrate RPC namespaces for node telemetry, block production, storage access, and fee estimation.

## Common Integration Patterns

### Track new blocks (subscriptions)

```typescript
const unsub = await api.rpc.chain.subscribeNewHeads((header) => {
  console.log(`New #${header.number} (${header.hash})`);
});
```

### Paginate large storage scans

```typescript
const page = await api.rpc.state.getKeysPaged(
  api.query.system.account.keyPrefix(),
  100,
  '0x',
  null
);
console.log('Fetched', page.length, 'System.Account keys');
```

### Estimate fees before broadcast

```typescript
const ext = api.tx.balances.transferAllowDeath(dest, amount);
const info = await api.rpc.payment.queryInfo(ext.toHex());
console.log(`PartialFee: ${info.partialFee.toHuman()}`);
```

## Performance Best Practices

- Prefer WebSocket connections for subscriptions and multi-round queries.
- Cache runtime metadata and reuse a single ApiPromise instance.
- Use `state_getKeysPaged` for large scans; avoid full-chain traversals.
- Exponential backoff on retries for transient `-32010`/`TooManyRequests` errors.

## Troubleshooting

- **WebSocket failure** – Verify your API key and outbound TCP/443. Try HTTPS for single calls.
- **Type mismatches** – Refresh metadata after runtime upgrades (`api.runtimeVersion`).
- **Invalid address** – Moonriver uses SS58 prefix `1285` for Substrate addresses; EVM `0x…` accounts are also supported in the runtime.
- **Extrinsic rejected** – Decode with `api.registry.findMetaError` to surface module/error.

## Smoke Tests

Run these checks against production endpoints (values as of 9 Oct 2025):

```bash
# Moonriver RPC with Dwellir
curl -s https://api-moonriver.n.dwellir.com/YOUR_API_KEY \
  -H 'Content-Type: application/json' \
  -d '{"jsonrpc":"2.0","id":1,"method":"system_health","params":[]}'

# Latest block header
curl -s https://api-moonriver.n.dwellir.com/YOUR_API_KEY \
  -H 'Content-Type: application/json' \
  -d '{"jsonrpc":"2.0","id":1,"method":"chain_getHeader","params":[]}'

# Runtime version
curl -s https://api-moonriver.n.dwellir.com/YOUR_API_KEY \
  -H 'Content-Type: application/json' \
  -d '{"jsonrpc":"2.0","id":1,"method":"state_getRuntimeVersion","params":[]}'
```

## Migration Guide

- **Endpoints** – Replace Polkadot/Moonbeam URLs with `https://api-moonriver.n.dwellir.com/YOUR_API_KEY` or `wss://api-moonriver.n.dwellir.com/YOUR_API_KEY`.
- **Addresses** – Use SS58 prefix `1285` for Substrate-style addresses when needed; EVM `0x…` addresses remain valid for account state.
- **Runtime types** – Update custom type bundles as needed and refresh metadata caches after upgrades (specVersion `3900` on Oct 9, 2025).
- **Fees** – Calibrate using `payment_queryInfo`/`payment_queryFeeDetails` for MOVR-denominated fees.
- **XCM/Parachain** – Confirm HRMP channels and destination parachain IDs for XCM; Moonriver is parachain `2023` on Kusama.

## Resources & Tools

- [Moonriver Moonscan Explorer](https://moonriver.moonscan.io)
- [Subscan – Moonriver](https://moonriver.subscan.io)
- [Moonbeam Docs – Moonriver](https://docs.moonbeam.network/builders/get-started/networks/moonriver/)
- [Substrate Developer Hub](https://docs.substrate.io/)
- [Dwellir Dashboard – Get your API key](https://dashboard.dwellir.com/register)
