You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs-v2/guides/USE_RC_BLOCK_SPEC.md
+51-3Lines changed: 51 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,6 +24,15 @@ The `useRcBlock` parameter is a boolean parameter that works in conjunction with
24
24
25
25
**Block Finalization Note**: The `useRcBlock` parameter does not make any assumptions about whether the block you pass is finalized or a best block. It is recommended to ensure the block you are passing is finalized if block finalization is important for your use case.
26
26
27
+
### useRcBlockFormat Parameter
28
+
The `useRcBlockFormat` parameter controls the response format when using `useRcBlock=true`. This parameter is only valid when `useRcBlock=true` is specified.
29
+
30
+
**Values:**
31
+
-`array` (default): Returns the standard array format with enhanced metadata
32
+
-`object`: Wraps the response in an object containing relay chain block info and the parachain data array
33
+
34
+
**Validation**: Using `useRcBlockFormat` without `useRcBlock=true` will return a `400 Bad Request` error.
35
+
27
36
## Implementation: useRcBlock Query Parameter
28
37
29
38
### Core Functionality
@@ -40,6 +49,10 @@ GET /pallets/staking/progress?at=1000000&useRcBlock=true
40
49
GET /accounts/{accountId}/balance-info?at=0x123abc&useRcBlock=true
41
50
GET /blocks/head?useRcBlock=true
42
51
GET /blocks/12345?at=12345&useRcBlock=true
52
+
53
+
# With useRcBlockFormat=object for wrapped response format
54
+
GET /pallets/staking/progress?at=1000000&useRcBlock=true&useRcBlockFormat=object
55
+
GET /accounts/{accountId}/balance-info?at=0x123abc&useRcBlock=true&useRcBlockFormat=object
43
56
```
44
57
45
58
### Response Format Changes
@@ -52,7 +65,7 @@ Returns single response object (unchanged):
52
65
}
53
66
```
54
67
55
-
**With useRcBlock=true:**
68
+
**With useRcBlock=true (default array format):**
56
69
Returns array format with additional metadata:
57
70
```json
58
71
[{
@@ -65,6 +78,38 @@ Returns array format with additional metadata:
65
78
66
79
Or empty array `[]` if no corresponding Asset Hub block exists.
67
80
81
+
**With useRcBlock=true&useRcBlockFormat=object:**
82
+
Returns object format wrapping the data with relay chain block info:
83
+
```json
84
+
{
85
+
"rcBlock": {
86
+
"hash": "0x1234567890abcdef...",
87
+
"parentHash": "0xabcdef1234567890...",
88
+
"number": "1000000"
89
+
},
90
+
"parachainDataPerBlock": [
91
+
{
92
+
// ... existing endpoint response data
93
+
"rcBlockHash": "0x1234567890abcdef...",
94
+
"rcBlockNumber": "1000000",
95
+
"ahTimestamp": "1642694400"
96
+
}
97
+
]
98
+
}
99
+
```
100
+
101
+
Or with empty `parachainDataPerBlock` array if no corresponding Asset Hub block exists:
102
+
```json
103
+
{
104
+
"rcBlock": {
105
+
"hash": "0x1234567890abcdef...",
106
+
"parentHash": "0xabcdef1234567890...",
107
+
"number": "1000000"
108
+
},
109
+
"parachainDataPerBlock": []
110
+
}
111
+
```
112
+
68
113
## Supported Endpoints
69
114
70
115
### Block Endpoints Supporting useRcBlock:
@@ -90,7 +135,8 @@ When `useRcBlock=true` is used, responses include additional context fields:
90
135
-`rcBlockHash`: The relay chain block hash
91
136
-`rcBlockNumber`: The relay chain block number
92
137
-`ahTimestamp`: The Asset Hub block timestamp
93
-
- Array format prepares for future elastic scaling scenarios
138
+
- Array format (default) prepares for future elastic scaling scenarios
139
+
- Object format (`useRcBlockFormat=object`) provides relay chain block metadata wrapper with `rcBlock` info (hash, parentHash, number) and `parachainDataPerBlock` array
94
140
95
141
### Backward Compatibility
96
142
- Defaults to `false`, maintaining existing functionality when not specified
@@ -104,9 +150,11 @@ When `useRcBlock=true` is used, responses include additional context fields:
104
150
105
151
### Validation Logic
106
152
The `validateUseRcBlock` middleware ensures:
107
-
1.**Boolean validation**: Must be "true" or "false" string
153
+
1.**Boolean validation**: `useRcBlock` must be "true" or "false" string
108
154
2.**Asset Hub requirement**: Only works when connected to Asset Hub
109
155
3.**Relay chain availability**: Requires relay chain API configuration via `SAS_SUBSTRATE_MULTI_CHAIN_URL`
156
+
4.**useRcBlockFormat dependency**: `useRcBlockFormat` requires `useRcBlock=true` to be specified
157
+
5.**useRcBlockFormat values**: Must be either "array" or "object" string
0 commit comments