Realm Edge RPC Documentation

This document provides comprehensive documentation for all Realm Edge RPC methods defined in the RealmEdgeRpc trait.

RPC Namespace: qed


Table of Contents

  1. User Management
  2. User End Cap Submission
  3. Checkpoint Data Operations
  4. L2 Block State Operations
  5. User Registration Tree Operations
  6. Checkpoint Tree Operations
  7. User Leaf Data Operations
  8. User Contract State Tree Operations
  9. User Contract Tree Operations
  10. User Tree Operations
  11. Batch Proof Generation
  12. GraphViz Export
  13. Data Structures

User Management

1. check_user_id_in_realm

Check if a user ID belongs to this realm.

Method Name: qed_check_user_id_in_realm

Request Parameters:

{
  "user_id": 12345
}
ParameterTypeDescription
user_idu64The user ID to check

Response:

{
  "result": true
}
FieldTypeDescription
resultbooltrue if the user belongs to this realm, false otherwise

Example:

curl -X POST http://localhost:8545 \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "method": "qed_check_user_id_in_realm",
    "params": [12345],
    "id": 1
  }'

User End Cap Submission

2. submit_user_end_cap

Submit a user end cap proof for processing.

Method Name: qed_submit_user_end_cap

Request Parameters:

{
  "user_ec_input": {
    "core": {
      "checkpoint_id": "123",
      "stats": { ... },
      "state_transition": { ... },
      "new_user_leaf": { ... }
    },
    "contract_state_updates": [ ... ]
  },
  "proof": { ... }
}
ParameterTypeDescription
user_ec_inputSubmitUserEndCapNonProofInput<F>End cap input data (see Data Structures)
proofProofWithPublicInputs<F, C, D>Zero-knowledge proof

Response:

{
  "result": "0x1234567890abcdef..."
}
FieldTypeDescription
resultStringTransaction hash or job ID

Checkpoint Data Operations

3. get_checkpoint_leaf_data

Get checkpoint leaf data by checkpoint ID (u64 parameter).

Method Name: qed_get_checkpoint_leaf_data

Request Parameters:

{
  "checkpoint_id": 100
}
ParameterTypeDescription
checkpoint_idu64The checkpoint ID

Response: See QEDCheckpointLeaf

Example:

curl -X POST http://localhost:8545 \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "method": "qed_get_checkpoint_leaf_data",
    "params": [100],
    "id": 1
  }'

4. get_checkpoint_leaf_data_f

Get checkpoint leaf data by checkpoint ID (Field parameter).

Method Name: qed_get_checkpoint_leaf_data_f

Request Parameters:

{
  "checkpoint_id": "100"
}
ParameterTypeDescription
checkpoint_idF (Field)The checkpoint ID as a field element

Response: See QEDCheckpointLeaf


L2 Block State Operations

5. get_latest_l2_block_state

Get the latest L2 block state.

Method Name: qed_get_latest_l2_block_state

Request Parameters: None

Response: See QEDL2BlockState

Example:

curl -X POST http://localhost:8545 \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "method": "qed_get_latest_l2_block_state",
    "params": [],
    "id": 1
  }'

Response Example:

{
  "result": {
    "checkpoint_id": 100,
    "next_add_withdrawal_id": 50,
    "next_process_withdrawal_id": 45,
    "next_deposit_id": 200,
    "total_deposits_claimed_epoch": 180,
    "next_user_id": 1000,
    "end_balance": 5000000,
    "next_contract_id": 25
  }
}

6. get_l2_block_state

Get L2 block state at a specific checkpoint (u64 parameter).

Method Name: qed_get_l2_block_state

Request Parameters:

{
  "checkpoint_id": 100
}
ParameterTypeDescription
checkpoint_idu64The checkpoint ID

Response: See QEDL2BlockState


7. get_l2_block_state_f

Get L2 block state at a specific checkpoint (Field parameter).

Method Name: qed_get_l2_block_state_f

Request Parameters:

{
  "checkpoint_id": "100"
}
ParameterTypeDescription
checkpoint_idF (Field)The checkpoint ID as a field element

Response: See QEDL2BlockState


User Registration Tree Operations

8. get_user_registration_tree_root

Get the user registration tree root at a specific checkpoint.

Method Name: qed_get_user_registration_tree_root

Request Parameters:

{
  "checkpoint_id": 100
}
ParameterTypeDescription
checkpoint_idu64The checkpoint ID

Response: See QHashOut

Example Response:

{
  "result": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"
}

Checkpoint Tree Operations

9. get_latest_checkpoint_tree_root

Get the latest checkpoint tree root.

Method Name: qed_get_latest_checkpoint_tree_root

Request Parameters: None

Response: See QHashOut


10. get_checkpoint_tree_root

Get checkpoint tree root at a specific checkpoint (u64 parameter).

Method Name: qed_get_checkpoint_tree_root

Request Parameters:

{
  "checkpoint_id": 100
}
ParameterTypeDescription
checkpoint_idu64The checkpoint ID

Response: See QHashOut


11. get_checkpoint_tree_root_f

Get checkpoint tree root at a specific checkpoint (Field parameter).

Method Name: qed_get_checkpoint_tree_root_f

Request Parameters:

{
  "checkpoint_id": "100"
}
ParameterTypeDescription
checkpoint_idF (Field)The checkpoint ID as a field element

Response: See QHashOut


12. get_checkpoint_tree_leaf_hash

Get a specific checkpoint tree leaf hash (u64 parameters).

Method Name: qed_get_checkpoint_tree_leaf_hash

Request Parameters:

{
  "checkpoint_id": 100,
  "leaf_checkpoint_id": 95
}
ParameterTypeDescription
checkpoint_idu64The checkpoint ID
leaf_checkpoint_idu64The leaf checkpoint ID

Response: See QHashOut


13. get_checkpoint_tree_leaf_hash_f

Get a specific checkpoint tree leaf hash (Field parameters).

Method Name: qed_get_checkpoint_tree_leaf_hash_f

Request Parameters:

{
  "checkpoint_id": "100",
  "leaf_checkpoint_id": "95"
}
ParameterTypeDescription
checkpoint_idF (Field)The checkpoint ID as a field element
leaf_checkpoint_idF (Field)The leaf checkpoint ID as a field element

Response: See QHashOut


14. get_checkpoint_tree_merkle_proof

Get Merkle proof for a checkpoint tree leaf (u64 parameters).

Method Name: qed_get_checkpoint_tree_merkle_proof

Request Parameters:

{
  "checkpoint_id": 100,
  "leaf_checkpoint_id": 95
}
ParameterTypeDescription
checkpoint_idu64The checkpoint ID
leaf_checkpoint_idu64The leaf checkpoint ID

Response: See MerkleProofCore


15. get_checkpoint_tree_merkle_proof_f

Get Merkle proof for a checkpoint tree leaf (Field parameters).

Method Name: qed_get_checkpoint_tree_merkle_proof_f

Request Parameters:

{
  "checkpoint_id": "100",
  "leaf_checkpoint_id": "95"
}
ParameterTypeDescription
checkpoint_idF (Field)The checkpoint ID as a field element
leaf_checkpoint_idF (Field)The leaf checkpoint ID as a field element

Response: See MerkleProofCore


16. get_checkpoint_global_state_roots

Get global state roots at a specific checkpoint.

Method Name: qed_get_checkpoint_global_state_roots

Request Parameters:

{
  "checkpoint_id": 100
}
ParameterTypeDescription
checkpoint_idu64The checkpoint ID

Response: See QEDCheckpointGlobalStateRoots

Example Response:

{
  "result": {
    "contract_tree_root": "0x...",
    "deposit_tree_root": "0x...",
    "user_tree_root": "0x...",
    "withdrawal_tree_root": "0x...",
    "user_registration_tree_root": "0x..."
  }
}

User Leaf Data Operations

17. get_user_leaf_data

Get user leaf data at a specific checkpoint (u64 parameters).

Method Name: qed_get_user_leaf_data

Request Parameters:

{
  "checkpoint_id": 100,
  "user_id": 12345
}
ParameterTypeDescription
checkpoint_idu64The checkpoint ID
user_idu64The user ID

Response: See QEDUserLeaf

Example:

curl -X POST http://localhost:8545 \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "method": "qed_get_user_leaf_data",
    "params": [100, 12345],
    "id": 1
  }'

18. get_user_leaf_data_f

Get user leaf data at a specific checkpoint (Field parameters).

Method Name: qed_get_user_leaf_data_f

Request Parameters:

{
  "checkpoint_id": "100",
  "user_id": "12345"
}
ParameterTypeDescription
checkpoint_idF (Field)The checkpoint ID as a field element
user_idF (Field)The user ID as a field element

Response: See QEDUserLeaf


User Contract State Tree Operations

19. get_user_contract_state_tree_root

Get user contract state tree root (u64 parameters).

Method Name: qed_get_user_contract_state_tree_root

Request Parameters:

{
  "checkpoint_id": 100,
  "user_id": 12345,
  "contract_id": 5
}
ParameterTypeDescription
checkpoint_idu64The checkpoint ID
user_idu64The user ID
contract_idu32The contract ID

Response: See QHashOut


20. get_user_contract_state_tree_root_f

Get user contract state tree root (Field parameters).

Method Name: qed_get_user_contract_state_tree_root_f

Request Parameters:

{
  "checkpoint_id": "100",
  "user_id": "12345",
  "contract_id": "5"
}
ParameterTypeDescription
checkpoint_idF (Field)The checkpoint ID as a field element
user_idF (Field)The user ID as a field element
contract_idF (Field)The contract ID as a field element

Response: See QHashOut


21. get_user_contract_state_tree_leaf_hash

Get user contract state tree leaf hash (u64 parameters).

Method Name: qed_get_user_contract_state_tree_leaf_hash

Request Parameters:

{
  "checkpoint_id": 100,
  "user_id": 12345,
  "contract_id": 5,
  "height": 10,
  "leaf_id": 42
}
ParameterTypeDescription
checkpoint_idu64The checkpoint ID
user_idu64The user ID
contract_idu32The contract ID
heightu8The tree height
leaf_idu64The leaf ID

Response: See QHashOut


22. get_user_contract_state_tree_leaf_hash_f

Get user contract state tree leaf hash (Field parameters).

Method Name: qed_get_user_contract_state_tree_leaf_hash_f

Request Parameters:

{
  "checkpoint_id": "100",
  "user_id": "12345",
  "contract_id": "5",
  "height": 10,
  "leaf_id": "42"
}
ParameterTypeDescription
checkpoint_idF (Field)The checkpoint ID as a field element
user_idF (Field)The user ID as a field element
contract_idF (Field)The contract ID as a field element
heightu8The tree height
leaf_idF (Field)The leaf ID as a field element

Response: See QHashOut


23. get_user_contract_state_tree_merkle_proof

Get Merkle proof for user contract state tree (u64 parameters).

Method Name: qed_get_user_contract_state_tree_merkle_proof

Request Parameters:

{
  "checkpoint_id": 100,
  "user_id": 12345,
  "contract_id": 5,
  "height": 10,
  "leaf_id": 42
}
ParameterTypeDescription
checkpoint_idu64The checkpoint ID
user_idu64The user ID
contract_idu32The contract ID
heightu8The tree height
leaf_idu64The leaf ID

Response: See MerkleProofCore


24. get_user_contract_state_tree_merkle_proof_f

Get Merkle proof for user contract state tree (Field parameters).

Method Name: qed_get_user_contract_state_tree_merkle_proof_f

Request Parameters:

{
  "checkpoint_id": "100",
  "user_id": "12345",
  "contract_id": "5",
  "height": 10,
  "leaf_id": "42"
}
ParameterTypeDescription
checkpoint_idF (Field)The checkpoint ID as a field element
user_idF (Field)The user ID as a field element
contract_idF (Field)The contract ID as a field element
heightu8The tree height
leaf_idF (Field)The leaf ID as a field element

Response: See MerkleProofCore


User Contract Tree Operations

25. get_user_contract_tree_root

Get user contract tree root (u64 parameters).

Method Name: qed_get_user_contract_tree_root

Request Parameters:

{
  "checkpoint_id": 100,
  "user_id": 12345
}
ParameterTypeDescription
checkpoint_idu64The checkpoint ID
user_idu64The user ID

Response: See QHashOut


26. get_user_contract_tree_root_f

Get user contract tree root (Field parameters).

Method Name: qed_get_user_contract_tree_root_f

Request Parameters:

{
  "checkpoint_id": "100",
  "user_id": "12345"
}
ParameterTypeDescription
checkpoint_idF (Field)The checkpoint ID as a field element
user_idF (Field)The user ID as a field element

Response: See QHashOut


27. get_user_contract_tree_leaf_hash

Get user contract tree leaf hash (u64 parameters).

Method Name: qed_get_user_contract_tree_leaf_hash

Request Parameters:

{
  "checkpoint_id": 100,
  "user_id": 12345,
  "contract_id": 5
}
ParameterTypeDescription
checkpoint_idu64The checkpoint ID
user_idu64The user ID
contract_idu32The contract ID

Response: See QHashOut


28. get_user_contract_tree_leaf_hash_f

Get user contract tree leaf hash (Field parameters).

Method Name: qed_get_user_contract_tree_leaf_hash_f

Request Parameters:

{
  "checkpoint_id": "100",
  "user_id": "12345",
  "contract_id": "5"
}
ParameterTypeDescription
checkpoint_idF (Field)The checkpoint ID as a field element
user_idF (Field)The user ID as a field element
contract_idF (Field)The contract ID as a field element

Response: See QHashOut


29. get_user_contract_tree_merkle_proof

Get Merkle proof for user contract tree (u64 parameters).

Method Name: qed_get_user_contract_tree_merkle_proof

Request Parameters:

{
  "checkpoint_id": 100,
  "user_id": 12345,
  "contract_id": 5
}
ParameterTypeDescription
checkpoint_idu64The checkpoint ID
user_idu64The user ID
contract_idu32The contract ID

Response: See MerkleProofCore


30. get_user_contract_tree_merkle_proof_f

Get Merkle proof for user contract tree (Field parameters).

Method Name: qed_get_user_contract_tree_merkle_proof_f

Request Parameters:

{
  "checkpoint_id": "100",
  "user_id": "12345",
  "contract_id": "5"
}
ParameterTypeDescription
checkpoint_idF (Field)The checkpoint ID as a field element
user_idF (Field)The user ID as a field element
contract_idF (Field)The contract ID as a field element

Response: See MerkleProofCore


User Tree Operations

31. get_user_tree_root

Get user tree root at a specific checkpoint (u64 parameter).

Method Name: qed_get_user_tree_root

Request Parameters:

{
  "checkpoint_id": 100
}
ParameterTypeDescription
checkpoint_idu64The checkpoint ID

Response: See QHashOut


32. get_user_tree_root_f

Get user tree root at a specific checkpoint (Field parameter).

Method Name: qed_get_user_tree_root_f

Request Parameters:

{
  "checkpoint_id": "100"
}
ParameterTypeDescription
checkpoint_idF (Field)The checkpoint ID as a field element

Response: See QHashOut


33. get_user_tree_leaf_hash

Get user tree leaf hash (u64 parameters).

Method Name: qed_get_user_tree_leaf_hash

Request Parameters:

{
  "checkpoint_id": 100,
  "user_id": 12345
}
ParameterTypeDescription
checkpoint_idu64The checkpoint ID
user_idu64The user ID

Response: See QHashOut


34. get_user_tree_leaf_hash_f

Get user tree leaf hash (Field parameters).

Method Name: qed_get_user_tree_leaf_hash_f

Request Parameters:

{
  "checkpoint_id": "100",
  "user_id": "12345"
}
ParameterTypeDescription
checkpoint_idF (Field)The checkpoint ID as a field element
user_idF (Field)The user ID as a field element

Response: See QHashOut


35. get_user_bottom_tree_merkle_proof

Get Merkle proof for user bottom tree (u64 parameters).

Method Name: qed_get_user_bottom_tree_merkle_proof

Request Parameters:

{
  "root_level": 5,
  "checkpoint_id": 100,
  "user_id": 12345
}
ParameterTypeDescription
root_levelu8The root level of the tree
checkpoint_idu64The checkpoint ID
user_idu64The user ID

Response: See MerkleProofCore


36. get_user_bottom_tree_merkle_proof_f

Get Merkle proof for user bottom tree (Field parameters).

Method Name: qed_get_user_bottom_tree_merkle_proof_f

Request Parameters:

{
  "root_level": 5,
  "checkpoint_id": "100",
  "user_id": "12345"
}
ParameterTypeDescription
root_levelu8The root level of the tree
checkpoint_idF (Field)The checkpoint ID as a field element
user_idF (Field)The user ID as a field element

Response: See MerkleProofCore


37. get_user_sub_tree_merkle_proof

Get Merkle proof for user sub-tree (u64 parameters).

Method Name: qed_get_user_sub_tree_merkle_proof

Request Parameters:

{
  "checkpoint_id": 100,
  "root_level": 5,
  "leaf_level": 2,
  "leaf_index": 42
}
ParameterTypeDescription
checkpoint_idu64The checkpoint ID
root_levelu8The root level of the tree
leaf_levelu8The leaf level of the tree
leaf_indexu64The leaf index

Response: See MerkleProofCore


38. get_user_sub_tree_merkle_proof_f

Get Merkle proof for user sub-tree (Field parameters).

Method Name: qed_get_user_sub_tree_merkle_proof_f

Request Parameters:

{
  "checkpoint_id": "100",
  "root_level": 5,
  "leaf_level": 2,
  "leaf_index": "42"
}
ParameterTypeDescription
checkpoint_idF (Field)The checkpoint ID as a field element
root_levelu8The root level of the tree
leaf_levelu8The leaf level of the tree
leaf_indexF (Field)The leaf index as a field element

Response: See MerkleProofCore


39. get_user_tree_merkle_proof

Get Merkle proof for user tree (u64 parameters).

Method Name: qed_get_user_tree_merkle_proof

Request Parameters:

{
  "checkpoint_id": 100,
  "user_id": 12345
}
ParameterTypeDescription
checkpoint_idu64The checkpoint ID
user_idu64The user ID

Response: See MerkleProofCore

Example:

curl -X POST http://localhost:8545 \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "method": "qed_get_user_tree_merkle_proof",
    "params": [100, 12345],
    "id": 1
  }'

40. get_user_tree_merkle_proof_f

Get Merkle proof for user tree (Field parameters).

Method Name: qed_get_user_tree_merkle_proof_f

Request Parameters:

{
  "checkpoint_id": "100",
  "user_id": "12345"
}
ParameterTypeDescription
checkpoint_idF (Field)The checkpoint ID as a field element
user_idF (Field)The user ID as a field element

Response: See MerkleProofCore

Note: This method internally converts field parameters to u64 and calls get_user_tree_merkle_proof.


Batch Proof Generation

41. generate_batch_variable_height_reward_proofs

Generate batch variable height reward Merkle proofs for multiple job IDs.

Method Name: qed_generate_batch_variable_height_reward_proofs

Request Parameters:

{
  "checkpoint_id": 100,
  "job_ids": [
    {
      "topic": "GenerateStandardProof",
      "goal_id": 100,
      "slot_id": 5,
      "circuit_type": "GUTATwoEndCap",
      "group_id": 1,
      "sub_group_id": 0,
      "task_index": 0,
      "data_type": "InputWitness",
      "data_index": 0
    }
  ]
}
ParameterTypeDescription
checkpoint_idu64The checkpoint ID
job_idsVec<QProvingJobDataID>Array of proving job data IDs (see QProvingJobDataID)

Response:

{
  "result": [
    [
      {
        "top_siblings": [...],
        "sibling_branch": "0x...",
        "reward_leaf": "0x...",
        "proof_height": "5",
        "index": "42"
      },
      {
        "topic": "GenerateStandardProof",
        "goal_id": 100,
        ...
      }
    ]
  ]
}
FieldTypeDescription
resultVec<(VariableHeightRewardMerkleProof, QProvingJobDataID)>Array of tuples containing proofs and job IDs

Example:

curl -X POST http://localhost:8545 \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "method": "qed_generate_batch_variable_height_reward_proofs",
    "params": [100, [...]],
    "id": 1
  }'

GraphViz Export

42. get_graphviz

Get GraphViz representation of the Merkle tree at a specific checkpoint.

Method Name: qed_get_graphviz

Request Parameters:

{
  "checkpoint_id": 100
}
ParameterTypeDescription
checkpoint_idu64The checkpoint ID

Response:

{
  "result": "digraph G {\n  node1 -> node2;\n  ...\n}"
}
FieldTypeDescription
resultStringGraphViz DOT format string

Example:

curl -X POST http://localhost:8545 \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "method": "qed_get_graphviz",
    "params": [100],
    "id": 1
  }' | jq -r '.result' | dot -Tpng > tree.png

Data Structures

QHashOut

A hash output wrapper for Plonky2 field elements.

Structure:

#![allow(unused)]
fn main() {
pub struct QHashOut<F: Field>(pub HashOut<F>);
}

JSON Representation:

"0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"

Description:

  • Wraps a Plonky2 HashOut<F> containing 4 field elements
  • Serialized as a hexadecimal string (32 bytes)
  • Represents a 256-bit hash value

QEDL2BlockState

L2 block state information at a specific checkpoint.

Structure:

#![allow(unused)]
fn main() {
pub struct QEDL2BlockState {
    pub checkpoint_id: u64,
    pub next_add_withdrawal_id: u64,
    pub next_process_withdrawal_id: u64,
    pub next_deposit_id: u64,
    pub total_deposits_claimed_epoch: u64,
    pub next_user_id: u64,
    pub end_balance: u64,
    pub next_contract_id: u32,
}
}

Fields:

FieldTypeDescription
checkpoint_idu64The checkpoint identifier
next_add_withdrawal_idu64Next withdrawal ID to be added
next_process_withdrawal_idu64Next withdrawal ID to be processed
next_deposit_idu64Next deposit ID
total_deposits_claimed_epochu64Total deposits claimed in current epoch
next_user_idu64Next user ID to be assigned
end_balanceu64Ending balance at this checkpoint
next_contract_idu32Next contract ID to be assigned

Example:

{
  "checkpoint_id": 100,
  "next_add_withdrawal_id": 50,
  "next_process_withdrawal_id": 45,
  "next_deposit_id": 200,
  "total_deposits_claimed_epoch": 180,
  "next_user_id": 1000,
  "end_balance": 5000000,
  "next_contract_id": 25
}

QEDCheckpointLeaf

Checkpoint leaf data containing global chain root and statistics.

Structure:

#![allow(unused)]
fn main() {
pub struct QEDCheckpointLeaf<F: RichField> {
    pub global_chain_root: QHashOut<F>,
    pub stats: QEDCheckpointLeafStats<F>,
}
}

Fields:

FieldTypeDescription
global_chain_rootQHashOut<F>Global chain state root hash
statsQEDCheckpointLeafStats<F>Checkpoint statistics

QEDCheckpointLeafStats Structure:

#![allow(unused)]
fn main() {
pub struct QEDCheckpointLeafStats<F: RichField> {
    pub fees_collected: F,
    pub user_ops_processed: F,
    pub total_transactions: F,
    pub slots_modified: F,
    pub pm_jobs_completed: PMJobsCompletedStats<F>,
    pub block_time: F,
    pub random_seed: QHashOut<F>,
    pub pm_rewards_commitment: PMRewardCommitment<F>,
    pub da_challenges_claimed: [F; DA_CHALLENGE_WINDOW],
}
}

Example:

{
  "global_chain_root": "0x...",
  "stats": {
    "fees_collected": "1000",
    "user_ops_processed": "50",
    "total_transactions": "75",
    "slots_modified": "30",
    "pm_jobs_completed": {...},
    "block_time": "1234567890",
    "random_seed": "0x...",
    "pm_rewards_commitment": {...},
    "da_challenges_claimed": [...]
  }
}

QEDCheckpointGlobalStateRoots

Global state roots at a specific checkpoint.

Structure:

#![allow(unused)]
fn main() {
pub struct QEDCheckpointGlobalStateRoots<F: RichField> {
    pub contract_tree_root: QHashOut<F>,
    pub deposit_tree_root: QHashOut<F>,
    pub user_tree_root: QHashOut<F>,
    pub withdrawal_tree_root: QHashOut<F>,
    pub user_registration_tree_root: QHashOut<F>,
}
}

Fields:

FieldTypeDescription
contract_tree_rootQHashOut<F>Root of the contract tree
deposit_tree_rootQHashOut<F>Root of the deposit tree
user_tree_rootQHashOut<F>Root of the user tree
withdrawal_tree_rootQHashOut<F>Root of the withdrawal tree
user_registration_tree_rootQHashOut<F>Root of the user registration tree

Example:

{
  "contract_tree_root": "0x1234...",
  "deposit_tree_root": "0x5678...",
  "user_tree_root": "0x9abc...",
  "withdrawal_tree_root": "0xdef0...",
  "user_registration_tree_root": "0x1234..."
}

QEDUserLeaf

User leaf data containing user state information.

Structure:

#![allow(unused)]
fn main() {
pub struct QEDUserLeaf<F: RichField> {
    pub public_key: QHashOut<F>,
    pub user_state_tree_root: QHashOut<F>,
    pub balance: F,
    pub nonce: F,
    pub last_checkpoint_id: F,
    pub event_index: F,
    pub user_id: F,
}
}

Fields:

FieldTypeDescription
public_keyQHashOut<F>User's public key hash
user_state_tree_rootQHashOut<F>Root of user's state tree
balanceFUser's balance
nonceFUser's transaction nonce
last_checkpoint_idFLast checkpoint ID where user was updated
event_indexFEvent index for this user
user_idFUser identifier

Example:

{
  "public_key": "0x1234...",
  "user_state_tree_root": "0x5678...",
  "balance": "1000000",
  "nonce": "42",
  "last_checkpoint_id": "100",
  "event_index": "15",
  "user_id": "12345"
}

MerkleProofCore

Generic Merkle proof structure.

Structure:

#![allow(unused)]
fn main() {
pub struct MerkleProofCore<Hash: PartialEq + Copy> {
    pub root: Hash,
    pub value: Hash,
    pub index: u64,
    pub siblings: Vec<Hash>,
}
}

Fields:

FieldTypeDescription
rootHashMerkle tree root hash
valueHashLeaf value being proven
indexu64Leaf index in the tree
siblingsVec<Hash>Sibling hashes along the path

Example:

{
  "root": "0x1234...",
  "value": "0x5678...",
  "index": 42,
  "siblings": [
    "0x9abc...",
    "0xdef0...",
    "0x1234..."
  ]
}

Verification: The proof can be verified by hashing the value with siblings along the path according to the index bits.


SubmitUserEndCapNonProofInput

Input data for submitting user end cap (without proof).

Structure:

#![allow(unused)]
fn main() {
pub struct SubmitUserEndCapNonProofInput<F: RichField> {
    pub core: SubmitUserEndCapNonProofCoreInput<F>,
    pub contract_state_updates: Vec<QEDContractStateUpdateHistory<F>>,
}

pub struct SubmitUserEndCapNonProofCoreInput<F: RichField> {
    pub checkpoint_id: F,
    pub stats: GUTAStats<F>,
    pub state_transition: UPSEndCapResultCompact<F>,
    pub new_user_leaf: QEDUserLeaf<F>,
}
}

Fields:

FieldTypeDescription
coreSubmitUserEndCapNonProofCoreInput<F>Core input data
contract_state_updatesVec<QEDContractStateUpdateHistory<F>>Contract state update history

Core Fields:

FieldTypeDescription
checkpoint_idFCheckpoint ID
statsGUTAStats<F>GUTA statistics
state_transitionUPSEndCapResultCompact<F>State transition result
new_user_leafQEDUserLeaf<F>New user leaf data

QProvingJobDataID

Proving job data identifier.

Structure:

#![allow(unused)]
fn main() {
pub struct QProvingJobDataID {
    pub topic: QJobTopic,
    pub goal_id: u64,
    pub slot_id: u64,
    pub circuit_type: ProvingJobCircuitType,
    pub group_id: u32,
    pub sub_group_id: u32,
    pub task_index: u32,
    pub data_type: ProvingJobDataType,
    pub data_index: u8,
}
}

Fields:

FieldTypeDescription
topicQJobTopicJob topic (e.g., GenerateStandardProof)
goal_idu64Goal identifier (usually checkpoint ID)
slot_idu64Slot identifier
circuit_typeProvingJobCircuitTypeType of circuit (e.g., GUTATwoEndCap)
group_idu32Group identifier
sub_group_idu32Sub-group identifier
task_indexu32Task index within the group
data_typeProvingJobDataTypeData type (e.g., InputWitness)
data_indexu8Data index

Serialization: Serialized as a 32-byte array.

Example:

{
  "topic": "GenerateStandardProof",
  "goal_id": 100,
  "slot_id": 5,
  "circuit_type": "GUTATwoEndCap",
  "group_id": 1,
  "sub_group_id": 0,
  "task_index": 0,
  "data_type": "InputWitness",
  "data_index": 0
}

VariableHeightRewardMerkleProof

Variable height Merkle proof for reward distribution.

Structure:

#![allow(unused)]
fn main() {
pub struct VariableHeightRewardMerkleProof {
    pub top_siblings: Vec<VariableHeightProofSibling>,
    pub sibling_branch: QHashOut<F>,
    pub reward_leaf: QHashOut<F>,
    pub proof_height: F,
    pub index: F,
}

pub struct VariableHeightProofSibling {
    pub sibling_branch: QHashOut<F>,
    pub sibling_reward_leaf: QHashOut<F>,
}
}

Fields:

FieldTypeDescription
top_siblingsVec<VariableHeightProofSibling>Siblings at each level
sibling_branchQHashOut<F>Sibling branch hash
reward_leafQHashOut<F>Reward leaf hash
proof_heightFHeight of the proof
indexFIndex in the tree

Example:

{
  "top_siblings": [
    {
      "sibling_branch": "0x1234...",
      "sibling_reward_leaf": "0x5678..."
    }
  ],
  "sibling_branch": "0x9abc...",
  "reward_leaf": "0xdef0...",
  "proof_height": "5",
  "index": "42"
}

Field Type Notes

Throughout this API, F represents a field element type (typically GoldilocksField).

Field Element Conversion:

  • Methods with _f suffix accept field elements as strings (e.g., "12345")
  • Methods without _f suffix accept native types (e.g., 12345)
  • Field elements are internally represented as u64 values in the Goldilocks field

Best Practices:

  • Use u64 variants for better performance when possible
  • Use Field variants when working with circuit inputs/outputs
  • Always validate checkpoint_id exists before querying
  • Handle RPC errors gracefully (missing data, invalid parameters)

Error Handling

All RPC methods return RpcResult<T> which can contain errors in the following format:

{
  "jsonrpc": "2.0",
  "error": {
    "code": -32000,
    "message": "Error description"
  },
  "id": 1
}

Common Error Codes:

  • -32000: Server error (checkpoint not found, data unavailable)
  • -32602: Invalid parameters
  • -32603: Internal error

Usage Examples

Complete Workflow Example

# 1. Check if user belongs to realm
curl -X POST http://localhost:8545 \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "method": "qed_check_user_id_in_realm",
    "params": [12345],
    "id": 1
  }'

# 2. Get latest L2 block state
curl -X POST http://localhost:8545 \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "method": "qed_get_latest_l2_block_state",
    "params": [],
    "id": 2
  }'

# 3. Get user leaf data at checkpoint
curl -X POST http://localhost:8545 \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "method": "qed_get_user_leaf_data",
    "params": [100, 12345],
    "id": 3
  }'

# 4. Get Merkle proof for user
curl -X POST http://localhost:8545 \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "method": "qed_get_user_tree_merkle_proof",
    "params": [100, 12345],
    "id": 4
  }'

Method Summary

#Method NameParametersReturnsDescription
1check_user_id_in_realmuser_id: u64boolCheck user belongs to realm
2submit_user_end_capinput, proofStringSubmit end cap proof
3-4get_checkpoint_leaf_data[_f]checkpoint_idQEDCheckpointLeafGet checkpoint leaf
5-7get_[latest_]l2_block_state[_f][checkpoint_id]QEDL2BlockStateGet L2 block state
8get_user_registration_tree_rootcheckpoint_idQHashOutGet registration tree root
9-11get_[latest_]checkpoint_tree_root[_f][checkpoint_id]QHashOutGet checkpoint tree root
12-15get_checkpoint_tree_[leaf_hash\|merkle_proof][_f]checkpoint_id, leaf_idQHashOut\|ProofCheckpoint tree ops
16get_checkpoint_global_state_rootscheckpoint_idGlobalStateRootsGet global state roots
17-18get_user_leaf_data[_f]checkpoint_id, user_idQEDUserLeafGet user leaf data
19-24get_user_contract_state_tree_*[_f]VariousQHashOut\|ProofContract state tree ops
25-30get_user_contract_tree_*[_f]VariousQHashOut\|ProofUser contract tree ops
31-40get_user_tree_*[_f]VariousQHashOut\|ProofUser tree operations
41generate_batch_variable_height_reward_proofscheckpoint_id, job_idsVec<(Proof, JobID)>Batch reward proofs
42get_graphvizcheckpoint_idStringGet tree visualization

Document Version: 1.0
Last Updated: 2025-10-24
Total RPC Methods: 42