# Enjin RPC with Dwellir

## Enjin 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 Enjin 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 Enjin Matrix?

### NFT-First Runtime

- Protocol-level NFT minting, on-chain metadata, and marketplace enforcement remove the need for bespoke smart contracts ([Enjin Blockchain overview](https://enjin.io/technology/blockchain)).
- ENJ-denominated fees are tuned for games and app developers, giving predictable operating costs for live services ([Enjin Blockchain overview](https://enjin.io/technology/blockchain)).

### Fuel Tanks & Managed Wallets

- Fuel tanks sponsor transaction fees for specific players or apps, smoothing onboarding into Matrixchain ([Fuel Tanks docs](https://docs.enjin.io/docs/creating-a-fuel-tank)).
- Managed wallets let users receive NFTs before creating self-custodial accounts, ideal for mainstream launches ([Managed wallets docs](https://docs.enjin.io/docs/using-managed-wallets)).

### Dual-Layer Security

- Matrixchain execution is secured by the Enjin Relaychain, combining Aura authoring with relay-governed GRANDPA finality ([Enjin Blockchain overview](https://enjin.io/technology/blockchain)).
- Custom matrixchains can connect while inheriting the same security and cross-chain routing primitives provided by the Relaychain ([Enjin Blockchain overview](https://enjin.io/technology/blockchain)).

## Quick Start with Enjin

Sign up at the Dwellir dashboard to generate an API key, then replace `YOUR_API_KEY` in the endpoints above. Keys can be scoped per environment to manage limits and analytics.

### Installation & Setup

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

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

# Latest finalized head
curl -s https://api-enjin-matrixchain.n.dwellir.com/YOUR_API_KEY \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","method":"chain_getFinalizedHead","params":[],"id":2}'

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

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

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

const [chain, runtime, head] = await Promise.all([
  api.rpc.system.chain(),
  api.rpc.state.getRuntimeVersion(),
  api.rpc.chain.getHeader()
]);

console.log(`Connected to ${chain} specVersion ${runtime.specVersion}`);
console.log(`Best block #${head.number.toNumber()} (${head.hash.toHex()})`);

const validator = 'efS1ZdvCHHviX7qnTGZEZQX9Uz3qpibG9L5RpF9niM8ne5RBn';
const account = await api.query.system.account(validator);
console.log('Validator free balance:', account.data.free.toHuman());
```

```rust
use subxt::{OnlineClient, PolkadotConfig};
use subxt::ext::sp_core::crypto::AccountId32;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    let api = OnlineClient::<PolkadotConfig>::from_url(
        "wss://api-enjin-matrixchain.n.dwellir.com/YOUR_API_KEY"
    ).await?;

    let runtime = api.rpc().runtime_version(None).await?;
    println!("specVersion={} txVersion={}", runtime.spec_version, runtime.transaction_version);

    let account: AccountId32 = "efS1ZdvCHHviX7qnTGZEZQX9Uz3qpibG9L5RpF9niM8ne5RBn".parse()?;
    let balance = api
        .storage()
        .at_latest()
        .await?
        .fetch(&subxt::dynamic::storage("System", "Account", vec![account.clone().into()]))
        .await?;
    println!("Account info: {:?}", balance);
    Ok(())
}
```

```python
from substrateinterface import SubstrateInterface

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

chain = substrate.rpc_request("system_chain", [])
print("Chain:", chain["result"])

account_info = substrate.query(
    module='System',
    storage_function='Account',
    params=['efS1ZdvCHHviX7qnTGZEZQX9Uz3qpibG9L5RpF9niM8ne5RBn']
)
print("Free balance:", account_info.value['data']['free'])
```

## Network Information

| Parameter    | Value                                                              | Details                                            |
| ------------ | ------------------------------------------------------------------ | -------------------------------------------------- |
| Genesis Hash | 0x3af4ff48ec76d2efc8476730f423ac07e25ad48f5f4c9dc39c778b164d808615 | Verified via `chain_getBlockHash(0)`               |
| Runtime Spec | 1022                                                               | Transaction version 11 (`state_getRuntimeVersion`) |
| SS58 Prefix  | 1110                                                               | `system_properties` result                         |
| Native Token | ENJ                                                                | 18 decimals (`system_properties`)                  |

### Matrix Ecosystem Snapshot (3 Oct 2025)

| Parameter      | Value                                         | Details                                                                                                                                                                                 |
| -------------- | --------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Relay Chain    | Enjin Relaychain                              | `0xd8761d3c88f26dc12875c00d3165f7d67243d56fc85b4cf19937601a7916e5a9`, verified via `chain_getBlockHash(0)` against the Enjin Relay archive RPC host `archive.relay.blockchain.enjin.io` |
| Finality       | Aura authorship with GRANDPA finality         | Shared by the Enjin Relaychain                                                                                                                                                          |
| Address Format | SS58 prefix `1110`                            | Returned by `system_properties` against the Enjin Matrix archive RPC host `archive.matrix.blockchain.enjin.io`                                                                          |
| Runtime        | Spec version `1022`, transaction version `11` | `state_getRuntimeVersion` against the Enjin Matrix archive RPC host `archive.matrix.blockchain.enjin.io`                                                                                |
| Explorers      | [Matrix Console](https://console.enjin.io)    | Mainnet and canary                                                                                                                                                                      |
| Canary Runtime | Enjin Matrix Canary                           | `wss://api-enjin-canary-matrix.n.dwellir.com/YOUR_API_KEY`                                                                                                                              |

## API Reference

Enjin Matrix exposes the standard Substrate RPC surface for node health, storage, extrinsics, and fee estimation, with additional Matrix-specific namespaces such as `fuelTanks_*`, `multitokens_*`, `ismp_*`, and `transactionWatch_v1_*` available depending on your environment and authorization scope.

> **Tip:** Use [`rpc_methods`](https://www.dwellir.com/docs/enjin/rpc_methods) to verify which optional namespaces (fuel tanks, multitokens, ISMP) are enabled for your API key and environment.

Additional Substrate namespaces such as `childstate_*`, `offchain_*`, and read-proof helpers follow the standard Substrate semantics; their availability depends on node configuration and authorization. Use `rpc_methods` to inspect support before invoking them from clients.

## Common Integration Patterns

- **Fuel tank sponsorship** – poll `fuelTanks_selectFuelTank` to determine which tank will cover fees for a user, then handle top-ups via governance-controlled accounts.
- **Managed wallet onboarding** – detect custodial wallets via metadata and migrate them to self-custody by monitoring `Balances.Transfer` events to managed accounts.
- **NFT marketplace indexing** – subscribe to `chain_subscribeFinalizedHeads`, pull block extrinsics, and decode marketplace pallets to track listings, royalty enforcement, and burns.

## Performance Best Practices

- Prefer WebSocket endpoints for subscriptions and batched queries; fall back to HTTPS for stateless reads.
- Cache runtime metadata keyed by `specVersion` to avoid re-fetching large SCALE blobs on each connection.
- Use `state_getKeysPaged` with modest page sizes (≤500) when walking storage maps to respect rate limits.
- Implement exponential backoff and retry logic for transient `429` or networking errors.

## Troubleshooting

- **Connection refused** – ensure `YOUR_API_KEY` is present and the hostname matches the region you activated in Dwellir.
- **Invalid SS58** – use prefix `1110` when encoding Matrixchain addresses; relay chain accounts use prefix `2135`.
- **Extrinsic failures** – decode the `DispatchError` using the latest metadata; many marketplace pallets return module-specific error codes.
- **Missing custom RPCs** – extend Polkadot.js type bundles with Enjin-specific RPC definitions when `API/INIT` warns about undecorated methods.

## Smoke Tests

Run these endpoints after deployment to validate connectivity:

```bash
# Health (should report peers > 0)
curl -s https://api-enjin-matrixchain.n.dwellir.com/YOUR_API_KEY \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","method":"system_health","params":[],"id":1}'

# Latest finalized hash
curl -s https://api-enjin-matrixchain.n.dwellir.com/YOUR_API_KEY \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","method":"chain_getFinalizedHead","params":[],"id":2}'

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

# RPC surface area
curl -s https://api-enjin-matrixchain.n.dwellir.com/YOUR_API_KEY \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","method":"rpc_methods","params":[],"id":4}'
```

## Migration Guide (Polkadot/Westend → Enjin Matrix)

1. **Endpoints** – replace legacy Polkadot/Westend RPC URLs with Dwellir Matrix endpoints listed above.
2. **Address format** – re-encode accounts with SS58 prefix `1110`; update wallet tooling accordingly.
3. **Fee economics** – call `payment_queryInfo` to account for ENJ-denominated fees and optional fuel tank sponsorships.
4. **Runtime pallets** – verify availability of Matrix-specific pallets (fuel tanks, managed wallets) and adjust type bundles.
5. **Event handling** – update indexers to interpret Enjin marketplace and multitoken events instead of Polkadot parachain events.

## Resources & Tools

- [Enjin Blockchain Technology Overview](https://enjin.io/technology/blockchain) – architecture, performance targets, and ecosystem highlights.
- [Console Explorer](https://console.enjin.io) – monitor blocks, accounts, and collections across mainnet and canary.
- [Dwellir Dashboard](https://dashboard.dwellir.com) – manage API keys, usage analytics, and plan limits.
- [Subscan (Matrixchain)](https://matrix.subscan.io) – alternative explorer for validators and extrinsics.

***

Ready to go live? Deploy against Matrix mainnet using Dwellir’s globally anycasted infrastructure, then automate observability with the smoke tests above.
