/midnight-skills:ankr-midnightfrom midnight-skills
Configures Ankr as a Midnight Network RPC provider for testnet and mainnet. Covers API key setup, HTTPS/WSS endpoints, wiring into midnight-js configs, and calling Midnight JSON-RPC methods.
Ships in midnight-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Use Ankr Chain RPC as your Midnight node endpoint for testnet and mainnet.
What this skill produces: working Ankr HTTPS/WSS URLs with API key, a small JSON-RPC client, midnight-js network config wired to Ankr, and call patterns for Midnight operations.
Primary references:
midnight-rpc/, midnight-js/, multinetwork/, indexer/@ankr.com/ankr.js (AnkrProvider) talks to Ankr Advanced API (ankr_getNFTsByOwner, getAccountBalance, …). Those methods are for EVM chains only (eth, polygon, bsc, …).
Midnight is not in the Advanced API chain list. Do not use:
// ❌ Wrong for Midnight — Advanced API / EVM only
import { AnkrProvider } from '@ankr.com/ankr.js';
const provider = new AnkrProvider('YOUR_ADVANCED_API_ENDPOINT');
await provider.getNFTsByOwner({ blockchain: 'eth', walletAddress: '0x…' });
For Midnight, use Ankr Node / Chain RPC: plain JSON-RPC POST to:
https://rpc.ankr.com/midnight_testnet/<API_KEY>
https://rpc.ankr.com/midnight_mainnet/<API_KEY>
Auth is the API key in the URL path — no Authorization header.
node / rpc at the Ankr URLmidnight_*, system_*, chain_*, …)Premium / paid plans unlock higher rate limits and private endpoints. Free/demo access may be rate-limited — prefer a project key for apps.
midnight_testnetmidnight_mainnetHTTPS: https://rpc.ankr.com/<network>/<API_KEY>
WSS: wss://rpc.ankr.com/<network>/<API_KEY>
| Midnight network | Ankr path | Example HTTPS |
|---|---|---|
| Testnet | midnight_testnet | https://rpc.ankr.com/midnight_testnet/<API_KEY> |
| Mainnet | midnight_mainnet | https://rpc.ankr.com/midnight_mainnet/<API_KEY> |
Formula: Endpoint = Project (API key) + Network.
Official Ankr request examples use a trailing slash:
https://rpc.ankr.com/midnight_testnet/YOUR_ANKR_API_KEY/
Both with and without trailing slash usually work; keep one style consistently.
# .env.local — never commit
ANKR_API_KEY=your_project_api_key_here
# Or store the full endpoint
ANKR_MIDNIGHT_TESTNET_RPC=https://rpc.ankr.com/midnight_testnet/your_project_api_key_here
ANKR_MIDNIGHT_MAINNET_RPC=https://rpc.ankr.com/midnight_mainnet/your_project_api_key_here
# Optional WebSocket
ANKR_MIDNIGHT_TESTNET_WSS=wss://rpc.ankr.com/midnight_testnet/your_project_api_key_here
ANKR_MIDNIGHT_MAINNET_WSS=wss://rpc.ankr.com/midnight_mainnet/your_project_api_key_here
Build URLs in code if you only store the key:
const ANKR_KEY = process.env.ANKR_API_KEY!;
if (!ANKR_KEY) throw new Error('Missing ANKR_API_KEY');
export const ANKR_MIDNIGHT = {
testnet: {
http: `https://rpc.ankr.com/midnight_testnet/${ANKR_KEY}`,
wss: `wss://rpc.ankr.com/midnight_testnet/${ANKR_KEY}`,
},
mainnet: {
http: `https://rpc.ankr.com/midnight_mainnet/${ANKR_KEY}`,
wss: `wss://rpc.ankr.com/midnight_mainnet/${ANKR_KEY}`,
},
} as const;
curl -X POST "https://rpc.ankr.com/midnight_testnet/${ANKR_API_KEY}/" \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"method": "system_chain",
"params": [],
"id": 1
}'
Expected shape:
{
"id": 1,
"jsonrpc": "2.0",
"result": "Midnight Preview" // illustrative; the value depends on the network the endpoint tracks
}
Quick health check:
curl -X POST "https://rpc.ankr.com/midnight_testnet/${ANKR_API_KEY}/" \
-H 'Content-Type: application/json' \
-d '{"jsonrpc":"2.0","method":"system_health","params":[],"id":1}'
No @ankr.com/ankr.js required for Midnight.
type JsonRpcId = number | string;
export async function ankrMidnightRpc<T = unknown>(
endpoint: string,
method: string,
params: unknown[] = [],
id: JsonRpcId = 1,
): Promise<T> {
const res = await fetch(endpoint, {
method: 'POST',
headers: { 'content-type': 'application/json' },
body: JSON.stringify({ jsonrpc: '2.0', method, params, id }),
});
if (!res.ok) {
throw new Error(`Ankr RPC HTTP ${res.status}: ${await res.text()}`);
}
const payload = (await res.json()) as {
result?: T;
error?: { code: number; message: string; data?: unknown };
};
if (payload.error) {
throw new Error(`Ankr RPC ${payload.error.code}: ${payload.error.message}`);
}
return payload.result as T;
}
Usage:
const rpc = process.env.ANKR_MIDNIGHT_TESTNET_RPC!;
const chain = await ankrMidnightRpc<string>(rpc, 'system_chain');
const health = await ankrMidnightRpc<{
peers: number;
isSyncing: boolean;
shouldHavePeers: boolean;
}>(rpc, 'system_health');
const apiVersions = await ankrMidnightRpc<number[]>(rpc, 'midnight_apiVersions');
Midnight dApps typically need three services. Ankr replaces only the node RPC:
| Service | Provider | Notes |
|---|---|---|
| Node RPC | Ankr (this skill) | midnight_*, system_*, tx submit paths used by SDKs |
| Indexer GraphQL | Midnight hosted indexer | Still indexer.*.midnight.network — not Ankr |
| Proof server | Local Docker or 1AM | Unchanged |
import { ANKR_MIDNIGHT } from './ankr';
// Map Ankr "testnet" to your app's Midnight testnet target
// (preview/preprod naming differs by SDK version — use the network your app deploys to)
export const networks = {
testnet: {
// Keep official indexer unless you have another GraphQL provider
// indexer.preprod.midnight.network was retired (HTTP 410); preprod's indexer is Blockfrost
indexerHttp: `https://midnight-preprod.blockfrost.io/api/v0?project_id=${process.env.BLOCKFROST_PROJECT_ID}`,
indexerWs: `wss://midnight-preprod.blockfrost.io/api/v0/ws?project_id=${process.env.BLOCKFROST_PROJECT_ID}`,
// Ankr node RPC (HTTPS). Some midnight-js setups expect WSS — use ANKR_MIDNIGHT.testnet.wss then.
rpc: ANKR_MIDNIGHT.testnet.http,
proofServerUrl: 'http://127.0.0.1:6300',
},
mainnet: {
// indexer.mainnet.midnight.network was retired (HTTP 410); mainnet's indexer is Blockfrost
indexerHttp: `https://midnight-mainnet.blockfrost.io/api/v0?project_id=${process.env.BLOCKFROST_PROJECT_ID}`,
indexerWs: `wss://midnight-mainnet.blockfrost.io/api/v0/ws?project_id=${process.env.BLOCKFROST_PROJECT_ID}`,
rpc: ANKR_MIDNIGHT.mainnet.http,
proofServerUrl: 'https://api.1am.xyz',
},
};
rpc.preprod.midnight.network / rpc.mainnet.midnight.network were shut down on 18 Nov 2026. Use the Ankr HTTPS URL (or WSS if the provider builder requires WebSocket) or Blockfrost's RPC (rpc.midnight-preprod.blockfrost.io?project_id=…). All networks run Ledger 9, so make sure the endpoint's node is 2.1.x.
Network naming note: Ankr exposes midnight_testnet / midnight_mainnet. Midnight apps often use preview / preprod / mainnet. Confirm which public Midnight network Ankr’s midnight_testnet tracks before deploying contracts against it: call system_chain (the official endpoints answer Midnight Preview, Midnight Preprod, Midnight Mainnet). Preview relaunched as a new chain on 7 Nov 2026, so older chain names are stale.
Full method catalog: Ankr Midnight docs and skill midnight-rpc/.
| Method | Purpose | Typical params |
|---|---|---|
midnight_apiVersions | Supported Midnight RPC API versions | [] |
midnight_contractState | Raw/binary contract state at optional block | [contractAddress, atBlockHash?] |
midnight_jsonContractState | Human-readable JSON contract state | [contractAddress, atBlockHash?] |
midnight_zswapChainState | ZSwap chain state for a contract | [contractAddress, atBlockHash?] |
midnight_jsonBlock | Full block as JSON | [blockHashOrNumber] |
midnight_decodeEvents | Decode Midnight contract events | [eventPayload…] (see node docs) |
const state = await ankrMidnightRpc(
rpc,
'midnight_jsonContractState',
['<contract-address>'], // omit second arg for latest
);
const zswap = await ankrMidnightRpc(
rpc,
'midnight_zswapChainState',
['<contract-address>'],
);
const versions = await ankrMidnightRpc(rpc, 'midnight_apiVersions');
| Method | Purpose |
|---|---|
system_chain | Chain name (e.g. Midnight Preview) |
system_chainType | Live / Development / Local |
system_health | Sync + peer health |
system_properties | Chain properties |
system_syncState | startingBlock / currentBlock / highestBlock |
system_version | Node implementation version |
await ankrMidnightRpc(rpc, 'system_chain');
await ankrMidnightRpc(rpc, 'system_syncState');
| Method | Purpose |
|---|---|
chain_getBlock | Full block by hash |
chain_getBlockHash | Hash for block number |
chain_getHeader | Block header |
chain_getFinalizedHead / chain_getFinalisedHead | Latest finalized hash |
chain_getHead | Best block hash |
chain_getRuntimeVersion | Runtime version |
const head = await ankrMidnightRpc<string>(rpc, 'chain_getFinalizedHead');
const block = await ankrMidnightRpc(rpc, 'chain_getBlock', [head]);
| Method | Purpose |
|---|---|
state_getStorage / state_getStorageAt | Read storage key |
state_getKeysPaged / state_getKeysPagedAt | Page storage keys |
state_getMetadata | Runtime metadata |
state_call / state_callAt | Runtime call without extrinsic |
state_queryStorageAt | Multi-key query at block |
| Method | Purpose |
|---|---|
archive_unstable_finalizedHeight | Latest archived finalized height |
archive_unstable_genesisHash | Genesis hash |
archive_unstable_hashByHeight | Hash(es) at height |
archive_unstable_header / archive_unstable_body | Historical header / extrinsics |
archive_unstable_call / archive_unstable_storage | Historical runtime call / storage |
| Method | Purpose |
|---|---|
sidechain_getStatus | Sidechain sync / status |
sidechain_getParams | Sidechain config params |
sidechain_getEpochCommittee | Validator committee for epoch |
sidechain_getRegistrations | Registered participants |
sidechain_getAriadneParameters | Ariadne parameters |
| Method | Purpose |
|---|---|
account_nextIndex / system_accountNextIndex | Next account nonce |
grandpa_proveFinality / grandpa_roundState | Finality proofs / round state |
childstate_getStorage (+ keys/hash/size variants) | Child storage reads |
rpc_methods | List methods exposed by this Ankr node |
offchain_localStorageGet / Set | Often restricted on public RPCs |
const methods = await ankrMidnightRpc(rpc, 'rpc_methods');
| Need | Use instead |
|---|---|
| Contract actions, tx history, live subscriptions | Midnight Indexer GraphQL (indexer/ skill) |
NFT/token portfolio APIs like getNFTsByOwner | Not available via Ankr Advanced API for Midnight |
| Proof generation | Local proof server or 1AM ProofStation |
| Compact compile / deploy | compact/, midnight-js/ |
| Symptom | Cause | Fix |
|---|---|---|
401 / unauthorized | Bad or missing API key in path | Recopy endpoint from Ankr Projects → Midnight |
method not found | Method not exposed on this node | Call rpc_methods; fall back to official Midnight RPC |
Advanced API / AnkrProvider errors with Midnight | Wrong product | Use Chain RPC JSON-RPC, not @ankr.com/ankr.js Advanced API |
| App works on official RPC, fails on Ankr | HTTPS vs WSS mismatch | Match protocol expected by midnight-js provider (http vs ws) |
| Rate limit / 429 | Free tier or empty credit balance | Upgrade plan / deposit API credits |
| Indexer queries fail after switching RPC | Indexer URL accidentally pointed at Ankr | Keep indexer on indexer.*.midnight.network |
| Wrong chain / contracts missing | Ankr testnet ≠ your preview/preprod deploy | Verify with system_chain and redeploy or switch network |
| Task | Skill |
|---|---|
| Midnight JSON-RPC method semantics | midnight-rpc/ |
| Provider wiring, wallets, deploy | midnight-js/ |
| Multi-network RPC/indexer/proof config | multinetwork/ |
| GraphQL reads & subscriptions | indexer/ |
| Environment / proof server setup | midnight-environment-setup/ |
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub kali-decoder/midnight-skills --plugin midnight-skills43 skills in this plugin
/1am-walletIntegrate the 1AM wallet for dust-free contract deployment and transaction flow on Midnight Network. Use this skill whenever a user is building a Midnight Network dApp, connecting to the 1AM browser extension, deploying or calling a Compact contract, handling ZK proving, setting up providers, or asking about dust-free transaction flow. Also use it for indexer patching, private state providers, payload encryption, or any question involving window.midnight['1am']./android-example-votingBuild a voting/poll dApp on Midnight Network using the Kuira Android SDK — Compact smart contract with create/cast/close circuits, passkey-derived identity, embedded wallet, Compose UI, reactive ledger reads via observeLedger(), and on-device ZK proving. Use when building a poll or voting dApp targeting Android./Other plugins' skills for the same job