For the complete documentation index, see llms.txt. This page is also available as Markdown.

midnight_contractState - Midnight

Example code for the midnight_contractState JSON-RPC method. Complete guide on how to use midnight_contractState JSON-RPC in GetBlock Web3 documentation.

This method fetches the on-chain state of a Midnight smart contract and returns it in raw encoded form. For a human-readable JSON version, use midnight_jsonContractState.

Parameters

Parameter
Type
Required
Description

address

string

Yes

Contract address (SS58 or hex form)

Request Example

curl --location --request POST 'https://go.getblock.io/<ACCESS-TOKEN>/' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "midnight_contractState",
    "params": [
        "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY"
    ],
    "id": "getblock.io"
}'

Response Example

{
    "jsonrpc": "2.0",
    "id": "getblock.io",
    "result": {
        "data": "0x010203\u2026",
        "nonce": 42,
        "balance": "0x0de0b6b3a7640000"
    }
}

Response Parameters

Field
Type
Description

result.data

string

Hex-encoded raw contract state blob

result.nonce

integer

Contract account nonce

result.balance

string

Contract DUST balance (hex-encoded)

Use Cases

  • Reading raw contract state for off-chain ZK proof generation

  • Replicating contract state in indexers

  • Auditing contract state for security analysis

Error Handling

Status Code
Error Message
Cause

403

Forbidden

Missing or invalid <ACCESS-TOKEN>

-32602

Invalid params

Request parameters are missing or malformed

429

Too Many Requests

Rate limit exceeded for your plan

SDK Integration

Last updated

Was this helpful?