Midnight

Midnight is a data protection-focused blockchain developed by Input Output Global (IOG) — the team behind Cardano — designed to bring confidential smart contracts and zero-knowledge (ZK) cryptography to Web3. Operating as a partner chain to Cardano and built on the Substrate framework, Midnight enables developers to write privacy-preserving decentralized applications in TypeScript using the Compact language, which compiles directly to ZK circuits.

The network uses a dual-token model:

  • NIGHT for governance and staking, and the shielded token
  • DUST for transaction fees — to allow selective disclosure of sensitive information while maintaining the auditability and security of public blockchains.

Key Features

  • Confidential Smart Contracts: Smart contracts authored in TypeScript with the Compact ZK-DSL, compiling directly to zero-knowledge circuits
  • Zero-Knowledge Proofs (ZKPs): Native ZK primitives for verifying computation without revealing underlying data
  • Privacy-First Architecture: Built for data protection and regulatory compliance, including GDPR-friendly selective disclosure
  • Dual-Token Economy: NIGHT (unshielded governance/staking token) and DUST (shielded gas token derived from NIGHT)
  • Cardano Partner Chain: Interoperable with Cardano; Cardano Stake Pool Operators can become Midnight Block Producers
  • Substrate-Based: Built on the Substrate framework, exposing the standard Substrate JSON-RPC surface plus Midnight extensions
  • GRANDPA Finality: Deterministic block finality via the Substrate GRANDPA finality gadget
  • Selective Disclosure: Users choose what information to share and with whom, enabled by ZK selective-disclosure primitives
  • ZSwap Privacy Layer: A native shielded UTXO model for confidential token transfers
  • WebSocket-First: Full subscription support for real-time block, event, and storage updates via standard Substrate subscriptions

TECHNICAL DISCLAIMER: AUTHORITATIVE JSON-RPC SPECIFICATION

GetBlock’s Midnight API reference documentation is provided exclusively for informational purposes and to optimize the developer experience. The canonical specification for Midnight's JSON-RPC interface is exposed live by every Midnight node via the rpc_methods call, and the Substrate JSON-RPC base is documented at the Polkadot SDK reference. For protocol-level details, consensus parameters, and the dual-token model, consult the official Midnight documentation at docs.midnight.network.

Network Information

PropertyValue
Network NameMidnight
Native TokensNIGHT (governance/staking), DUST (shielded gas, 6 decimals)
Block Time~6 seconds (Substrate default)
ConsensusCustom privacy-aware Proof-of-Stake (Aura authoring + GRANDPA finality)
ArchitectureSubstrate partner chain to Cardano
Smart Contract LayerCompact (ZK-DSL compiling to circuits); TypeScript SDK
EVM CompatibleNo
Address FormatSS58 (Substrate-style)
Block ExplorerMidnight Explorer (community)

Base URL

bashhttps://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/
bashhttps://shared.us-east-1.getblock.io/<ACCESS-TOKEN>/
bashhttps://shared.ap-southeast-1.getblock.io/<ACCESS-TOKEN>/

All Midnight JSON-RPC methods are called by sending a POST request to the base URL with a standard JSON-RPC 2.0 body. For real-time subscriptions (new blocks, finalized heads, runtime events) use the WebSocket scheme: wss://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/.

Supported Networks

NetworkJSON-RPCWSSFrankfurt, GermanyNew York, USASingapore, Singapore
Mainnet✅✅✅❌❌
testnet-02✅✅✅✅✅

Quickstart

In this section, you will learn how to make your first call with either:

  • Axios (JavaScript / Node.js)
  • Python (Requests library)

Before you begin, you must have already installed npm or yarn on your local machine (for the Axios example) or Python and pip (for the Python example).

  1. Setup project

    Create and initialize a new project:

    bashmkdir midnight-api-quickstart
    cd midnight-api-quickstart
    npm init --yes
  2. Install Axios

    bashnpm install axios
  3. Create file

    Create a new file named index.js. This is where you will make your first call.

  4. Set ES module type

    Set the ES module "type": "module" in your package.json.

  5. Add code

    Add the following code to index.js:

    index.js

    javascriptimport axios from 'axios';
    
    const data = JSON.stringify({
        "jsonrpc": "2.0",
        "method": "system_chain",
        "params": [],
        "id": "getblock.io"
    });
    
    const config = {
        method: 'post',
        url: 'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/',
        headers: {
            'Content-Type': 'application/json'
        },
        data: data
    };
    
    axios(config)
        .then(response => console.log(JSON.stringify(response.data, null, 2)))
        .catch(error => console.log(error));

    Replace <ACCESS-TOKEN> with your actual GetBlock access token.

  6. Run the script

    bashnode index.js

    Expected output (example):

    json{
        "jsonrpc": "2.0",
        "id": "getblock.io",
        "result": "Midnight Mainnet"
    }
  1. Setup the project directory

    bashmkdir midnight-api-quickstart
    cd midnight-api-quickstart
  2. Create and activate a virtual environment

    bashpython -m venv venv
    source venv/bin/activate
    
    # On Windows, use venv\Scripts\activate
  3. Install requests

    bashpip install requests
  4. Create script

    Create a file called main.py with the following content:

    main.py

    pythonimport requests
    import json
    
    url = "https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/"
    
    payload = json.dumps({
        "jsonrpc": "2.0",
        "method": "system_chain",
        "params": [],
        "id": "getblock.io"
    })
    
    headers = {
        'Content-Type': 'application/json'
    }
    
    response = requests.post(url, headers=headers, data=payload)
    print(response.text)

    Replace <ACCESS-TOKEN> with your actual GetBlock access token.

  5. Run the script

    bashpython main.py

Available API Methods

Midnight exposes the full Substrate JSON-RPC surface, plus Midnight-specific extensions and partner chain primitives. Every method is callable via HTTP POST or over a WebSocket connection. Subscription-style methods are only available over WSS.

System Information & Networking

MethodDescription
system_chainReturns the name of the connected chain
system_chainTypeReturns the chain type (Live, Development, Local)
system_healthReturns node health and sync status
system_propertiesReturns chain properties (SS58 format, token decimals, symbols)
system_syncStateReturns sync status and highest known block
system_versionReturns the node implementation version
system_nameReturns the node implementation name

Accounts & Keys

MethodDescription
account_nextIndexReturns the next nonce (account index) for an account
system_accountNextIndexAlias to account_nextIndex

GRANDPA Finality

MethodDescription
grandpa_proveFinalityProvides a justification proof for finalized blocks via GRANDPA
grandpa_roundStateReturns the current GRANDPA round state

Off-chain Worker Storage

MethodDescription
offchain_localStorageGetReads data from local off-chain worker storage
offchain_localStorageSetWrites data into local off-chain worker storage

Archive (Unstable v2 API)

MethodDescription
archive_unstable_bodyFetches the body of a historical block
archive_unstable_callExecutes a runtime call at a specific block
archive_unstable_finalizedHeightReturns the height of the finalized block
archive_unstable_genesisHashReturns the genesis block hash
archive_unstable_hashByHeightReturns the block hash at a given height
archive_unstable_headerFetches the header of a historical block
archive_unstable_storageReturns historical storage values

Midnight-Specific

MethodDescription
midnight_apiVersionsLists supported Midnight API versions on the node
midnight_contractStateFetches the on-chain state of a Midnight smart contract
midnight_decodeEventsDecodes event data emitted by Midnight smart contracts
midnight_jsonBlockReturns a full block in human-readable JSON format
midnight_jsonContractStateReturns human-readable JSON-formatted contract state
midnight_zswapChainStateReturns the ZSwap (shielded UTXO layer) state

Sidechain & Partner Chain

MethodDescription
sidechain_getAriadneParametersReturns Ariadne protocol parameters used for privacy
sidechain_getEpochCommitteeReturns the validator committee for a given epoch
sidechain_getParamsReturns current sidechain configuration parameters
sidechain_getStatusReturns current sidechain status (sync state and parameters)

Chain & Block Data

MethodDescription
chain_getBlockReturns full block data by block hash
chain_getBlockHashReturns the block hash for a given block number
chain_getFinalizedHeadReturns the latest finalized block hash (chain_getFinalisedHead is an alias)
chain_getHeadReturns the current best block hash
chain_getHeaderReturns the header of a given block
chain_getRuntimeVersionReturns the current runtime version

State & Storage

MethodDescription
state_callExecutes a runtime call without submitting an extrinsic
state_callAtExecutes a runtime call at a specific block
state_getMetadataReturns the current runtime metadata
state_getRuntimeVersionReturns the runtime version at the current best block
state_getKeysReturns a list of storage keys (deprecated, use state_getKeysPaged)
state_getKeysPagedReturns paged storage keys
state_getKeysPagedAtReturns paged storage keys at a specific block
state_getStorageReturns a storage value for a given key
state_getStorageAtReturns a storage value at a given block
state_getStorageHashReturns the hash of a storage entry
state_getStorageSizeReturns the byte size of a storage entry
state_getReadProofReturns a Merkle proof of inclusion for storage entries
state_queryStorageAtQueries storage at a specific block

Child State

MethodDescription
childstate_getKeysReturns keys from child storage
childstate_getKeysPagedReturns paged keys from child storage
childstate_getStorageReturns a storage entry from child storage
childstate_getStorageEntriesReturns multiple entries from child storage
childstate_getStorageHashReturns the hash of a child storage value
childstate_getStorageSizeReturns the byte size of a child storage value

Author (Transaction Submission)

MethodDescription
author_submitExtrinsicSubmits a signed extrinsic to the network
author_pendingExtrinsicsReturns extrinsics currently in the pool
author_removeExtrinsicRemoves extrinsics from the pool

RPC Meta

MethodDescription
rpc_methodsReturns the list of all RPC methods supported by the connected node

Support

For technical support and questions:

See Also