ckb-rpc 0.43.2

CKB RPC server.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
# CKB JSON-RPC Protocols

<!--**NOTE:** This file is auto-generated from code comments.-->

The RPC interface shares the version of the node version, which is returned in `local_node_info`. The interface is fully compatible between patch versions, for example, a client for 0.25.0 should work with 0.25.x for any x.

Allowing arbitrary machines to access the JSON-RPC port (using the `rpc.listen_address` configuration option) is **dangerous and strongly discouraged**. Please strictly limit the access to only trusted machines.

CKB JSON-RPC only supports HTTP now. If you need SSL, please set up a proxy via Nginx or other HTTP servers.

Subscriptions require a full duplex connection. CKB offers such connections in the form of TCP (enable with `rpc.tcp_listen_address` configuration option) and WebSockets (enable with `rpc.ws_listen_address`).

## JSONRPC Deprecation Process

A CKB RPC method is deprecated in three steps.

First, the method is marked as deprecated in the CKB release notes and RPC document. However, the RPC method is still available. The RPC document will have the suggestion of alternative solutions.

The CKB dev team will disable any deprecated RPC methods starting from the next minor version release. Users can enable the deprecated methods via the config file option rpc.enable_deprecated_rpc.

Once a deprecated method is disabled, the CKB dev team will remove it in a future minor version release.

For example, a method is marked as deprecated in 0.35.0, it can be disabled in 0.36.0 and removed in 0.37.0. The minor versions are released monthly, so there's at least a two-month buffer for a deprecated RPC method.

## Minimum Supported Rust Version policy (MSRV)

The crate `ckb-rpc`'s minimum supported rustc version is 1.51.0.


## Table of Contents

* [RPC Methods](#rpc-methods)
    * [Module Alert](#module-alert)
        * [Method `send_alert`](#method-send_alert)
    * [Module Chain](#module-chain)
        * [Method `get_block`](#method-get_block)
        * [Method `get_block_by_number`](#method-get_block_by_number)
        * [Method `get_header`](#method-get_header)
        * [Method `get_header_by_number`](#method-get_header_by_number)
        * [Method `get_transaction`](#method-get_transaction)
        * [Method `get_block_hash`](#method-get_block_hash)
        * [Method `get_tip_header`](#method-get_tip_header)
        * [Method `get_live_cell`](#method-get_live_cell)
        * [Method `get_tip_block_number`](#method-get_tip_block_number)
        * [Method `get_current_epoch`](#method-get_current_epoch)
        * [Method `get_epoch_by_number`](#method-get_epoch_by_number)
        * [Method `get_block_economic_state`](#method-get_block_economic_state)
        * [Method `get_transaction_proof`](#method-get_transaction_proof)
        * [Method `verify_transaction_proof`](#method-verify_transaction_proof)
        * [Method `get_fork_block`](#method-get_fork_block)
        * [Method `get_consensus`](#method-get_consensus)
        * [Method `get_block_median_time`](#method-get_block_median_time)
    * [Module Experiment](#module-experiment)
        * [Method `dry_run_transaction`](#method-dry_run_transaction)
        * [Method `calculate_dao_maximum_withdraw`](#method-calculate_dao_maximum_withdraw)
    * [Module Miner](#module-miner)
        * [Method `get_block_template`](#method-get_block_template)
        * [Method `submit_block`](#method-submit_block)
    * [Module Net](#module-net)
        * [Method `local_node_info`](#method-local_node_info)
        * [Method `get_peers`](#method-get_peers)
        * [Method `get_banned_addresses`](#method-get_banned_addresses)
        * [Method `clear_banned_addresses`](#method-clear_banned_addresses)
        * [Method `set_ban`](#method-set_ban)
        * [Method `sync_state`](#method-sync_state)
        * [Method `set_network_active`](#method-set_network_active)
        * [Method `add_node`](#method-add_node)
        * [Method `remove_node`](#method-remove_node)
        * [Method `ping_peers`](#method-ping_peers)
    * [Module Pool](#module-pool)
        * [Method `send_transaction`](#method-send_transaction)
        * [Method `tx_pool_info`](#method-tx_pool_info)
        * [Method `clear_tx_pool`](#method-clear_tx_pool)
        * [Method `get_raw_tx_pool`](#method-get_raw_tx_pool)
    * [Module Stats](#module-stats)
        * [Method `get_blockchain_info`](#method-get_blockchain_info)
    * [Module Subscription](#module-subscription)
        * [Method `subscribe`](#method-subscribe)
        * [Method `unsubscribe`](#method-unsubscribe)
* [RPC Errors](#rpc-errors)
* [RPC Types](#rpc-types)
    * [Type `Alert`](#type-alert)
    * [Type `AlertId`](#type-alertid)
    * [Type `AlertMessage`](#type-alertmessage)
    * [Type `AlertPriority`](#type-alertpriority)
    * [Type `BannedAddr`](#type-bannedaddr)
    * [Type `Block`](#type-block)
    * [Type `BlockEconomicState`](#type-blockeconomicstate)
    * [Type `BlockIssuance`](#type-blockissuance)
    * [Type `BlockNumber`](#type-blocknumber)
    * [Type `BlockTemplate`](#type-blocktemplate)
    * [Type `BlockView`](#type-blockview)
    * [Type `Byte32`](#type-byte32)
    * [Type `Capacity`](#type-capacity)
    * [Type `CellData`](#type-celldata)
    * [Type `CellDep`](#type-celldep)
    * [Type `CellInfo`](#type-cellinfo)
    * [Type `CellInput`](#type-cellinput)
    * [Type `CellOutput`](#type-celloutput)
    * [Type `CellWithStatus`](#type-cellwithstatus)
    * [Type `CellbaseTemplate`](#type-cellbasetemplate)
    * [Type `ChainInfo`](#type-chaininfo)
    * [Type `Consensus`](#type-consensus)
    * [Type `Cycle`](#type-cycle)
    * [Type `DepType`](#type-deptype)
    * [Type `DryRunResult`](#type-dryrunresult)
    * [Type `EpochNumber`](#type-epochnumber)
    * [Type `EpochNumberWithFraction`](#type-epochnumberwithfraction)
    * [Type `EpochView`](#type-epochview)
    * [Type `H256`](#type-h256)
    * [Type `Header`](#type-header)
    * [Type `HeaderView`](#type-headerview)
    * [Type `JsonBytes`](#type-jsonbytes)
    * [Type `LocalNode`](#type-localnode)
    * [Type `LocalNodeProtocol`](#type-localnodeprotocol)
    * [Type `MerkleProof`](#type-merkleproof)
    * [Type `MinerReward`](#type-minerreward)
    * [Type `NodeAddress`](#type-nodeaddress)
    * [Type `OutPoint`](#type-outpoint)
    * [Type `OutputsValidator`](#type-outputsvalidator)
    * [Type `PeerSyncState`](#type-peersyncstate)
    * [Type `PoolTransactionEntry`](#type-pooltransactionentry)
    * [Type `PoolTransactionReject`](#type-pooltransactionreject)
    * [Type `ProposalShortId`](#type-proposalshortid)
    * [Type `ProposalWindow`](#type-proposalwindow)
    * [Type `RationalU256`](#type-rationalu256)
    * [Type `RawTxPool`](#type-rawtxpool)
    * [Type `RemoteNode`](#type-remotenode)
    * [Type `RemoteNodeProtocol`](#type-remotenodeprotocol)
    * [Type `Script`](#type-script)
    * [Type `ScriptHashType`](#type-scripthashtype)
    * [Type `SerializedBlock`](#type-serializedblock)
    * [Type `SerializedHeader`](#type-serializedheader)
    * [Type `Status`](#type-status)
    * [Type `SyncState`](#type-syncstate)
    * [Type `Timestamp`](#type-timestamp)
    * [Type `Transaction`](#type-transaction)
    * [Type `TransactionProof`](#type-transactionproof)
    * [Type `TransactionTemplate`](#type-transactiontemplate)
    * [Type `TransactionView`](#type-transactionview)
    * [Type `TransactionWithStatus`](#type-transactionwithstatus)
    * [Type `TxPoolIds`](#type-txpoolids)
    * [Type `TxPoolInfo`](#type-txpoolinfo)
    * [Type `TxPoolVerbosity`](#type-txpoolverbosity)
    * [Type `TxStatus`](#type-txstatus)
    * [Type `TxVerbosity`](#type-txverbosity)
    * [Type `U256`](#type-u256)
    * [Type `Uint128`](#type-uint128)
    * [Type `Uint32`](#type-uint32)
    * [Type `Uint64`](#type-uint64)
    * [Type `UncleBlock`](#type-uncleblock)
    * [Type `UncleBlockView`](#type-uncleblockview)
    * [Type `UncleTemplate`](#type-uncletemplate)
    * [Type `Version`](#type-version)

## RPC Methods

### Module Alert

RPC Module Alert for network alerts.

An alert is a message about critical problems to be broadcast to all nodes via the p2p network.

The alerts must be signed by 2-of-4 signatures, where the public keys are hard-coded in the source code and belong to early CKB developers.

#### Method `send_alert`
* `send_alert(alert)`
    * `alert`: [`Alert`](#type-alert)
* result: `null`

Sends an alert.

This RPC returns `null` on success.

##### Errors

*   [`AlertFailedToVerifySignatures (-1000)`](#error-alertfailedtoverifysignatures) - Some signatures in the request are invalid.

*   [`P2PFailedToBroadcast (-101)`](#error-p2pfailedtobroadcast) - Alert is saved locally but has failed to broadcast to the P2P network.

*   `InvalidParams (-32602)` - The time specified in `alert.notice_until` must be in the future.

##### Examples

Request

```
{
  "jsonrpc": "2.0",
  "method": "send_alert",
  "params": [
    {
      "id": "0x1",
      "cancel": "0x0",
      "priority": "0x1",
      "message": "An example alert message!",
      "notice_until": "0x24bcca57c00",
      "signatures": [
        "0xbd07059aa9a3d057da294c2c4d96fa1e67eeb089837c87b523f124239e18e9fc7d11bb95b720478f7f937d073517d0e4eb9a91d12da5c88a05f750362f4c214dd0",
        "0x0242ef40bb64fe3189284de91f981b17f4d740c5e24a3fc9b70059db6aa1d198a2e76da4f84ab37549880d116860976e0cf81cd039563c452412076ebffa2e4453"
      ]
    }
  ],
  "id": 42
}
```

Response

```
{
  "error": {
    "code": -1000,
    "data": "SigNotEnough",
    "message":"AlertFailedToVerifySignatures: The count of sigs less than threshold."
  },
  "jsonrpc": "2.0",
  "result": null,
  "id": 42
}
```

### Module Chain

RPC Module Chain for methods related to the canonical chain.

This module queries information about the canonical chain.

#### Canonical Chain

A canonical chain is the one with the most accumulated work. The accumulated work is the sum of difficulties of all the blocks in the chain.

#### Chain Reorganization

Chain Reorganization happens when CKB found a chain that has accumulated more work than the canonical chain. The reorganization reverts the blocks in the current canonical chain if needed, and switch the canonical chain to that better chain.

#### Live Cell

A cell is live if

*   it is found as an output in any transaction in the [canonical chain](#canonical-chain), and

*   it is not found as an input in any transaction in the canonical chain.

#### Method `get_block`
* `get_block(block_hash, verbosity)`
    * `block_hash`: [`H256`](#type-h256)
    * `verbosity`: [`Uint32`](#type-uint32) `|` `null`
* result: [`BlockView`](#type-blockview) `|` [`SerializedBlock`](#type-serializedblock) `|` `null`

Returns the information about a block by hash.

##### Params

*   `block_hash` - the block hash.

*   `verbosity` - result format which allows 0 and 2. (**Optional**, the default is 2.)

##### Returns

The RPC returns a block or null. When the RPC returns a block, the block hash must equal to the parameter `block_hash`.

If the block is in the [canonical chain](#canonical-chain), the RPC must return the block information. Otherwise, the behavior is undefined. The RPC may return blocks found in local storage or simply returns null for all blocks that are not in the canonical chain. And because of [chain reorganization](#chain-reorganization), for the same `block_hash`, the RPC may sometimes return null and sometimes return the block.

When `verbosity` is 2, it returns a JSON object as the `result`. See `BlockView` for the schema.

When `verbosity` is 0, it returns a 0x-prefixed hex string as the `result`. The string encodes the block serialized by molecule using schema `table Block`.

##### Examples

Request

```
{
  "id": 42,
  "jsonrpc": "2.0",
  "method": "get_block",
  "params": [
    "0xa5f5c85987a15de25661e5a214f2c1449cd803f071acc7999820f25246471f40"
  ]
}
```

Response

```
{
  "id": 42,
  "jsonrpc": "2.0",
  "result": {
    "header": {
      "compact_target": "0x1e083126",
      "dao": "0xb5a3e047474401001bc476b9ee573000c0c387962a38000000febffacf030000",
      "epoch": "0x7080018000001",
      "hash": "0xa5f5c85987a15de25661e5a214f2c1449cd803f071acc7999820f25246471f40",
      "nonce": "0x0",
      "number": "0x400",
      "parent_hash": "0xae003585fa15309b30b31aed3dcf385e9472c3c3e93746a6c4540629a6a1ed2d",
      "proposals_hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
      "timestamp": "0x5cd2b117",
      "transactions_root": "0xc47d5b78b3c4c4c853e2a32810818940d0ee403423bea9ec7b8e566d9595206c",
      "uncles_hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
      "version": "0x0"
    },
    "proposals": [],
    "transactions": [
      {
        "cell_deps": [],
        "hash": "0x365698b50ca0da75dca2c87f9e7b563811d3b5813736b8cc62cc3b106faceb17",
        "header_deps": [],
        "inputs": [
          {
            "previous_output": {
              "index": "0xffffffff",
              "tx_hash": "0x0000000000000000000000000000000000000000000000000000000000000000"
            },
            "since": "0x400"
          }
        ],
        "outputs": [
          {
            "capacity": "0x18e64b61cf",
            "lock": {
              "args": "0x",
              "code_hash": "0x28e83a1277d48add8e72fadaa9248559e1b632bab2bd60b27955ebc4c03800a5",
              "hash_type": "data"
            },
            "type": null
          }
        ],
        "outputs_data": [
          "0x"
        ],
        "version": "0x0",
        "witnesses": [
          "0x450000000c000000410000003500000010000000300000003100000028e83a1277d48add8e72fadaa9248559e1b632bab2bd60b27955ebc4c03800a5000000000000000000"
        ]
      }
    ],
    "uncles": []
  }
}
```

The response looks like below when `verbosity` is 0.

```
{
  "id": 42,
  "jsonrpc": "2.0",
  "result": "0x..."
}
```

#### Method `get_block_by_number`
* `get_block_by_number(block_number, verbosity)`
    * `block_number`: [`BlockNumber`](#type-blocknumber)
    * `verbosity`: [`Uint32`](#type-uint32) `|` `null`
* result: [`BlockView`](#type-blockview) `|` [`SerializedBlock`](#type-serializedblock) `|` `null`

Returns the block in the [canonical chain](#canonical-chain) with the specific block number.

##### Params

*   `block_number` - the block number.

*   `verbosity` - result format which allows 0 and 2. (**Optional**, the default is 2.)

##### Returns

The RPC returns the block when `block_number` is less than or equal to the tip block number returned by [`get_tip_block_number`](#method-get_tip_block_number) and returns null otherwise.

Because of [chain reorganization](#chain-reorganization), the PRC may return null or even different blocks in different invocations with the same `block_number`.

When `verbosity` is 2, it returns a JSON object as the `result`. See `BlockView` for the schema.

When `verbosity` is 0, it returns a 0x-prefixed hex string as the `result`. The string encodes the block serialized by molecule using schema `table Block`.

##### Errors

*   [`ChainIndexIsInconsistent (-201)`](#error-chainindexisinconsistent) - The index is inconsistent. It says a block hash is in the main chain, but cannot read it from the database.

*   [`DatabaseIsCorrupt (-202)`](#error-databaseiscorrupt) - The data read from database is dirty. Please report it as a bug.

##### Examples

Request

```
{
  "id": 42,
  "jsonrpc": "2.0",
  "method": "get_block_by_number",
  "params": [
    "0x400"
  ]
}
```

Response

```
{
  "id": 42,
  "jsonrpc": "2.0",
  "result": {
    "header": {
      "compact_target": "0x1e083126",
      "dao": "0xb5a3e047474401001bc476b9ee573000c0c387962a38000000febffacf030000",
      "epoch": "0x7080018000001",
      "hash": "0xa5f5c85987a15de25661e5a214f2c1449cd803f071acc7999820f25246471f40",
      "nonce": "0x0",
      "number": "0x400",
      "parent_hash": "0xae003585fa15309b30b31aed3dcf385e9472c3c3e93746a6c4540629a6a1ed2d",
      "proposals_hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
      "timestamp": "0x5cd2b117",
      "transactions_root": "0xc47d5b78b3c4c4c853e2a32810818940d0ee403423bea9ec7b8e566d9595206c",
      "uncles_hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
      "version": "0x0"
    },
    "proposals": [],
    "transactions": [
      {
        "cell_deps": [],
        "hash": "0x365698b50ca0da75dca2c87f9e7b563811d3b5813736b8cc62cc3b106faceb17",
        "header_deps": [],
        "inputs": [
          {
            "previous_output": {
              "index": "0xffffffff",
              "tx_hash": "0x0000000000000000000000000000000000000000000000000000000000000000"
            },
            "since": "0x400"
          }
        ],
        "outputs": [
          {
            "capacity": "0x18e64b61cf",
            "lock": {
              "args": "0x",
              "code_hash": "0x28e83a1277d48add8e72fadaa9248559e1b632bab2bd60b27955ebc4c03800a5",
              "hash_type": "data"
            },
            "type": null
          }
        ],
        "outputs_data": [
          "0x"
        ],
        "version": "0x0",
        "witnesses": [
          "0x450000000c000000410000003500000010000000300000003100000028e83a1277d48add8e72fadaa9248559e1b632bab2bd60b27955ebc4c03800a5000000000000000000"
        ]
      }
    ],
    "uncles": []
  }
}
```

The response looks like below when `verbosity` is 0.

```
{
  "id": 42,
  "jsonrpc": "2.0",
  "result": "0x..."
}
```

#### Method `get_header`
* `get_header(block_hash, verbosity)`
    * `block_hash`: [`H256`](#type-h256)
    * `verbosity`: [`Uint32`](#type-uint32) `|` `null`
* result: [`HeaderView`](#type-headerview) `|` [`SerializedHeader`](#type-serializedheader) `|` `null`

Returns the information about a block header by hash.

##### Params

*   `block_hash` - the block hash.

*   `verbosity` - result format which allows 0 and 1. (**Optional**, the default is 1.)

##### Returns

The RPC returns a header or null. When the RPC returns a header, the block hash must equal to the parameter `block_hash`.

If the block is in the [canonical chain](#canonical-chain), the RPC must return the header information. Otherwise, the behavior is undefined. The RPC may return blocks found in local storage or simply returns null for all blocks that are not in the canonical chain. And because of [chain reorganization](#chain-reorganization), for the same `block_hash`, the RPC may sometimes return null and sometimes return the block header.

When `verbosity` is 1, it returns a JSON object as the `result`. See `HeaderView` for the schema.

When `verbosity` is 0, it returns a 0x-prefixed hex string as the `result`. The string encodes the block header serialized by molecule using schema `table Header`.

##### Examples

Request

```
{
  "id": 42,
  "jsonrpc": "2.0",
  "method": "get_header",
  "params": [
    "0xa5f5c85987a15de25661e5a214f2c1449cd803f071acc7999820f25246471f40"
  ]
}
```

Response

```
{
  "id": 42,
  "jsonrpc": "2.0",
  "result": {
    "compact_target": "0x1e083126",
    "dao": "0xb5a3e047474401001bc476b9ee573000c0c387962a38000000febffacf030000",
    "epoch": "0x7080018000001",
    "hash": "0xa5f5c85987a15de25661e5a214f2c1449cd803f071acc7999820f25246471f40",
    "nonce": "0x0",
    "number": "0x400",
    "parent_hash": "0xae003585fa15309b30b31aed3dcf385e9472c3c3e93746a6c4540629a6a1ed2d",
    "proposals_hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "timestamp": "0x5cd2b117",
    "transactions_root": "0xc47d5b78b3c4c4c853e2a32810818940d0ee403423bea9ec7b8e566d9595206c",
    "uncles_hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "version": "0x0"
  }
}
```

The response looks like below when `verbosity` is 0.

```
{
  "id": 42,
  "jsonrpc": "2.0",
  "result": "0x..."
}
```

#### Method `get_header_by_number`
* `get_header_by_number(block_number, verbosity)`
    * `block_number`: [`BlockNumber`](#type-blocknumber)
    * `verbosity`: [`Uint32`](#type-uint32) `|` `null`
* result: [`HeaderView`](#type-headerview) `|` [`SerializedHeader`](#type-serializedheader) `|` `null`

Returns the block header in the [canonical chain](#canonical-chain) with the specific block number.

##### Params

*   `block_number` - Number of a block

*   `verbosity` - result format which allows 0 and 1. (**Optional**, the default is 1.)

##### Returns

The RPC returns the block header when `block_number` is less than or equal to the tip block number returned by [`get_tip_block_number`](#method-get_tip_block_number) and returns null otherwise.

Because of [chain reorganization](#chain-reorganization), the PRC may return null or even different block headers in different invocations with the same `block_number`.

When `verbosity` is 1, it returns a JSON object as the `result`. See `HeaderView` for the schema.

When `verbosity` is 0, it returns a 0x-prefixed hex string as the `result`. The string encodes the block header serialized by molecule using schema `table Header`.

##### Errors

*   [`ChainIndexIsInconsistent (-201)`](#error-chainindexisinconsistent) - The index is inconsistent. It says a block hash is in the main chain, but cannot read it from the database.

##### Examples

Request

```
{
  "id": 42,
  "jsonrpc": "2.0",
  "method": "get_header_by_number",
  "params": [
    "0x400"
  ]
}
```

Response

```
{
  "id": 42,
  "jsonrpc": "2.0",
  "result": {
    "compact_target": "0x1e083126",
    "dao": "0xb5a3e047474401001bc476b9ee573000c0c387962a38000000febffacf030000",
    "epoch": "0x7080018000001",
    "hash": "0xa5f5c85987a15de25661e5a214f2c1449cd803f071acc7999820f25246471f40",
    "nonce": "0x0",
    "number": "0x400",
    "parent_hash": "0xae003585fa15309b30b31aed3dcf385e9472c3c3e93746a6c4540629a6a1ed2d",
    "proposals_hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "timestamp": "0x5cd2b117",
    "transactions_root": "0xc47d5b78b3c4c4c853e2a32810818940d0ee403423bea9ec7b8e566d9595206c",
    "uncles_hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "version": "0x0"
  }
}
```

The response looks like below when `verbosity` is 0.

```
{
  "id": 42,
  "jsonrpc": "2.0",
  "result": "0x..."
}
```

#### Method `get_transaction`
* `get_transaction(tx_hash)`
    * `tx_hash`: [`H256`](#type-h256)
* result: [`TransactionWithStatus`](#type-transactionwithstatus) `|` `null`

Returns the information about a transaction requested by transaction hash.

##### Returns

This RPC returns `null` if the transaction is not committed in the [canonical chain](#canonical-chain) nor the transaction memory pool.

If the transaction is in the chain, the block hash is also returned.

##### Params

*   `tx_hash` - Hash of a transaction

##### Examples

Request

```
{
  "id": 42,
  "jsonrpc": "2.0",
  "method": "get_transaction",
  "params": [
    "0xa0ef4eb5f4ceeb08a4c8524d84c5da95dce2f608e0ca2ec8091191b0f330c6e3"
  ]
}
```

Response

```
{
  "id": 42,
  "jsonrpc": "2.0",
  "result": {
    "transaction": {
      "cell_deps": [
        {
          "dep_type": "code",
          "out_point": {
            "index": "0x0",
            "tx_hash": "0xa4037a893eb48e18ed4ef61034ce26eba9c585f15c9cee102ae58505565eccc3"
          }
        }
      ],
      "hash": "0xa0ef4eb5f4ceeb08a4c8524d84c5da95dce2f608e0ca2ec8091191b0f330c6e3",
      "header_deps": [
        "0x7978ec7ce5b507cfb52e149e36b1a23f6062ed150503c85bbf825da3599095ed"
      ],
      "inputs": [
        {
          "previous_output": {
            "index": "0x0",
            "tx_hash": "0x365698b50ca0da75dca2c87f9e7b563811d3b5813736b8cc62cc3b106faceb17"
          },
          "since": "0x0"
        }
      ],
      "outputs": [
        {
          "capacity": "0x2540be400",
          "lock": {
            "args": "0x",
            "code_hash": "0x28e83a1277d48add8e72fadaa9248559e1b632bab2bd60b27955ebc4c03800a5",
            "hash_type": "data"
          },
          "type": null
        }
      ],
      "outputs_data": [
        "0x"
      ],
      "version": "0x0",
      "witnesses": []
    },
    "tx_status": {
      "block_hash": null,
      "status": "pending"
    }
  }
}
```

#### Method `get_block_hash`
* `get_block_hash(block_number)`
    * `block_number`: [`BlockNumber`](#type-blocknumber)
* result: [`H256`](#type-h256) `|` `null`

Returns the hash of a block in the [canonical chain](#canonical-chain) with the specified `block_number`.

##### Params

*   `block_number` - Block number

##### Returns

The RPC returns the block hash when `block_number` is less than or equal to the tip block number returned by [`get_tip_block_number`](#method-get_tip_block_number) and returns null otherwise.

Because of [chain reorganization](#chain-reorganization), the PRC may return null or even different block hashes in different invocations with the same `block_number`.

##### Examples

Request

```
{
  "id": 42,
  "jsonrpc": "2.0",
  "method": "get_block_hash",
  "params": [
    "0x400"
  ]
}
```

Response

```
{
  "id": 42,
  "jsonrpc": "2.0",
  "result": "0xa5f5c85987a15de25661e5a214f2c1449cd803f071acc7999820f25246471f40"
}
```

#### Method `get_tip_header`
* `get_tip_header(verbosity)`
    * `verbosity`: [`Uint32`](#type-uint32) `|` `null`
* result: [`HeaderView`](#type-headerview) `|` [`SerializedHeader`](#type-serializedheader)

Returns the header with the highest block number in the [canonical chain](#canonical-chain).

Because of [chain reorganization](#chain-reorganization), the block number returned can be less than previous invocations and different invocations may return different block headers with the same block number.

##### Params

*   `verbosity` - result format which allows 0 and 1. (**Optional**, the default is 1.)

##### Returns

When `verbosity` is 1, the RPC returns a JSON object as the `result`. See HeaderView for the schema.

When `verbosity` is 0, it returns a 0x-prefixed hex string as the `result`. The string encodes the header serialized by molecule using schema `table Header`.

##### Examples

Request

```
{
  "id": 42,
  "jsonrpc": "2.0",
  "method": "get_tip_header",
  "params": []
}
```

Response

```
{
  "jsonrpc": "2.0",
  "result": {
    "compact_target": "0x1e083126",
    "dao": "0xb5a3e047474401001bc476b9ee573000c0c387962a38000000febffacf030000",
    "epoch": "0x7080018000001",
    "hash": "0xa5f5c85987a15de25661e5a214f2c1449cd803f071acc7999820f25246471f40",
    "nonce": "0x0",
    "number": "0x400",
    "parent_hash": "0xae003585fa15309b30b31aed3dcf385e9472c3c3e93746a6c4540629a6a1ed2d",
    "proposals_hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "timestamp": "0x5cd2b117",
    "transactions_root": "0xc47d5b78b3c4c4c853e2a32810818940d0ee403423bea9ec7b8e566d9595206c",
    "uncles_hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "version": "0x0"
  },
  "id": 42
}
```

The response looks like below when `verbosity` is 0.

```
{
  "id": 42,
  "jsonrpc": "2.0",
  "result": "0x..."
}
```

#### Method `get_live_cell`
* `get_live_cell(out_point, with_data)`
    * `out_point`: [`OutPoint`](#type-outpoint)
    * `with_data`: `boolean`
* result: [`CellWithStatus`](#type-cellwithstatus)

Returns the status of a cell. The RPC returns extra information if it is a [live cell] (#live-cell).

##### Returns

This RPC tells whether a cell is live or not.

If the cell is live, the RPC will return details about the cell. Otherwise, the field `cell` is null in the result.

If the cell is live and `with_data` is set to `false`, the field `cell.data` is null in the result.

##### Params

*   `out_point` - Reference to the cell by transaction hash and output index.

*   `with_data` - Whether the RPC should return cell data. Cell data can be huge, if the client does not need the data, it should set this to `false` to save bandwidth.

##### Examples

Request

```
{
  "id": 42,
  "jsonrpc": "2.0",
  "method": "get_live_cell",
  "params": [
    {
      "index": "0x0",
      "tx_hash": "0xa4037a893eb48e18ed4ef61034ce26eba9c585f15c9cee102ae58505565eccc3"
    },
    true
  ]
}
```

Response

```
{
  "id": 42,
  "jsonrpc": "2.0",
  "result": {
    "cell": {
      "data": {
        "content": "0x7f454c460201010000000000000000000200f3000100000078000100000000004000000000000000980000000000000005000000400038000100400003000200010000000500000000000000000000000000010000000000000001000000000082000000000000008200000000000000001000000000000001459308d00573000000002e7368737472746162002e74657874000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000b000000010000000600000000000000780001000000000078000000000000000a0000000000000000000000000000000200000000000000000000000000000001000000030000000000000000000000000000000000000082000000000000001100000000000000000000000000000001000000000000000000000000000000",
        "hash": "0x28e83a1277d48add8e72fadaa9248559e1b632bab2bd60b27955ebc4c03800a5"
      },
      "output": {
        "capacity": "0x802665800",
        "lock": {
          "args": "0x",
          "code_hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
          "hash_type": "data"
        },
        "type": null
      }
    },
    "status": "live"
  }
}
```

#### Method `get_tip_block_number`
* `get_tip_block_number()`
* result: [`BlockNumber`](#type-blocknumber)

Returns the highest block number in the [canonical chain](#canonical-chain).

Because of [chain reorganization](#chain-reorganization), the returned block number may be less than a value returned in the previous invocation.

##### Examples

Request

```
{
  "id": 42,
  "jsonrpc": "2.0",
  "method": "get_tip_block_number",
  "params": []
}
```

Response

```
{
  "id": 42,
  "jsonrpc": "2.0",
  "result": "0x400"
}
```

#### Method `get_current_epoch`
* `get_current_epoch()`
* result: [`EpochView`](#type-epochview)

Returns the epoch with the highest number in the [canonical chain](#canonical-chain).

Pay attention that like blocks with the specific block number may change because of [chain reorganization](#chain-reorganization), This RPC may return different epochs which have the same epoch number.

##### Examples

Request

```
{
  "id": 42,
  "jsonrpc": "2.0",
  "method": "get_current_epoch",
  "params": []
}
```

Response

```
{
  "id": 42,
  "jsonrpc": "2.0",
  "result": {
    "compact_target": "0x1e083126",
    "length": "0x708",
    "number": "0x1",
    "start_number": "0x3e8"
  }
}
```

#### Method `get_epoch_by_number`
* `get_epoch_by_number(epoch_number)`
    * `epoch_number`: [`EpochNumber`](#type-epochnumber)
* result: [`EpochView`](#type-epochview) `|` `null`

Returns the epoch in the [canonical chain](#canonical-chain) with the specific epoch number.

##### Params

*   `epoch_number` - Epoch number

##### Returns

The RPC returns the epoch when `epoch_number` is less than or equal to the current epoch number returned by [`get_current_epoch`](#method-get_current_epoch) and returns null otherwise.

Because of [chain reorganization](#chain-reorganization), for the same `epoch_number`, this RPC may return null or different epochs in different invocations.

##### Examples

Request

```
{
  "id": 42,
  "jsonrpc": "2.0",
  "method": "get_epoch_by_number",
  "params": [
    "0x0"
  ]
}
```

Response

```
{
  "id": 42,
  "jsonrpc": "2.0",
  "result": {
    "compact_target": "0x20010000",
    "length": "0x3e8",
    "number": "0x0",
    "start_number": "0x0"
  }
}
```

#### Method `get_block_economic_state`
* `get_block_economic_state(block_hash)`
    * `block_hash`: [`H256`](#type-h256)
* result: [`BlockEconomicState`](#type-blockeconomicstate) `|` `null`

Returns increased issuance, miner reward, and the total transaction fee of a block.

This RPC returns null if the block is not in the [canonical chain](#canonical-chain).

CKB delays CKB creation for miners. The output cells in the cellbase of block N are for the miner creating block `N - 1 - ProposalWindow.farthest`.

In mainnet, `ProposalWindow.farthest` is 10, so the outputs in block 100 are rewards for miner creating block 89.

Because of the delay, this RPC returns null if the block rewards are not finalized yet. For example, the economic state for block 89 is only available when the number returned by [`get_tip_block_number`](#method-get_tip_block_number) is greater than or equal to 100.

##### Params

*   `block_hash` - Specifies the block hash which rewards should be analyzed.

##### Returns

If the block with the hash `block_hash` is in the [canonical chain](#canonical-chain) and its rewards have been finalized, return the block rewards analysis for this block. A special case is that the return value for genesis block is null.

##### Examples

Request

```
{
  "id": 42,
  "jsonrpc": "2.0",
  "method": "get_block_economic_state",
  "params": [
    "0x02530b25ad0ff677acc365cb73de3e8cc09c7ddd58272e879252e199d08df83b"
  ]
}
```

Response

```
{
  "id": 42,
  "jsonrpc": "2.0",
  "result": {
    "finalized_at": "0xa5f5c85987a15de25661e5a214f2c1449cd803f071acc7999820f25246471f40",
    "issuance": {
      "primary": "0x18ce922bca",
      "secondary": "0x7f02ec655"
    },
    "miner_reward": {
      "committed": "0x0",
      "primary": "0x18ce922bca",
      "proposal": "0x0",
      "secondary": "0x17b93605"
    },
    "txs_fee": "0x0"
  }
}
```

#### Method `get_transaction_proof`
* `get_transaction_proof(tx_hashes, block_hash)`
    * `tx_hashes`: `Array<` [`H256`](#type-h256) `>`
    * `block_hash`: [`H256`](#type-h256) `|` `null`
* result: [`TransactionProof`](#type-transactionproof)

Returns a Merkle proof that transactions are included in a block.

##### Params

*   `tx_hashes` - Transaction hashes, all transactions must be in the same block

*   `block_hash` - An optional parameter, if specified, looks for transactions in the block with this hash

##### Examples

Request

```
{
  "id": 42,
  "jsonrpc": "2.0",
  "method": "get_transaction_proof",
  "params": [
    [ "0xa4037a893eb48e18ed4ef61034ce26eba9c585f15c9cee102ae58505565eccc3" ]
  ]
}
```

Response

```
{
  "id": 42,
  "jsonrpc": "2.0",
  "result": {
    "block_hash": "0x7978ec7ce5b507cfb52e149e36b1a23f6062ed150503c85bbf825da3599095ed",
    "proof": {
      "indices": [ "0x0" ],
      "lemmas": []
    },
    "witnesses_root": "0x2bb631f4a251ec39d943cc238fc1e39c7f0e99776e8a1e7be28a03c70c4f4853"
  }
}
```

#### Method `verify_transaction_proof`
* `verify_transaction_proof(tx_proof)`
    * `tx_proof`: [`TransactionProof`](#type-transactionproof)
* result: `Array<` [`H256`](#type-h256) `>`

Verifies that a proof points to transactions in a block, returning the transaction hashes it commits to.

##### Parameters

*   `transaction_proof` - proof generated by [`get_transaction_proof`](#method-get_transaction_proof).

##### Examples

Request

```
{
  "id": 42,
  "jsonrpc": "2.0",
  "method": "verify_transaction_proof",
  "params": [
    {
      "block_hash": "0x7978ec7ce5b507cfb52e149e36b1a23f6062ed150503c85bbf825da3599095ed",
      "proof": {
        "indices": [ "0x0" ],
        "lemmas": []
      },
      "witnesses_root": "0x2bb631f4a251ec39d943cc238fc1e39c7f0e99776e8a1e7be28a03c70c4f4853"
    }
  ]
}
```

Response

```
{
  "id": 42,
  "jsonrpc": "2.0",
  "result": [
    "0xa4037a893eb48e18ed4ef61034ce26eba9c585f15c9cee102ae58505565eccc3"
  ]
}
```

#### Method `get_fork_block`
* `get_fork_block(block_hash, verbosity)`
    * `block_hash`: [`H256`](#type-h256)
    * `verbosity`: [`Uint32`](#type-uint32) `|` `null`
* result: [`BlockView`](#type-blockview) `|` [`SerializedBlock`](#type-serializedblock) `|` `null`

Returns the information about a fork block by hash.

##### Params

*   `block_hash` - the fork block hash.

*   `verbosity` - result format which allows 0 and 2. (**Optional**, the default is 2.)

##### Returns

The RPC returns a fork block or null. When the RPC returns a block, the block hash must equal to the parameter `block_hash`.

Please note that due to the technical nature of the peer to peer sync, the RPC may return null or a fork block result on different nodes with same `block_hash` even they are fully synced to the [canonical chain](#canonical-chain). And because of [chain reorganization](#chain-reorganization), for the same `block_hash`, the RPC may sometimes return null and sometimes return the fork block.

When `verbosity` is 2, it returns a JSON object as the `result`. See `BlockView` for the schema.

When `verbosity` is 0, it returns a 0x-prefixed hex string as the `result`. The string encodes the block serialized by molecule using schema `table Block`.

##### Examples

Request

```
{
  "id": 42,
  "jsonrpc": "2.0",
  "method": "get_fork_block",
  "params": [
    "0xdca341a42890536551f99357612cef7148ed471e3b6419d0844a4e400be6ee94"
  ]
}
```

Response

```
{
  "id": 42,
  "jsonrpc": "2.0",
  "result": {
    "header": {
      "compact_target": "0x1e083126",
      "dao": "0xb5a3e047474401001bc476b9ee573000c0c387962a38000000febffacf030000",
      "epoch": "0x7080018000001",
      "hash": "0xdca341a42890536551f99357612cef7148ed471e3b6419d0844a4e400be6ee94",
      "nonce": "0x0",
      "number": "0x400",
      "parent_hash": "0xae003585fa15309b30b31aed3dcf385e9472c3c3e93746a6c4540629a6a1ed2d",
      "proposals_hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
      "timestamp": "0x5cd2b118",
      "transactions_root": "0xc47d5b78b3c4c4c853e2a32810818940d0ee403423bea9ec7b8e566d9595206c",
      "uncles_hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
      "version": "0x0"
    },
    "proposals": [],
    "transactions": [
      {
        "cell_deps": [],
        "hash": "0x365698b50ca0da75dca2c87f9e7b563811d3b5813736b8cc62cc3b106faceb17",
        "header_deps": [],
        "inputs": [
          {
            "previous_output": {
              "index": "0xffffffff",
              "tx_hash": "0x0000000000000000000000000000000000000000000000000000000000000000"
            },
            "since": "0x400"
          }
        ],
        "outputs": [
          {
            "capacity": "0x18e64b61cf",
            "lock": {
              "args": "0x",
              "code_hash": "0x28e83a1277d48add8e72fadaa9248559e1b632bab2bd60b27955ebc4c03800a5",
              "hash_type": "data"
            },
            "type": null
          }
        ],
        "outputs_data": [
          "0x"
        ],
        "version": "0x0",
        "witnesses": [
          "0x450000000c000000410000003500000010000000300000003100000028e83a1277d48add8e72fadaa9248559e1b632bab2bd60b27955ebc4c03800a5000000000000000000"
        ]
      }
    ],
    "uncles": []
  }
}
```

The response looks like below when `verbosity` is 0.

```
{
  "id": 42,
  "jsonrpc": "2.0",
  "result": "0x..."
}
```

#### Method `get_consensus`
* `get_consensus()`
* result: [`Consensus`](#type-consensus)

Return various consensus parameters.

##### Examples

Request

```
{
  "id": 42,
  "jsonrpc": "2.0",
  "method": "get_consensus",
  "params": []
}
```

Response

```
{
  "id": 42,
  "jsonrpc": "2.0",
  "result": {
        "block_version": "0x0",
        "cellbase_maturity": "0x10000000000",
        "dao_type_hash": null,
        "epoch_duration_target": "0x3840",
        "genesis_hash": "0x7978ec7ce5b507cfb52e149e36b1a23f6062ed150503c85bbf825da3599095ed",
        "id": "main",
        "initial_primary_epoch_reward": "0x71afd498d000",
        "max_block_bytes": "0x91c08",
        "max_block_cycles": "0xd09dc300",
        "max_block_proposals_limit": "0x5dc",
        "max_uncles_num": "0x2",
        "median_time_block_count": "0x25",
        "orphan_rate_target": {
            "denom": "0x28",
            "numer": "0x1"
        },
        "permanent_difficulty_in_dummy": false,
        "primary_epoch_reward_halving_interval": "0x2238",
        "proposer_reward_ratio": {
            "denom": "0xa",
            "numer": "0x4"
        },
        "secondary_epoch_reward": "0x37d0c8e28542",
        "secp256k1_blake160_multisig_all_type_hash": null,
        "secp256k1_blake160_sighash_all_type_hash": null,
        "tx_proposal_window": {
            "closest": "0x2",
            "farthest": "0xa"
        },
        "tx_version": "0x0",
        "type_id_code_hash": "0x00000000000000000000000000000000000000000000000000545950455f4944"
    }
}
```

#### Method `get_block_median_time`
* `get_block_median_time(block_hash)`
    * `block_hash`: [`H256`](#type-h256)
* result: [`Timestamp`](#type-timestamp) `|` `null`

Returns the past median time by block hash.

##### Params

*   `block_hash` - A median time is calculated for a consecutive block sequence. `block_hash` indicates the highest block of the sequence.

##### Returns

When the given block hash is not on the current canonical chain, this RPC returns null; otherwise returns the median time of the consecutive 37 blocks where the given block_hash has the highest height.

Note that the given block is included in the median time. The included block number range is `[MAX(block - 36, 0), block]`.

##### Examples

Request

```
{
  "id": 42,
  "jsonrpc": "2.0",
  "method": "get_block_median_time",
  "params": [
    "0xa5f5c85987a15de25661e5a214f2c1449cd803f071acc7999820f25246471f40"
  ]
}
```

Response

```
{
  "id": 42,
  "jsonrpc": "2.0",
  "result": "0x5cd2b105"
}
```

### Module Experiment

RPC Module Experiment for experimenting methods.

**EXPERIMENTAL warning**

The methods here may be removed or changed in future releases without prior notifications.

#### Method `dry_run_transaction`
* `dry_run_transaction(tx)`
    * `tx`: [`Transaction`](#type-transaction)
* result: [`DryRunResult`](#type-dryrunresult)

Dry run a transaction and return the execution cycles.

This method will not check the transaction validity, but only run the lock script and type script and then return the execution cycles.

It is used to debug transaction scripts and query how many cycles the scripts consume.

##### Errors

*   [`TransactionFailedToResolve (-301)`](#error-transactionfailedtoresolve) - Failed to resolve the referenced cells and headers used in the transaction, as inputs or dependencies.

*   [`TransactionFailedToVerify (-302)`](#error-transactionfailedtoverify) - There is a script returns with an error.

##### Examples

Request

```
{
  "id": 42,
  "jsonrpc": "2.0",
  "method": "dry_run_transaction",
  "params": [
    {
      "cell_deps": [
        {
          "dep_type": "code",
          "out_point": {
            "index": "0x0",
            "tx_hash": "0xa4037a893eb48e18ed4ef61034ce26eba9c585f15c9cee102ae58505565eccc3"
          }
        }
      ],
      "header_deps": [
        "0x7978ec7ce5b507cfb52e149e36b1a23f6062ed150503c85bbf825da3599095ed"
      ],
      "inputs": [
        {
          "previous_output": {
            "index": "0x0",
            "tx_hash": "0x365698b50ca0da75dca2c87f9e7b563811d3b5813736b8cc62cc3b106faceb17"
          },
          "since": "0x0"
        }
      ],
      "outputs": [
        {
          "capacity": "0x2540be400",
          "lock": {
            "args": "0x",
            "code_hash": "0x28e83a1277d48add8e72fadaa9248559e1b632bab2bd60b27955ebc4c03800a5",
            "hash_type": "data"
          },
          "type": null
        }
      ],
      "outputs_data": [
        "0x"
      ],
      "version": "0x0",
      "witnesses": []
    }
  ]
}
```

Response

```
{
  "id": 42,
  "jsonrpc": "2.0",
  "result": {
    "cycles": "0x219"
  }
}
```

#### Method `calculate_dao_maximum_withdraw`
* `calculate_dao_maximum_withdraw(out_point, block_hash)`
    * `out_point`: [`OutPoint`](#type-outpoint)
    * `block_hash`: [`H256`](#type-h256)
* result: [`Capacity`](#type-capacity)

Calculates the maximum withdrawal one can get, given a referenced DAO cell, and a withdrawing block hash.

##### Params

*   `out_point` - Reference to the DAO cell.

*   `block_hash` - The assumed reference block for withdrawing. This block must be in the [canonical chain](#canonical-chain).

##### Returns

The RPC returns the final capacity when the cell `out_point` is withdrawn using the block `block_hash` as the reference.

In CKB, scripts cannot get the information about in which block the transaction is committed. A workaround is letting the transaction reference a block hash so the script knows that the transaction is committed at least after the reference block.

##### Errors

*   [`DaoError (-5)`](#error-daoerror) - The given out point is not a valid cell for DAO computation.

*   [`CKBInternalError (-1)`](#error-ckbinternalerror) - Mathematics overflow.

##### Examples

Request

```
{
  "id": 42,
  "jsonrpc": "2.0",
  "method": "calculate_dao_maximum_withdraw",
  "params": [
    {
      "index": "0x0",
      "tx_hash": "0xa4037a893eb48e18ed4ef61034ce26eba9c585f15c9cee102ae58505565eccc3"
    },
    "0xa5f5c85987a15de25661e5a214f2c1449cd803f071acc7999820f25246471f40"
  ]
}
```

Response

```
{
  "id": 42,
  "jsonrpc": "2.0",
  "result": "0x4a8b4e8a4"
}
```

### Module Miner

RPC Module Miner for miners.

A miner gets a template from CKB, optionally selects transactions, resolves the PoW puzzle, and submits the found new block.

#### Method `get_block_template`
* `get_block_template(bytes_limit, proposals_limit, max_version)`
    * `bytes_limit`: [`Uint64`](#type-uint64) `|` `null`
    * `proposals_limit`: [`Uint64`](#type-uint64) `|` `null`
    * `max_version`: [`Version`](#type-version) `|` `null`
* result: [`BlockTemplate`](#type-blocktemplate)

Returns block template for miners.

Miners can assemble the new block from the template. The RPC is designed to allow miners to remove transactions and adding new transactions to the block.

##### Params

*   `bytes_limit` - the max serialization size in bytes of the block. (**Optional:** the default is the consensus limit.)

*   `proposals_limit` - the max count of proposals. (**Optional:** the default is the consensus limit.)

*   `max_version` - the max block version. (**Optional:** the default is one configured in the current client version.)

##### Examples

Request

```
{
  "id": 42,
  "jsonrpc": "2.0",
  "method": "get_block_template",
  "params": [
    null,
    null,
    null
  ]
}
```

Response

```
{
  "id": 42,
  "jsonrpc": "2.0",
  "result": {
    "bytes_limit": "0x91c08",
    "cellbase": {
      "cycles": null,
      "data": {
        "cell_deps": [],
        "header_deps": [],
        "inputs": [
          {
            "previous_output": {
              "index": "0xffffffff",
              "tx_hash": "0x0000000000000000000000000000000000000000000000000000000000000000"
            },
            "since": "0x401"
          }
        ],
        "outputs": [
          {
            "capacity": "0x18e64efc04",
            "lock": {
              "args": "0x",
              "code_hash": "0x28e83a1277d48add8e72fadaa9248559e1b632bab2bd60b27955ebc4c03800a5",
              "hash_type": "data"
            },
            "type": null
          }
        ],
        "outputs_data": [
          "0x"
        ],
        "version": "0x0",
        "witnesses": [
          "0x590000000c00000055000000490000001000000030000000310000001892ea40d82b53c678ff88312450bbb17e164d7a3e0a90941aa58839f56f8df20114000000b2e61ff569acf041b3c2c17724e2379c581eeac300000000"
        ]
      },
      "hash": "0xbaf7e4db2fd002f19a597ca1a31dfe8cfe26ed8cebc91f52b75b16a7a5ec8bab"
    },
    "compact_target": "0x1e083126",
    "current_time": "0x174c45e17a3",
    "cycles_limit": "0xd09dc300",
    "dao": "0xd495a106684401001e47c0ae1d5930009449d26e32380000000721efd0030000",
    "epoch": "0x7080019000001",
    "number": "0x401",
    "parent_hash": "0xa5f5c85987a15de25661e5a214f2c1449cd803f071acc7999820f25246471f40",
    "proposals": ["0xa0ef4eb5f4ceeb08a4c8"],
    "transactions": [],
    "uncles": [
      {
        "hash": "0xdca341a42890536551f99357612cef7148ed471e3b6419d0844a4e400be6ee94",
        "header": {
          "compact_target": "0x1e083126",
          "dao": "0xb5a3e047474401001bc476b9ee573000c0c387962a38000000febffacf030000",
          "epoch": "0x7080018000001",
          "nonce": "0x0",
          "number": "0x400",
          "parent_hash": "0xae003585fa15309b30b31aed3dcf385e9472c3c3e93746a6c4540629a6a1ed2d",
          "proposals_hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
          "timestamp": "0x5cd2b118",
          "transactions_root": "0xc47d5b78b3c4c4c853e2a32810818940d0ee403423bea9ec7b8e566d9595206c",
          "uncles_hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
          "version":"0x0"
        },
        "proposals": [],
        "required": false
      }
    ],
    "uncles_count_limit": "0x2",
    "version": "0x0",
    "work_id": "0x0"
  }
}
```

#### Method `submit_block`
* `submit_block(work_id, block)`
    * `work_id`: `string`
    * `block`: [`Block`](#type-block)
* result: [`H256`](#type-h256)

Submit new block to the network.

##### Params

*   `work_id` - The same work ID returned from [`get_block_template`](#method-get_block_template).

*   `block` - The assembled block from the block template and which PoW puzzle has been resolved.

##### Examples

Request

```
{
  "id": 42,
  "jsonrpc": "2.0",
  "method": "submit_block",
  "params": [
    "example",
    {
      "header": {
        "compact_target": "0x1e083126",
        "dao": "0xb5a3e047474401001bc476b9ee573000c0c387962a38000000febffacf030000",
        "epoch": "0x7080018000001",
        "nonce": "0x0",
        "number": "0x400",
        "parent_hash": "0xae003585fa15309b30b31aed3dcf385e9472c3c3e93746a6c4540629a6a1ed2d",
        "proposals_hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
        "timestamp": "0x5cd2b117",
        "transactions_root": "0xc47d5b78b3c4c4c853e2a32810818940d0ee403423bea9ec7b8e566d9595206c",
        "uncles_hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
        "version": "0x0"
      },
      "proposals": [],
      "transactions": [
        {
          "cell_deps": [],
          "header_deps": [],
          "inputs": [
            {
              "previous_output": {
                "index": "0xffffffff",
                "tx_hash": "0x0000000000000000000000000000000000000000000000000000000000000000"
              },
              "since": "0x400"
            }
          ],
          "outputs": [
            {
              "capacity": "0x18e64b61cf",
              "lock": {
                "args": "0x",
                "code_hash": "0x28e83a1277d48add8e72fadaa9248559e1b632bab2bd60b27955ebc4c03800a5",
                "hash_type": "data"
              },
              "type": null
            }
          ],
          "outputs_data": [
            "0x"
          ],
          "version": "0x0",
          "witnesses": [
            "0x450000000c000000410000003500000010000000300000003100000028e83a1277d48add8e72fadaa9248559e1b632bab2bd60b27955ebc4c03800a5000000000000000000"
          ]
        }
      ],
      "uncles": []
    }
  ]
}
```

Response

```
{
  "id": 42,
  "jsonrpc": "2.0",
  "result": "0xa5f5c85987a15de25661e5a214f2c1449cd803f071acc7999820f25246471f40"
}
```

### Module Net

RPC Module Net for P2P network.

#### Method `local_node_info`
* `local_node_info()`
* result: [`LocalNode`](#type-localnode)

Returns the local node information.

The local node means the node itself which is serving the RPC.

##### Examples

Request

```
{
  "id": 42,
  "jsonrpc": "2.0",
  "method": "local_node_info",
  "params": []
}
```

Response

```
{
  "id": 42,
  "jsonrpc": "2.0",
  "result": {
    "active": true,
    "addresses": [
      {
        "address": "/ip4/192.168.0.2/tcp/8112/p2p/QmTRHCdrRtgUzYLNCin69zEvPvLYdxUZLLfLYyHVY3DZAS",
        "score": "0xff"
      },
      {
        "address": "/ip4/0.0.0.0/tcp/8112/p2p/QmTRHCdrRtgUzYLNCin69zEvPvLYdxUZLLfLYyHVY3DZAS",
        "score": "0x1"
      }
    ],
    "connections": "0xb",
    "node_id": "QmTRHCdrRtgUzYLNCin69zEvPvLYdxUZLLfLYyHVY3DZAS",
    "protocols": [
      {
        "id": "0x0",
        "name": "/ckb/ping",
        "support_versions": [
          "0.0.1"
        ]
      },
      {
        "id": "0x1",
        "name": "/ckb/discovery",
        "support_versions": [
          "0.0.1"
        ]
      }
    ],
    "version": "0.34.0 (f37f598 2020-07-17)"
  }
}
```

#### Method `get_peers`
* `get_peers()`
* result: `Array<` [`RemoteNode`](#type-remotenode) `>`

Returns the connected peers' information.

##### Examples

Request

```
{
  "id": 42,
  "jsonrpc": "2.0",
  "method": "get_peers",
  "params": []
}
```

Response

```
{
  "id": 42,
  "jsonrpc": "2.0",
  "result": [
    {
      "addresses": [
        {
          "address": "/ip6/::ffff:18.185.102.19/tcp/8115/p2p/QmXwUgF48ULy6hkgfqrEwEfuHW7WyWyWauueRDAYQHNDfN",
          "score": "0x64"
        },
        {
          "address": "/ip4/18.185.102.19/tcp/8115/p2p/QmXwUgF48ULy6hkgfqrEwEfuHW7WyWyWauueRDAYQHNDfN",
          "score": "0x64"
        }
      ],
      "connected_duration": "0x2f",
      "is_outbound": true,
      "last_ping_duration": "0x1a",
      "node_id": "QmXwUgF48ULy6hkgfqrEwEfuHW7WyWyWauueRDAYQHNDfN",
      "protocols": [
        {
          "id": "0x4",
          "version": "0.0.1"
        },
        {
          "id": "0x2",
          "version": "0.0.1"
        },
        {
          "id": "0x1",
          "version": "0.0.1"
        },
        {
          "id": "0x64",
          "version": "1"
        },
        {
          "id": "0x6e",
          "version": "1"
        },
        {
          "id": "0x66",
          "version": "1"
        },
        {
          "id": "0x65",
          "version": "1"
        },
        {
          "id": "0x0",
          "version": "0.0.1"
        }
      ],
      "sync_state": {
        "best_known_header_hash": null,
        "best_known_header_number": null,
        "can_fetch_count": "0x80",
        "inflight_count": "0xa",
        "last_common_header_hash": null,
        "last_common_header_number": null,
        "unknown_header_list_size": "0x20"
      },
      "version": "0.34.0 (f37f598 2020-07-17)"
    },
    {
      "addresses": [
        {
          "address": "/ip4/174.80.182.60/tcp/52965/p2p/QmVTMd7SEXfxS5p4EEM5ykTe1DwWWVewEM3NwjLY242vr2",
          "score": "0x1"
        }
      ],
      "connected_duration": "0x95",
      "is_outbound": true,
      "last_ping_duration": "0x41",
      "node_id": "QmSrkzhdBMmfCGx8tQGwgXxzBg8kLtX8qMcqECMuKWsxDV",
      "protocols": [
        {
          "id": "0x0",
          "version": "0.0.1"
        },
        {
          "id": "0x2",
          "version": "0.0.1"
        },
        {
          "id": "0x6e",
          "version": "1"
        },
        {
          "id": "0x66",
          "version": "1"
        },
        {
          "id": "0x1",
          "version": "0.0.1"
        },
        {
          "id": "0x65",
          "version": "1"
        },
        {
          "id": "0x64",
          "version": "1"
        },
        {
          "id": "0x4",
          "version": "0.0.1"
        }
      ],
      "sync_state": {
        "best_known_header_hash": "0x2157c72b3eddd41a7a14c361173cd22ef27d7e0a29eda2e511ee0b3598c0b895",
        "best_known_header_number": "0xdb835",
        "can_fetch_count": "0x80",
        "inflight_count": "0xa",
        "last_common_header_hash": "0xc63026bd881d880bb142c855dc8153187543245f0a94391c831c75df31f263c4",
        "last_common_header_number": "0x4dc08",
        "unknown_header_list_size": "0x1f"
      },
      "version": "0.30.1 (5cc1b75 2020-03-23)"
    }
  ]
}
```

#### Method `get_banned_addresses`
* `get_banned_addresses()`
* result: `Array<` [`BannedAddr`](#type-bannedaddr) `>`

Returns all banned IPs/Subnets.

##### Examples

Request

```
{
  "id": 42,
  "jsonrpc": "2.0",
  "method": "get_banned_addresses",
  "params": []
}
```

Response

```
{
  "id": 42,
  "jsonrpc": "2.0",
  "result": [
    {
      "address": "192.168.0.2/32",
      "ban_reason": "",
      "ban_until": "0x1ac89236180",
      "created_at": "0x16bde533338"
    }
  ]
}
```

#### Method `clear_banned_addresses`
* `clear_banned_addresses()`
* result: `null`

Clears all banned IPs/Subnets.

##### Examples

Request

```
{
  "id": 42,
  "jsonrpc": "2.0",
  "method": "clear_banned_addresses",
  "params": []
}
```

Response

```
{
  "id": 42,
  "jsonrpc": "2.0",
  "result": null
}
```

#### Method `set_ban`
* `set_ban(address, command, ban_time, absolute, reason)`
    * `address`: `string`
    * `command`: `string`
    * `ban_time`: [`Timestamp`](#type-timestamp) `|` `null`
    * `absolute`: `boolean` `|` `null`
    * `reason`: `string` `|` `null`
* result: `null`

Inserts or deletes an IP/Subnet from the banned list

##### Params

*   `address` - The IP/Subnet with an optional netmask (default is /32 = single IP). Examples:
    *   "192.168.0.2" bans a single IP

    *   "192.168.0.0/24" bans IP from "192.168.0.0" to "192.168.0.255".


*   `command` - `insert` to insert an IP/Subnet to the list, `delete` to delete an IP/Subnet from the list.

*   `ban_time` - Time in milliseconds how long (or until when if [absolute] is set) the IP is banned, optional parameter, null means using the default time of 24h

*   `absolute` - If set, the `ban_time` must be an absolute timestamp in milliseconds since epoch, optional parameter.

*   `reason` - Ban reason, optional parameter.

##### Errors

*   [`InvalidParams (-32602)`](#error-invalidparams)
    *   Expected `address` to be a valid IP address with an optional netmask.

    *   Expected `command` to be in the list [insert, delete].


##### Examples

Request

```
{
  "id": 42,
  "jsonrpc": "2.0",
  "method": "set_ban",
  "params": [
    "192.168.0.2",
    "insert",
    "0x1ac89236180",
    true,
    "set_ban example"
  ]
}
```

Response

```
{
  "id": 42,
  "jsonrpc": "2.0",
  "result": null
}
```

#### Method `sync_state`
* `sync_state()`
* result: [`SyncState`](#type-syncstate)

Returns chain synchronization state of this node.

##### Examples

Request

```
{
  "id": 42,
  "jsonrpc": "2.0",
  "method": "sync_state",
  "params": []
}
```

Response

```
{
  "id": 42,
  "jsonrpc": "2.0",
  "result": {
    "best_known_block_number": "0x400",
    "best_known_block_timestamp": "0x5cd2b117",
    "fast_time": "0x3e8",
    "ibd": true,
    "inflight_blocks_count": "0x0",
    "low_time": "0x5dc",
    "normal_time": "0x4e2",
    "orphan_blocks_count": "0x0"
  }
}
```

#### Method `set_network_active`
* `set_network_active(state)`
    * `state`: `boolean`
* result: `null`

Disable/enable all p2p network activity

##### Params

*   `state` - true to enable networking, false to disable

##### Examples

Request

```
{
  "id": 42,
  "jsonrpc": "2.0",
  "method": "set_network_active",
  "params": [
    false
  ]
}
```

Response

```
{
  "id": 42,
  "jsonrpc": "2.0",
  "result": null
}
```

#### Method `add_node`
* `add_node(peer_id, address)`
    * `peer_id`: `string`
    * `address`: `string`
* result: `null`

Attempts to add a node to the peers list and try connecting to it.

##### Params

*   `peer_id` - The node id of the node.

*   `address` - The address of the node.

The full P2P address is usually displayed as `address/peer_id`, for example in the log

```
2020-09-16 15:31:35.191 +08:00 NetworkRuntime INFO ckb_network::network
  Listen on address: /ip4/192.168.2.100/tcp/8114/QmUsZHPbjjzU627UZFt4k8j6ycEcNvXRnVGxCPKqwbAfQS
```

And in RPC `local_node_info`:

```
{
  "addresses": [
    {
      "address": "/ip4/192.168.2.100/tcp/8114/QmUsZHPbjjzU627UZFt4k8j6ycEcNvXRnVGxCPKqwbAfQS",
      "score": "0xff"
    }
  ]
}
```

In both of these examples,

*   `peer_id` is `QmUsZHPbjjzU627UZFt4k8j6ycEcNvXRnVGxCPKqwbAfQS`,

*   and `address` is `/ip4/192.168.2.100/tcp/8114`

##### Examples

Request

```
{
  "id": 42,
  "jsonrpc": "2.0",
  "method": "add_node",
  "params": [
    "QmUsZHPbjjzU627UZFt4k8j6ycEcNvXRnVGxCPKqwbAfQS",
    "/ip4/192.168.2.100/tcp/8114"
  ]
}
```

Response

```
{
  "id": 42,
  "jsonrpc": "2.0",
  "result": null
}
```

#### Method `remove_node`
* `remove_node(peer_id)`
    * `peer_id`: `string`
* result: `null`

Attempts to remove a node from the peers list and try disconnecting from it.

##### Params

*   `peer_id` - The peer id of the node.

This is the last part of a full P2P address. For example, in address "/ip4/192.168.2.100/tcp/8114/QmUsZHPbjjzU627UZFt4k8j6ycEcNvXRnVGxCPKqwbAfQS", the `peer_id` is `QmUsZHPbjjzU627UZFt4k8j6ycEcNvXRnVGxCPKqwbAfQS`.

##### Examples

Request

```
{
  "id": 42,
  "jsonrpc": "2.0",
  "method": "remove_node",
  "params": [
    "QmUsZHPbjjzU627UZFt4k8j6ycEcNvXRnVGxCPKqwbAfQS"
  ]
}
```

Response

```
{
  "id": 42,
  "jsonrpc": "2.0",
  "result": null
}
```

#### Method `ping_peers`
* `ping_peers()`
* result: `null`

Requests that a ping is sent to all connected peers, to measure ping time.

##### Examples

Requests

```
{
  "id": 42,
  "jsonrpc": "2.0",
  "method": "ping_peers",
  "params": []
}
```

Response

```
{
  "id": 42,
  "jsonrpc": "2.0",
  "result": null
}
```

### Module Pool

RPC Module Pool for transaction memory pool.

#### Method `send_transaction`
* `send_transaction(tx, outputs_validator)`
    * `tx`: [`Transaction`](#type-transaction)
    * `outputs_validator`: [`OutputsValidator`](#type-outputsvalidator) `|` `null`
* result: [`H256`](#type-h256)

Submits a new transaction into the transaction pool.

##### Params

*   `transaction` - The transaction.

*   `outputs_validator` - Validates the transaction outputs before entering the tx-pool. (**Optional**, default is "passthrough").

##### Errors

*   [`PoolRejectedTransactionByOutputsValidator (-1102)`](#error-poolrejectedtransactionbyoutputsvalidator) - The transaction is rejected by the validator specified by `outputs_validator`. If you really want to send transactions with advanced scripts, please set `outputs_validator` to "passthrough".

*   [`PoolRejectedTransactionByIllTransactionChecker (-1103)`](#error-poolrejectedtransactionbyilltransactionchecker) - Pool rejects some transactions which seem contain invalid VM instructions. See the issue link in the error message for details.

*   [`PoolRejectedTransactionByMinFeeRate (-1104)`](#error-poolrejectedtransactionbyminfeerate) - The transaction fee rate must be greater than or equal to the config option `tx_pool.min_fee_rate`.

*   [`PoolRejectedTransactionByMaxAncestorsCountLimit (-1105)`](#error-poolrejectedtransactionbymaxancestorscountlimit) - The ancestors count must be greater than or equal to the config option `tx_pool.max_ancestors_count`.

*   [`PoolIsFull (-1106)`](#error-poolisfull) - Pool is full.

*   [`PoolRejectedDuplicatedTransaction (-1107)`](#error-poolrejectedduplicatedtransaction) - The transaction is already in the pool.

*   [`TransactionFailedToResolve (-301)`](#error-transactionfailedtoresolve) - Failed to resolve the referenced cells and headers used in the transaction, as inputs or dependencies.

*   [`TransactionFailedToVerify (-302)`](#error-transactionfailedtoverify) - Failed to verify the transaction.

##### Examples

Request

```
{
  "id": 42,
  "jsonrpc": "2.0",
  "method": "send_transaction",
  "params": [
    {
      "cell_deps": [
        {
          "dep_type": "code",
          "out_point": {
            "index": "0x0",
            "tx_hash": "0xa4037a893eb48e18ed4ef61034ce26eba9c585f15c9cee102ae58505565eccc3"
          }
        }
      ],
      "header_deps": [
        "0x7978ec7ce5b507cfb52e149e36b1a23f6062ed150503c85bbf825da3599095ed"
      ],
      "inputs": [
        {
          "previous_output": {
            "index": "0x0",
            "tx_hash": "0x365698b50ca0da75dca2c87f9e7b563811d3b5813736b8cc62cc3b106faceb17"
          },
          "since": "0x0"
        }
      ],
      "outputs": [
        {
          "capacity": "0x2540be400",
          "lock": {
            "args": "0x",
            "code_hash": "0x28e83a1277d48add8e72fadaa9248559e1b632bab2bd60b27955ebc4c03800a5",
            "hash_type": "data"
          },
          "type": null
        }
      ],
      "outputs_data": [
        "0x"
      ],
      "version": "0x0",
      "witnesses": []
    },
    "passthrough"
  ]
}
```

Response

```
{
  "id": 42,
  "jsonrpc": "2.0",
  "result": "0xa0ef4eb5f4ceeb08a4c8524d84c5da95dce2f608e0ca2ec8091191b0f330c6e3"
}
```

#### Method `tx_pool_info`
* `tx_pool_info()`
* result: [`TxPoolInfo`](#type-txpoolinfo)

Returns the transaction pool information.

##### Examples

Request

```
{
  "id": 42,
  "jsonrpc": "2.0",
  "method": "tx_pool_info",
  "params": []
}
```

Response

```
{
  "id": 42,
  "jsonrpc": "2.0",
  "result": {
    "last_txs_updated_at": "0x0",
    "min_fee_rate": "0x0",
    "orphan": "0x0",
    "pending": "0x1",
    "proposed": "0x0",
    "tip_hash": "0xa5f5c85987a15de25661e5a214f2c1449cd803f071acc7999820f25246471f40",
    "tip_number": "0x400",
    "total_tx_cycles": "0x219",
    "total_tx_size": "0x112"
  }
}
```

#### Method `clear_tx_pool`
* `clear_tx_pool()`
* result: `null`

Removes all transactions from the transaction pool.

##### Examples

Request

```
{
  "id": 42,
  "jsonrpc": "2.0",
  "method": "clear_tx_pool",
  "params": []
}
```

Response

```
{
  "id": 42,
  "jsonrpc": "2.0",
  "result": null
}
```

#### Method `get_raw_tx_pool`
* `get_raw_tx_pool(verbose)`
    * `verbose`: `boolean` `|` `null`
* result: [`RawTxPool`](#type-rawtxpool)

Returns all transaction ids in tx pool as a json array of string transaction ids.

##### Params

*   `verbose` - True for a json object, false for array of transaction ids, default=false

##### Examples

Request

```
{
  "id": 42,
  "jsonrpc": "2.0",
  "method": "get_raw_tx_pool",
  "params": [true]
}
```

Response

```
{
  "id": 42,
  "jsonrpc": "2.0",
  "result":
   {
       "pending": {
           "0xa0ef4eb5f4ceeb08a4c8524d84c5da95dce2f608e0ca2ec8091191b0f330c6e3": {
               "cycles": "0x219",
               "size": "0x112",
               "fee": "0x16923f7dcf",
               "ancestors_size": "0x112",
               "ancestors_cycles": "0x219",
               "ancestors_count": "0x1"
           }
       },
       "proposed": {}
   }
}
```

### Module Stats

RPC Module Stats for getting various statistic data.

#### Method `get_blockchain_info`
* `get_blockchain_info()`
* result: [`ChainInfo`](#type-chaininfo)

Returns statistics about the chain.

##### Examples

Request

```
{
  "id": 42,
  "jsonrpc": "2.0",
  "method": "get_blockchain_info",
  "params": []
}
```

Response

```
{
  "id": 42,
  "jsonrpc": "2.0",
  "result": {
    "alerts": [
      {
        "id": "0x2a",
        "message": "An example alert message!",
        "notice_until": "0x24bcca57c00",
        "priority": "0x1"
      }
    ],
    "chain": "ckb",
    "difficulty": "0x1f4003",
    "epoch": "0x7080018000001",
    "is_initial_block_download": true,
    "median_time": "0x5cd2b105"
  }
}
```

### Module Subscription

RPC Module Subscription that CKB node will push new messages to subscribers.

RPC subscriptions require a full duplex connection. CKB offers such connections in the form of TCP (enable with rpc.tcp_listen_address configuration option) and WebSocket (enable with rpc.ws_listen_address).

#### Examples

TCP RPC subscription:

```
telnet localhost 18114
> {"id": 2, "jsonrpc": "2.0", "method": "subscribe", "params": ["new_tip_header"]}
< {"jsonrpc":"2.0","result":0,"id":2}
< {"jsonrpc":"2.0","method":"subscribe","params":{"result":"...block header json...",
"subscription":0}}
< {"jsonrpc":"2.0","method":"subscribe","params":{"result":"...block header json...",
"subscription":0}}
< ...
> {"id": 2, "jsonrpc": "2.0", "method": "unsubscribe", "params": [0]}
< {"jsonrpc":"2.0","result":true,"id":2}
```

WebSocket RPC subscription:

```
let socket = new WebSocket("ws://localhost:28114")

socket.onmessage = function(event) {
  console.log(`Data received from server: ${event.data}`);
}

socket.send(`{"id": 2, "jsonrpc": "2.0", "method": "subscribe", "params": ["new_tip_header"]}`)

socket.send(`{"id": 2, "jsonrpc": "2.0", "method": "unsubscribe", "params": [0]}`)
```

#### Method `subscribe`
* `subscribe(topic)`
    * `topic`: `string`
* result: `string`

Subscribes to a topic.

##### Params

*   `topic` - Subscription topic (enum: new_tip_header | new_tip_block | new_transaction | proposed_transaction | rejected_transaction)

##### Returns

This RPC returns the subscription ID as the result. CKB node will push messages in the subscribed topics to the current RPC connection. The subscript ID is also attached as `params.subscription` in the push messages.

Example push message:

```
{
  "jsonrpc": "2.0",
  "method": "subscribe",
  "params": {
    "result": { ... },
    "subscription": "0x2a"
  }
}
```

##### Topics

###### `new_tip_header`

Whenever there's a block that is appended to the canonical chain, the CKB node will publish the block header to subscribers.

The type of the `params.result` in the push message is [`HeaderView`](#type-headerview).

###### `new_tip_block`

Whenever there's a block that is appended to the canonical chain, the CKB node will publish the whole block to subscribers.

The type of the `params.result` in the push message is [`BlockView`](#type-blockview).

###### `new_transaction`

Subscribers will get notified when a new transaction is submitted to the pool.

The type of the `params.result` in the push message is [`PoolTransactionEntry`](#type-pooltransactionentry).

###### `proposed_transaction`

Subscribers will get notified when an in-pool transaction is proposed by chain.

The type of the `params.result` in the push message is [`PoolTransactionEntry`](#type-pooltransactionentry).

###### `rejected_transaction`

Subscribers will get notified when a pending transaction is rejected by tx-pool.

The type of the `params.result` in the push message is an array contain:

The type of the `params.result` in the push message is a two-elements array, where

*   the first item type is [`PoolTransactionEntry`](#type-pooltransactionentry), and

*   the second item type is [`PoolTransactionReject`](#type-pooltransactionreject).

##### Examples

Request

```
{
  "id": 42,
  "jsonrpc": "2.0",
  "method": "subscribe",
  "params": [
    "new_tip_header"
  ]
}
```

Response

```
{
  "id": 42,
  "jsonrpc": "2.0",
  "result": "0x2a"
}
```

#### Method `unsubscribe`
* `unsubscribe(id)`
    * `id`: `string`
* result: `boolean`

Unsubscribes from a subscribed topic.

##### Params

*   `id` - Subscription ID

##### Examples

Request

```
{
  "id": 42,
  "jsonrpc": "2.0",
  "method": "unsubscribe",
  "params": [
    "0x2a"
  ]
}
```

Response

```
{
  "id": 42,
  "jsonrpc": "2.0",
  "result": true
}
```


## RPC Errors

CKB RPC error codes.

CKB RPC follows the JSON RPC specification about the [error object](https://www.jsonrpc.org/specification#error_object).

Besides the pre-defined errors, all CKB defined errors are listed here.

Here is a reference to the pre-defined errors:

|  code | message | meaning |
| --- |--- |--- |
|  -32700 | Parse error | Invalid JSON was received by the server. |
|  -32600 | Invalid Request | The JSON sent is not a valid Request object. |
|  -32601 | Method not found | The method does not exist / is not available. |
|  -32602 | Invalid params | Invalid method parameter(s). |
|  -32603 | Internal error | Internal JSON-RPC error. |
|  -32000 to -32099 | Server error | Reserved for implementation-defined server-errors. |

CKB application-defined errors follow some patterns to assign the codes:

*   -1 ~ -999 are general errors

*   -1000 ~ -2999 are module-specific errors. Each module generally gets 100 reserved error codes.

Unless otherwise noted, all the errors return optional detailed information as `string` in the error object `data` field.

### Error `CKBInternalError`

(-1): CKB internal errors are considered to never happen or only happen when the system resources are exhausted.

### Error `Deprecated`

(-2): The CKB method has been deprecated and disabled.

Set `rpc.enable_deprecated_rpc` to `true` in the config file to enable all deprecated methods.

### Error `Invalid`

(-3): Error code -3 is no longer used.

Before v0.35.0, CKB returns all RPC errors using the error code -3. CKB no longer uses -3 since v0.35.0.

### Error `RPCModuleIsDisabled`

(-4): The RPC method is not enabled.

CKB groups RPC methods into modules, and a method is enabled only when the module is explicitly enabled in the config file.

### Error `DaoError`

(-5): DAO related errors.

### Error `IntegerOverflow`

(-6): Integer operation overflow.

### Error `ConfigError`

(-7): The error is caused by a config file option.

Users have to edit the config file to fix the error.

### Error `P2PFailedToBroadcast`

(-101): The CKB local node failed to broadcast a message to its peers.

### Error `DatabaseError`

(-200): Internal database error.

The CKB node persists data to the database. This is the error from the underlying database module.

### Error `ChainIndexIsInconsistent`

(-201): The chain index is inconsistent.

An example of an inconsistent index is that the chain index says a block hash is in the chain but the block cannot be read from the database.

This is a fatal error usually due to a serious bug. Please back up the data directory and re-sync the chain from scratch.

### Error `DatabaseIsCorrupt`

(-202): The underlying database is corrupt.

This is a fatal error usually caused by the underlying database used by CKB. Please back up the data directory and re-sync the chain from scratch.

### Error `TransactionFailedToResolve`

(-301): Failed to resolve the referenced cells and headers used in the transaction, as inputs or dependencies.

### Error `TransactionFailedToVerify`

(-302): Failed to verify the transaction.

### Error `AlertFailedToVerifySignatures`

(-1000): Some signatures in the submit alert are invalid.

### Error `PoolRejectedTransactionByOutputsValidator`

(-1102): The transaction is rejected by the outputs validator specified by the RPC parameter.

### Error `PoolRejectedTransactionByIllTransactionChecker`

(-1103): Pool rejects some transactions which seem contain invalid VM instructions. See the issue link in the error message for details.

### Error `PoolRejectedTransactionByMinFeeRate`

(-1104): The transaction fee rate must be greater than or equal to the config option `tx_pool.min_fee_rate`

The fee rate is calculated as:

```
fee / (1000 * tx_serialization_size_in_block_in_bytes)
```

### Error `PoolRejectedTransactionByMaxAncestorsCountLimit`

(-1105): The in-pool ancestors count must be less than or equal to the config option `tx_pool.max_ancestors_count`

Pool rejects a large package of chained transactions to avoid certain kinds of DoS attacks.

### Error `PoolIsFull`

(-1106): The transaction is rejected because the pool has reached its limit.

### Error `PoolRejectedDuplicatedTransaction`

(-1107): The transaction is already in the pool.

### Error `PoolRejectedMalformedTransaction`

(-1108): The transaction is rejected because it does not make sense in the context.

For example, a cellbase transaction is not allowed in `send_transaction` RPC.


## RPC Types

### Type `Alert`

An alert is a message about critical problems to be broadcast to all nodes via the p2p network.

#### Examples

An example in JSON


```
{
  "id": "0x1",
  "cancel": "0x0",
  "min_version": "0.1.0",
  "max_version": "1.0.0",
  "priority": "0x1",
  "message": "An example alert message!",
  "notice_until": "0x24bcca57c00",
  "signatures": [
    "0xbd07059aa9a3d057da294c2c4d96fa1e67eeb089837c87b523f124239e18e9fc7d11bb95b720478f7f937d073517d0e4eb9a91d12da5c88a05f750362f4c214dd0",
    "0x0242ef40bb64fe3189284de91f981b17f4d740c5e24a3fc9b70059db6aa1d198a2e76da4f84ab37549880d116860976e0cf81cd039563c452412076ebffa2e4453"
  ]
}
```


#### Fields

`Alert` is a JSON object with the following fields.

*   `id`: [`AlertId`](#type-alertid) - The identifier of the alert. Clients use id to filter duplicated alerts.

*   `cancel`: [`AlertId`](#type-alertid) - Cancel a previous sent alert.

*   `min_version`: `string` `|` `null` - Optionally set the minimal version of the target clients.

    See [Semantic Version](https://semver.org/) about how to specify a version.

*   `max_version`: `string` `|` `null` - Optionally set the maximal version of the target clients.

    See [Semantic Version](https://semver.org/) about how to specify a version.

*   `priority`: [`AlertPriority`](#type-alertpriority) - Alerts are sorted by priority, highest first.

*   `notice_until`: [`Timestamp`](#type-timestamp) - The alert is expired after this timestamp.

*   `message`: `string` - Alert message.

*   `signatures`: `Array<` [`JsonBytes`](#type-jsonbytes) `>` - The list of required signatures.


### Type `AlertId`

The alert identifier that is used to filter duplicated alerts.

This is a 32-bit unsigned integer type encoded as the 0x-prefixed hex string in JSON. See examples of [Uint32](#type-uint32).

### Type `AlertMessage`

An alert sent by RPC `send_alert`.

#### Fields

`AlertMessage` is a JSON object with the following fields.

*   `id`: [`AlertId`](#type-alertid) - The unique alert ID.

*   `priority`: [`AlertPriority`](#type-alertpriority) - Alerts are sorted by priority, highest first.

*   `notice_until`: [`Timestamp`](#type-timestamp) - The alert is expired after this timestamp.

*   `message`: `string` - Alert message.


### Type `AlertPriority`

Alerts are sorted by priority. Greater integers mean higher priorities.

This is a 32-bit unsigned integer type encoded as the 0x-prefixed hex string in JSON. See examples of [Uint32](#type-uint32).

### Type `BannedAddr`

A banned P2P address.

#### Fields

`BannedAddr` is a JSON object with the following fields.

*   `address`: `string` - The P2P address.

    Example: "/ip4/192.168.0.2/tcp/8112/p2p/QmTRHCdrRtgUzYLNCin69zEvPvLYdxUZLLfLYyHVY3DZAS"

*   `ban_until`: [`Timestamp`](#type-timestamp) - The address is banned until this time.

*   `ban_reason`: `string` - The reason.

*   `created_at`: [`Timestamp`](#type-timestamp) - When this address is banned.


### Type `Block`

The JSON view of a Block used as a parameter in the RPC.

#### Fields

`Block` is a JSON object with the following fields.

*   `header`: [`Header`](#type-header) - The block header.

*   `uncles`: `Array<` [`UncleBlock`](#type-uncleblock) `>` - The uncles blocks in the block body.

*   `transactions`: `Array<` [`Transaction`](#type-transaction) `>` - The transactions in the block body.

*   `proposals`: `Array<` [`ProposalShortId`](#type-proposalshortid) `>` - The proposal IDs in the block body.


### Type `BlockEconomicState`

Block Economic State.

It includes the rewards details and when it is finalized.

#### Fields

`BlockEconomicState` is a JSON object with the following fields.

*   `issuance`: [`BlockIssuance`](#type-blockissuance) - Block base rewards.

*   `miner_reward`: [`MinerReward`](#type-minerreward) - Block rewards for miners.

*   `txs_fee`: [`Capacity`](#type-capacity) - The total fees of all transactions committed in the block.

*   `finalized_at`: [`H256`](#type-h256) - The block hash of the block which creates the rewards as cells in its cellbase transaction.


### Type `BlockIssuance`

Block base rewards.

#### Fields

`BlockIssuance` is a JSON object with the following fields.

*   `primary`: [`Capacity`](#type-capacity) - The primary base rewards.

*   `secondary`: [`Capacity`](#type-capacity) - The secondary base rewards.


### Type `BlockNumber`

Consecutive block number starting from 0.

This is a 64-bit unsigned integer type encoded as the 0x-prefixed hex string in JSON. See examples of [Uint64](#type-uint64).

### Type `BlockTemplate`

A block template for miners.

Miners optional pick transactions and then assemble the final block.

#### Fields

`BlockTemplate` is a JSON object with the following fields.

*   `version`: [`Version`](#type-version) - Block version.

    Miners must use it unchanged in the assembled block.

*   `compact_target`: [`Uint32`](#type-uint32) - The compacted difficulty target for the new block.

    Miners must use it unchanged in the assembled block.

*   `current_time`: [`Timestamp`](#type-timestamp) - The timestamp for the new block.

    CKB node guarantees that this timestamp is larger than the median of the previous 37 blocks.

    Miners can increase it to the current time. It is not recommended to decrease it, since it may violate the median block timestamp consensus rule.

*   `number`: [`BlockNumber`](#type-blocknumber) - The block number for the new block.

    Miners must use it unchanged in the assembled block.

*   `epoch`: [`EpochNumberWithFraction`](#type-epochnumberwithfraction) - The epoch progress information for the new block.

    Miners must use it unchanged in the assembled block.

*   `parent_hash`: [`H256`](#type-h256) - The parent block hash of the new block.

    Miners must use it unchanged in the assembled block.

*   `cycles_limit`: [`Cycle`](#type-cycle) - The cycles limit.

    Miners must keep the total cycles below this limit, otherwise, the CKB node will reject the block submission.

    It is guaranteed that the block does not exceed the limit if miners do not add new transactions to the block.

*   `bytes_limit`: [`Uint64`](#type-uint64) - The block serialized size limit.

    Miners must keep the block size below this limit, otherwise, the CKB node will reject the block submission.

    It is guaranteed that the block does not exceed the limit if miners do not add new transaction commitments.

*   `uncles_count_limit`: [`Uint64`](#type-uint64) - The uncle count limit.

    Miners must keep the uncles count below this limit, otherwise, the CKB node will reject the block submission.

*   `uncles`: `Array<` [`UncleTemplate`](#type-uncletemplate) `>` - Provided valid uncle blocks candidates for the new block.

    Miners must include the uncles marked as `required` in the assembled new block.

*   `transactions`: `Array<` [`TransactionTemplate`](#type-transactiontemplate) `>` - Provided valid transactions which can be committed in the new block.

    Miners must include the transactions marked as `required` in the assembled new block.

*   `proposals`: `Array<` [`ProposalShortId`](#type-proposalshortid) `>` - Provided proposal ids list of transactions for the new block.

*   `cellbase`: [`CellbaseTemplate`](#type-cellbasetemplate) - Provided cellbase transaction template.

    Miners must use it as the cellbase transaction without changes in the assembled block.

*   `work_id`: [`Uint64`](#type-uint64) - Work ID. The miner must submit the new assembled and resolved block using the same work ID.

*   `dao`: [`Byte32`](#type-byte32) - Reference DAO field.

    This field is only valid when miners use all and only use the provided transactions in the template. Two fields must be updated when miners want to select transactions:

    *   `S_i`, bytes 16 to 23

    *   `U_i`, bytes 24 to 31

    See RFC [Deposit and Withdraw in Nervos DAO](https://github.com/nervosnetwork/rfcs/blob/master/rfcs/0023-dao-deposit-withdraw/0023-dao-deposit-withdraw.md#calculation).


### Type `BlockView`

The JSON view of a Block including header and body.

#### Fields

`BlockView` is a JSON object with the following fields.

*   `header`: [`HeaderView`](#type-headerview) - The block header.

*   `uncles`: `Array<` [`UncleBlockView`](#type-uncleblockview) `>` - The uncles blocks in the block body.

*   `transactions`: `Array<` [`TransactionView`](#type-transactionview) `>` - The transactions in the block body.

*   `proposals`: `Array<` [`ProposalShortId`](#type-proposalshortid) `>` - The proposal IDs in the block body.


### Type `Byte32`

Fixed-length 32 bytes binary encoded as a 0x-prefixed hex string in JSON.

#### Example

```
0xd495a106684401001e47c0ae1d5930009449d26e32380000000721efd0030000
```



### Type `Capacity`

The capacity of a cell is the value of the cell in Shannons. It is also the upper limit of the cell occupied storage size where every 100,000,000 Shannons give 1-byte storage.

This is a 64-bit unsigned integer type encoded as the 0x-prefixed hex string in JSON. See examples of [Uint64](#type-uint64).

### Type `CellData`

The cell data content and hash.

#### Examples


```
{
  "content": "0x7f454c460201010000000000000000000200f3000100000078000100000000004000000000000000980000000000000005000000400038000100400003000200010000000500000000000000000000000000010000000000000001000000000082000000000000008200000000000000001000000000000001459308d00573000000002e7368737472746162002e74657874000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000b000000010000000600000000000000780001000000000078000000000000000a0000000000000000000000000000000200000000000000000000000000000001000000030000000000000000000000000000000000000082000000000000001100000000000000000000000000000001000000000000000000000000000000",
  "hash": "0x28e83a1277d48add8e72fadaa9248559e1b632bab2bd60b27955ebc4c03800a5"
}
```


#### Fields

`CellData` is a JSON object with the following fields.

*   `content`: [`JsonBytes`](#type-jsonbytes) - Cell content.

*   `hash`: [`H256`](#type-h256) - Cell content hash.


### Type `CellDep`

The cell dependency of a transaction.

#### Examples


```
{
  "dep_type": "code",
  "out_point": {
    "index": "0x0",
    "tx_hash": "0xa4037a893eb48e18ed4ef61034ce26eba9c585f15c9cee102ae58505565eccc3"
  }
}
```


#### Fields

`CellDep` is a JSON object with the following fields.

*   `out_point`: [`OutPoint`](#type-outpoint) - Reference to the cell.

*   `dep_type`: [`DepType`](#type-deptype) - Dependency type.


### Type `CellInfo`

The JSON view of a cell combining the fields in cell output and cell data.

#### Examples


```
{
  "data": {
    "content": "0x7f454c460201010000000000000000000200f3000100000078000100000000004000000000000000980000000000000005000000400038000100400003000200010000000500000000000000000000000000010000000000000001000000000082000000000000008200000000000000001000000000000001459308d00573000000002e7368737472746162002e74657874000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000b000000010000000600000000000000780001000000000078000000000000000a0000000000000000000000000000000200000000000000000000000000000001000000030000000000000000000000000000000000000082000000000000001100000000000000000000000000000001000000000000000000000000000000",
    "hash": "0x28e83a1277d48add8e72fadaa9248559e1b632bab2bd60b27955ebc4c03800a5"
  },
  "output": {
    "capacity": "0x802665800",
    "lock": {
      "args": "0x",
      "code_hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
      "hash_type": "data"
    },
    "type": null
  }
}
```


#### Fields

`CellInfo` is a JSON object with the following fields.

*   `output`: [`CellOutput`](#type-celloutput) - Cell fields appears in the transaction `outputs` array.

*   `data`: [`CellData`](#type-celldata) `|` `null` - Cell data.

    This is `null` when the data is not requested, which does not mean the cell data is empty.


### Type `CellInput`

The input cell of a transaction.

#### Examples


```
{
  "previous_output": {
    "index": "0x0",
    "tx_hash": "0x365698b50ca0da75dca2c87f9e7b563811d3b5813736b8cc62cc3b106faceb17"
  },
  "since": "0x0"
}
```


#### Fields

`CellInput` is a JSON object with the following fields.

*   `since`: [`Uint64`](#type-uint64) - Restrict when the transaction can be committed into the chain.

    See the RFC [Transaction valid since](https://github.com/nervosnetwork/rfcs/blob/master/rfcs/0017-tx-valid-since/0017-tx-valid-since.md).

*   `previous_output`: [`OutPoint`](#type-outpoint) - Reference to the input cell.


### Type `CellOutput`

The fields of an output cell except the cell data.

#### Examples


```
{
  "capacity": "0x2540be400",
  "lock": {
    "args": "0x",
    "code_hash": "0x28e83a1277d48add8e72fadaa9248559e1b632bab2bd60b27955ebc4c03800a5",
    "hash_type": "data"
  },
  "type": null
}
```


#### Fields

`CellOutput` is a JSON object with the following fields.

*   `capacity`: [`Capacity`](#type-capacity) - The cell capacity.

    The capacity of a cell is the value of the cell in Shannons. It is also the upper limit of the cell occupied storage size where every 100,000,000 Shannons give 1-byte storage.

*   `lock`: [`Script`](#type-script) - The lock script.

*   `type_`: [`Script`](#type-script) `|` `null` - The optional type script.

    The JSON field name is "type".


### Type `CellWithStatus`

The JSON view of a cell with its status information.

#### Examples


```
{
  "cell": {
    "data": {
      "content": "0x7f454c460201010000000000000000000200f3000100000078000100000000004000000000000000980000000000000005000000400038000100400003000200010000000500000000000000000000000000010000000000000001000000000082000000000000008200000000000000001000000000000001459308d00573000000002e7368737472746162002e74657874000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000b000000010000000600000000000000780001000000000078000000000000000a0000000000000000000000000000000200000000000000000000000000000001000000030000000000000000000000000000000000000082000000000000001100000000000000000000000000000001000000000000000000000000000000",
      "hash": "0x28e83a1277d48add8e72fadaa9248559e1b632bab2bd60b27955ebc4c03800a5"
    },
    "output": {
      "capacity": "0x802665800",
      "lock": {
        "args": "0x",
        "code_hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
        "hash_type": "data"
      },
      "type": null
    }
  },
  "status": "live"
}
```



```
{
  "cell": null,
  "status": "unknown"
}
```


#### Fields

`CellWithStatus` is a JSON object with the following fields.

*   `cell`: [`CellInfo`](#type-cellinfo) `|` `null` - The cell information.

    For performance issues, CKB only keeps the information for live cells.

*   `status`: `string` - Status of the cell.

    Allowed values: "live", "dead", "unknown".

    *   `live` - The transaction creating this cell is in the chain, and there are no transactions found in the chain that uses this cell as an input.

    *   `dead` - (**Deprecated**: the dead status will be removed since 0.36.0, please do not rely on the logic that differentiates dead and unknown cells.) The transaction creating this cell is in the chain, and a transaction is found in the chain which uses this cell as an input.

    *   `unknown` - CKB does not know the status of the cell. Either the transaction creating this cell is not in the chain yet, or it is no longer live.


### Type `CellbaseTemplate`

The cellbase transaction template of the new block for miners.

#### Fields

`CellbaseTemplate` is a JSON object with the following fields.

*   `hash`: [`H256`](#type-h256) - The cellbase transaction hash.

*   `cycles`: [`Cycle`](#type-cycle) `|` `null` - The hint of how many cycles this transaction consumes.

    Miners can utilize this field to ensure that the total cycles do not exceed the limit while selecting transactions.

*   `data`: [`Transaction`](#type-transaction) - The cellbase transaction.


### Type `ChainInfo`

Chain information.

#### Fields

`ChainInfo` is a JSON object with the following fields.

*   `chain`: `string` - The network name.

    Examples:

    *   "ckb" - Lina the mainnet.

    *   "ckb_testnet" - Aggron the testnet.

*   `median_time`: [`Timestamp`](#type-timestamp) - The median time of the last 37 blocks, including the tip block.

*   `epoch`: [`EpochNumberWithFraction`](#type-epochnumberwithfraction) - The epoch information of tip block in the chain.

*   `difficulty`: [`U256`](#type-u256) - Current difficulty.

    Decoded from the epoch `compact_target`.

*   `is_initial_block_download`: `boolean` - Whether the local node is in IBD, Initial Block Download.

    When a node starts and its chain tip timestamp is far behind the wall clock, it will enter the IBD until it catches up the synchronization.

    During IBD, the local node only synchronizes the chain with one selected remote node and stops responding the most P2P requests.

*   `alerts`: `Array<` [`AlertMessage`](#type-alertmessage) `>` - Active alerts stored in the local node.


### Type `Consensus`

Consensus defines various parameters that influence chain consensus

#### Fields

`Consensus` is a JSON object with the following fields.

*   `id`: `string` - Names the network.

*   `genesis_hash`: [`H256`](#type-h256) - The genesis block hash

*   `dao_type_hash`: [`H256`](#type-h256) `|` `null` - The dao type hash

*   `secp256k1_blake160_sighash_all_type_hash`: [`H256`](#type-h256) `|` `null` - The secp256k1_blake160_sighash_all_type_hash

*   `secp256k1_blake160_multisig_all_type_hash`: [`H256`](#type-h256) `|` `null` - The secp256k1_blake160_multisig_all_type_hash

*   `initial_primary_epoch_reward`: [`Capacity`](#type-capacity) - The initial primary_epoch_reward

*   `secondary_epoch_reward`: [`Capacity`](#type-capacity) - The secondary primary_epoch_reward

*   `max_uncles_num`: [`Uint64`](#type-uint64) - The maximum amount of uncles allowed for a block

*   `orphan_rate_target`: [`RationalU256`](#type-rationalu256) - The expected orphan_rate

*   `epoch_duration_target`: [`Uint64`](#type-uint64) - The expected epoch_duration

*   `tx_proposal_window`: [`ProposalWindow`](#type-proposalwindow) - The two-step-transaction-confirmation proposal window

*   `proposer_reward_ratio`: [`RationalU256`](#type-rationalu256) - The two-step-transaction-confirmation proposer reward ratio

*   `cellbase_maturity`: [`EpochNumberWithFraction`](#type-epochnumberwithfraction) - The Cellbase maturity

*   `median_time_block_count`: [`Uint64`](#type-uint64) - This parameter indicates the count of past blocks used in the median time calculation

*   `max_block_cycles`: [`Cycle`](#type-cycle) - Maximum cycles that all the scripts in all the commit transactions can take

*   `max_block_bytes`: [`Uint64`](#type-uint64) - Maximum number of bytes to use for the entire block

*   `block_version`: [`Version`](#type-version) - The block version number supported

*   `tx_version`: [`Version`](#type-version) - The tx version number supported

*   `type_id_code_hash`: [`H256`](#type-h256) - The "TYPE_ID" in hex

*   `max_block_proposals_limit`: [`Uint64`](#type-uint64) - The Limit to the number of proposals per block

*   `primary_epoch_reward_halving_interval`: [`Uint64`](#type-uint64) - Primary reward is cut in half every halving_interval epoch

*   `permanent_difficulty_in_dummy`: `boolean` - Keep difficulty be permanent if the pow is dummy


### Type `Cycle`

Count of cycles consumed by CKB VM to run scripts.

This is a 64-bit unsigned integer type encoded as the 0x-prefixed hex string in JSON. See examples of [Uint64](#type-uint64).

### Type `DepType`

The dep cell type. Allowed values: "code" and "dep_group".

`DepType` is equivalent to `"code" | "dep_group"`.

*   Type "code".
*   Type "dep_group".


### Type `DryRunResult`

Response result of the RPC method `dry_run_transaction`.

#### Fields

`DryRunResult` is a JSON object with the following fields.

*   `cycles`: [`Cycle`](#type-cycle) - The count of cycles that the VM has consumed to verify this transaction.


### Type `EpochNumber`

Consecutive epoch number starting from 0.

This is a 64-bit unsigned integer type encoded as the 0x-prefixed hex string in JSON. See examples of [Uint64](#type-uint64).

### Type `EpochNumberWithFraction`

The epoch indicator of a block. It shows which epoch the block is in, and the elapsed epoch fraction after adding this block.

This is a 64-bit unsigned integer type encoded as the 0x-prefixed hex string in JSON. See examples of [Uint64](#type-uint64).

The lower 56 bits of the epoch field are split into 3 parts (listed in the order from higher bits to lower bits):

*   The highest 16 bits represent the epoch length

*   The next 16 bits represent the current block index in the epoch, starting from 0.

*   The lowest 24 bits represent the current epoch number.

Assume there's a block, which number is 11555 and in epoch 50. The epoch 50 starts from block 11000 and have 1000 blocks. The epoch field for this particular block will then be 1,099,520,939,130,930, which is calculated in the following way:

```
50 | ((11555 - 11000) << 24) | (1000 << 40)
```

### Type `EpochView`

JSON view of an epoch.

CKB adjusts difficulty based on epochs.

#### Examples


```
{
  "compact_target": "0x1e083126",
  "length": "0x708",
  "number": "0x1",
  "start_number": "0x3e8"
}
```


#### Fields

`EpochView` is a JSON object with the following fields.

*   `number`: [`EpochNumber`](#type-epochnumber) - Consecutive epoch number starting from 0.

*   `start_number`: [`BlockNumber`](#type-blocknumber) - The block number of the first block in the epoch.

    It also equals the total count of blocks in all the epochs which epoch number is less than this epoch.

*   `length`: [`BlockNumber`](#type-blocknumber) - The number of blocks in this epoch.

*   `compact_target`: [`Uint32`](#type-uint32) - The difficulty target for any block in this epoch.


### Type `H256`

The 32-byte fixed-length binary data.

The name comes from the number of bits in the data.

In JSONRPC, it is encoded as a 0x-prefixed hex string.



### Type `Header`

The block header.

Refer to RFC [CKB Block Structure](https://github.com/nervosnetwork/rfcs/blob/master/rfcs/0027-block-structure/0027-block-structure.md).

#### Fields

`Header` is a JSON object with the following fields.

*   `version`: [`Version`](#type-version) - The block version.

    It must equal to 0 now and is reserved for future upgrades.

*   `compact_target`: [`Uint32`](#type-uint32) - The block difficulty target.

    It can be converted to a 256-bit target. Miners must ensure the Eaglesong of the header is within the target.

*   `timestamp`: [`Timestamp`](#type-timestamp) - The block timestamp.

    It is a Unix timestamp in milliseconds (1 second = 1000 milliseconds).

    Miners should put the time when the block is created in the header, however, the precision is not guaranteed. A block with a higher block number may even have a smaller timestamp.

*   `number`: [`BlockNumber`](#type-blocknumber) - The consecutive block number starting from 0.

*   `epoch`: [`EpochNumberWithFraction`](#type-epochnumberwithfraction) - The epoch information of this block.

    See `EpochNumberWithFraction` for details.

*   `parent_hash`: [`H256`](#type-h256) - The header hash of the parent block.

*   `transactions_root`: [`H256`](#type-h256) - The commitment to all the transactions in the block.

    It is a hash on two Merkle Tree roots:

    *   The root of a CKB Merkle Tree, which items are the transaction hashes of all the transactions in the block.

    *   The root of a CKB Merkle Tree, but the items are the transaction witness hashes of all the transactions in the block.

*   `proposals_hash`: [`H256`](#type-h256) - The hash on `proposals` in the block body.

    It is all zeros when `proposals` is empty, or the hash on all the bytes concatenated together.

*   `uncles_hash`: [`H256`](#type-h256) - The hash on `uncles` in the block body.

    It is all zeros when `uncles` is empty, or the hash on all the uncle header hashes concatenated together.

*   `dao`: [`Byte32`](#type-byte32) - DAO fields.

    See RFC [Deposit and Withdraw in Nervos DAO](https://github.com/nervosnetwork/rfcs/blob/master/rfcs/0023-dao-deposit-withdraw/0023-dao-deposit-withdraw.md#calculation).

*   `nonce`: [`Uint128`](#type-uint128) - Miner can modify this field to find a proper value such that the Eaglesong of the header is within the target encoded from `compact_target`.


### Type `HeaderView`

The JSON view of a Header.

This structure is serialized into a JSON object with field `hash` and all the fields in [`Header`](#type-header).

#### Examples


```
{
  "compact_target": "0x1e083126",
  "dao": "0xb5a3e047474401001bc476b9ee573000c0c387962a38000000febffacf030000",
  "epoch": "0x7080018000001",
  "hash": "0xa5f5c85987a15de25661e5a214f2c1449cd803f071acc7999820f25246471f40",
  "nonce": "0x0",
  "number": "0x400",
  "parent_hash": "0xae003585fa15309b30b31aed3dcf385e9472c3c3e93746a6c4540629a6a1ed2d",
  "proposals_hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
  "timestamp": "0x5cd2b117",
  "transactions_root": "0xc47d5b78b3c4c4c853e2a32810818940d0ee403423bea9ec7b8e566d9595206c",
  "uncles_hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
  "version": "0x0"
}
```


#### Fields

`HeaderView` is a JSON object with the following fields.

*   `inner`: [`Header`](#type-header) - All the fields in `Header` are included in `HeaderView` in JSON.

*   `hash`: [`H256`](#type-h256) - The header hash. It is also called the block hash.


### Type `JsonBytes`

Variable-length binary encoded as a 0x-prefixed hex string in JSON.

#### Example

|  JSON | Binary |
| --- |--- |
|  "0x" | Empty binary |
|  "0x00" | Single byte 0 |
|  "0x636b62" | 3 bytes, UTF-8 encoding of ckb |
|  "00" | Invalid, 0x is required |
|  "0x0" | Invalid, each byte requires 2 digits |



### Type `LocalNode`

The information of the node itself.

#### Examples


```
{
  "active": true,
  "addresses": [
    {
      "address": "/ip4/192.168.0.2/tcp/8112/p2p/QmTRHCdrRtgUzYLNCin69zEvPvLYdxUZLLfLYyHVY3DZAS",
      "score": "0xff"
    },
    {
      "address": "/ip4/0.0.0.0/tcp/8112/p2p/QmTRHCdrRtgUzYLNCin69zEvPvLYdxUZLLfLYyHVY3DZAS",
      "score": "0x1"
    }
  ],
  "connections": "0xb",
  "node_id": "QmTRHCdrRtgUzYLNCin69zEvPvLYdxUZLLfLYyHVY3DZAS",
  "protocols": [
    {
      "id": "0x0",
      "name": "/ckb/ping",
      "support_versions": [
        "0.0.1"
      ]
    },
    {
      "id": "0x1",
      "name": "/ckb/discovery",
      "support_versions": [
        "0.0.1"
      ]
    }
  ],
  "version": "0.34.0 (f37f598 2020-07-17)"
}
```


#### Fields

`LocalNode` is a JSON object with the following fields.

*   `version`: `string` - CKB node version.

    Example: "version": "0.34.0 (f37f598 2020-07-17)"

*   `node_id`: `string` - The unique node ID derived from the p2p private key.

    The private key is generated randomly on the first boot.

*   `active`: `boolean` - Whether this node is active.

    An inactive node ignores incoming p2p messages and drops outgoing messages.

*   `addresses`: `Array<` [`NodeAddress`](#type-nodeaddress) `>` - P2P addresses of this node.

    A node can have multiple addresses.

*   `protocols`: `Array<` [`LocalNodeProtocol`](#type-localnodeprotocol) `>` - Supported protocols.

*   `connections`: [`Uint64`](#type-uint64) - Count of currently connected peers.


### Type `LocalNodeProtocol`

The information of a P2P protocol that is supported by the local node.

#### Fields

`LocalNodeProtocol` is a JSON object with the following fields.

*   `id`: [`Uint64`](#type-uint64) - Unique protocol ID.

*   `name`: `string` - Readable protocol name.

*   `support_versions`: `Array<` `string` `>` - Supported versions.

    See [Semantic Version](https://semver.org/) about how to specify a version.


### Type `MerkleProof`

Proof of CKB Merkle Tree.

CKB Merkle Tree is a [CBMT](https://github.com/nervosnetwork/rfcs/blob/master/rfcs/0006-merkle-tree/0006-merkle-tree.md) using CKB blake2b hash as the merge function.

#### Fields

`MerkleProof` is a JSON object with the following fields.

*   `indices`: `Array<` [`Uint32`](#type-uint32) `>` - Leaves indices in the CBMT that are proved present in the block.

    These are indices in the CBMT tree not the transaction indices in the block.

*   `lemmas`: `Array<` [`H256`](#type-h256) `>` - Hashes of all siblings along the paths to root.


### Type `MinerReward`

Block rewards for miners.

#### Fields

`MinerReward` is a JSON object with the following fields.

*   `primary`: [`Capacity`](#type-capacity) - The primary base block reward allocated to miners.

*   `secondary`: [`Capacity`](#type-capacity) - The secondary base block reward allocated to miners.

*   `committed`: [`Capacity`](#type-capacity) - The transaction fees that are rewarded to miners because the transaction is committed in the block.

    Miners get 60% of the transaction fee for each transaction committed in the block.

*   `proposal`: [`Capacity`](#type-capacity) - The transaction fees that are rewarded to miners because the transaction is proposed in the block or its uncles.

    Miners get 40% of the transaction fee for each transaction proposed in the block and committed later in its active commit window.


### Type `NodeAddress`

Node P2P address and score.

#### Fields

`NodeAddress` is a JSON object with the following fields.

*   `address`: `string` - P2P address.

    This is the same address used in the whitelist in ckb.toml.

    Example: "/ip4/192.168.0.2/tcp/8112/p2p/QmTRHCdrRtgUzYLNCin69zEvPvLYdxUZLLfLYyHVY3DZAS"

*   `score`: [`Uint64`](#type-uint64) - Address score.

    A higher score means a higher probability of a successful connection.


### Type `OutPoint`

Reference to a cell via transaction hash and output index.

#### Examples


```
{
  "index": "0x0",
  "tx_hash": "0x365698b50ca0da75dca2c87f9e7b563811d3b5813736b8cc62cc3b106faceb17"
}
```


#### Fields

`OutPoint` is a JSON object with the following fields.

*   `tx_hash`: [`H256`](#type-h256) - Transaction hash in which the cell is an output.

*   `index`: [`Uint32`](#type-uint32) - The output index of the cell in the transaction specified by `tx_hash`.


### Type `OutputsValidator`

Transaction output validators that prevent common mistakes.

`OutputsValidator` is equivalent to `"default" | "passthrough"`.

*   "default": The default validator which restricts the lock script and type script usage.
*   "passthrough": bypass the validator, thus allow any kind of transaction outputs.


### Type `PeerSyncState`

The chain synchronization state between the local node and a remote node.

#### Fields

`PeerSyncState` is a JSON object with the following fields.

*   `best_known_header_hash`: [`Byte32`](#type-byte32) `|` `null` - Best known header hash of remote peer.

    This is the observed tip of the remote node's canonical chain.

*   `best_known_header_number`: [`Uint64`](#type-uint64) `|` `null` - Best known header number of remote peer

    This is the block number of the block with the hash `best_known_header_hash`.

*   `last_common_header_hash`: [`Byte32`](#type-byte32) `|` `null` - Last common header hash of remote peer.

    This is the common ancestor of the local node canonical chain tip and the block `best_known_header_hash`.

*   `last_common_header_number`: [`Uint64`](#type-uint64) `|` `null` - Last common header number of remote peer.

    This is the block number of the block with the hash `last_common_header_hash`.

*   `unknown_header_list_size`: [`Uint64`](#type-uint64) - The total size of unknown header list.

    **Deprecated**: this is an internal state and will be removed in a future release.

*   `inflight_count`: [`Uint64`](#type-uint64) - The count of concurrency downloading blocks.

*   `can_fetch_count`: [`Uint64`](#type-uint64) - The count of blocks are available for concurrency download.


### Type `PoolTransactionEntry`

The transaction entry in the pool.

#### Fields

`PoolTransactionEntry` is a JSON object with the following fields.

*   `transaction`: [`TransactionView`](#type-transactionview) - The transaction.

*   `cycles`: [`Cycle`](#type-cycle) - Consumed cycles.

*   `size`: [`Uint64`](#type-uint64) - The transaction serialized size in block.

*   `fee`: [`Capacity`](#type-capacity) - The transaction fee.


### Type `PoolTransactionReject`

TX reject message

`PoolTransactionReject` is a JSON object with following fields.

*   `type`: `"LowFeeRate" | "ExceededMaximumAncestorsCount" | "Full" | "Duplicated" | "Malformed" | "Resolve" | "Verification"` - Reject type.
*   `description`: `string` - Detailed description about why the transaction is rejected.

Different reject types:

*   `LowFeeRate`: Transaction fee lower than config
*   `ExceededMaximumAncestorsCount`: Transaction exceeded maximum ancestors count limit
*   `Full`: Transaction pool exceeded maximum size or cycles limit,
*   `Duplicated`: Transaction already exist in transaction_pool
*   `Malformed`: Malformed transaction
*   `Resolve`: Resolve failed
*   `Verification`: Verification failed


### Type `ProposalShortId`

The 10-byte fixed-length binary encoded as a 0x-prefixed hex string in JSON.

#### Example

```
0xa0ef4eb5f4ceeb08a4c8
```



### Type `ProposalWindow`

Two protocol parameters `closest` and `farthest` define the closest and farthest on-chain distance between a transaction's proposal and commitment.

A non-cellbase transaction is committed at height h_c if all of the following conditions are met:

*   it is proposed at height h_p of the same chain, where w_close <= h_c − h_p <= w_far ;

*   it is in the commitment zone of the main chain block with height h_c ;

```
  ProposalWindow { closest: 2, farthest: 10 }
      propose
         \
          \
          13 14 [15 16 17 18 19 20 21 22 23]
                 \_______________________/
                              \
                            commit
```

#### Fields

`ProposalWindow` is a JSON object with the following fields.

*   `closest`: [`BlockNumber`](#type-blocknumber) - The closest distance between the proposal and the commitment.

*   `farthest`: [`BlockNumber`](#type-blocknumber) - The farthest distance between the proposal and the commitment.


### Type `RationalU256`

The ratio which numerator and denominator are both 256-bit unsigned integers.

#### Example

```
{
    "denom": "0x28",
    "numer": "0x1"
}
```


### Type `RawTxPool`

All transactions in tx-pool.

`RawTxPool` is equivalent to [`TxPoolIds`](#type-txpoolids) `|` [`TxPoolVerbosity`](#type-txpoolverbosity).

### Type `RemoteNode`

Information of a remote node.

A remote node connects to the local node via the P2P network. It is often called a peer.

#### Examples


```
{
  "addresses": [
    {
      "address": "/ip6/::ffff:18.185.102.19/tcp/8115/p2p/QmXwUgF48ULy6hkgfqrEwEfuHW7WyWyWauueRDAYQHNDfN",
      "score": "0x64"
    },
    {
      "address": "/ip4/18.185.102.19/tcp/8115/p2p/QmXwUgF48ULy6hkgfqrEwEfuHW7WyWyWauueRDAYQHNDfN",
      "score": "0x64"
    }
  ],
  "connected_duration": "0x2f",
  "is_outbound": true,
  "last_ping_duration": "0x1a",
  "node_id": "QmXwUgF48ULy6hkgfqrEwEfuHW7WyWyWauueRDAYQHNDfN",
  "protocols": [
    {
      "id": "0x4",
      "version": "0.0.1"
    },
    {
      "id": "0x2",
      "version": "0.0.1"
    },
    {
      "id": "0x1",
      "version": "0.0.1"
    },
    {
      "id": "0x64",
      "version": "1"
    },
    {
      "id": "0x6e",
      "version": "1"
    },
    {
      "id": "0x66",
      "version": "1"
    },
    {
      "id": "0x65",
      "version": "1"
    },
    {
      "id": "0x0",
      "version": "0.0.1"
    }
  ],
  "sync_state": {
    "best_known_header_hash": null,
    "best_known_header_number": null,
    "can_fetch_count": "0x80",
    "inflight_count": "0xa",
    "last_common_header_hash": null,
    "last_common_header_number": null,
    "unknown_header_list_size": "0x20"
  },
  "version": "0.34.0 (f37f598 2020-07-17)"
}
```


#### Fields

`RemoteNode` is a JSON object with the following fields.

*   `version`: `string` - The remote node version.

*   `node_id`: `string` - The remote node ID which is derived from its P2P private key.

*   `addresses`: `Array<` [`NodeAddress`](#type-nodeaddress) `>` - The remote node addresses.

*   `is_outbound`: `boolean` - Whether this is an outbound remote node.

    If the connection is established by the local node, `is_outbound` is true.

*   `connected_duration`: [`Uint64`](#type-uint64) - Elapsed time in seconds since the remote node is connected.

*   `last_ping_duration`: [`Uint64`](#type-uint64) `|` `null` - Elapsed time in milliseconds since receiving the ping response from this remote node.

    Null means no ping responses have been received yet.

*   `sync_state`: [`PeerSyncState`](#type-peersyncstate) `|` `null` - Chain synchronization state.

    Null means chain sync has not started with this remote node yet.

*   `protocols`: `Array<` [`RemoteNodeProtocol`](#type-remotenodeprotocol) `>` - Active protocols.

    CKB uses Tentacle multiplexed network framework. Multiple protocols are running simultaneously in the connection.


### Type `RemoteNodeProtocol`

The information about an active running protocol.

#### Fields

`RemoteNodeProtocol` is a JSON object with the following fields.

*   `id`: [`Uint64`](#type-uint64) - Unique protocol ID.

*   `version`: `string` - Active protocol version.


### Type `Script`

Describes the lock script and type script for a cell.

#### Examples


```
{
  "args": "0x",
  "code_hash": "0x28e83a1277d48add8e72fadaa9248559e1b632bab2bd60b27955ebc4c03800a5",
  "hash_type": "data"
}
```


#### Fields

`Script` is a JSON object with the following fields.

*   `code_hash`: [`H256`](#type-h256) - The hash used to match the script code.

*   `hash_type`: [`ScriptHashType`](#type-scripthashtype) - Specifies how to use the `code_hash` to match the script code.

*   `args`: [`JsonBytes`](#type-jsonbytes) - Arguments for script.


### Type `ScriptHashType`

Specifies how the script `code_hash` is used to match the script code.

Allowed values: "data" and "type".

Refer to the section [Code Locating](https://github.com/nervosnetwork/rfcs/blob/master/rfcs/0022-transaction-structure/0022-transaction-structure.md#code-locating) and [Upgradable Script](https://github.com/nervosnetwork/rfcs/blob/master/rfcs/0022-transaction-structure/0022-transaction-structure.md#upgradable-script) in the RFC *CKB Transaction Structure*.

`ScriptHashType` is equivalent to `"data" | "type"`.

*   Type "data" matches script code via cell data hash.
*   Type "type" matches script code via cell type script hash.


### Type `SerializedBlock`

This is a 0x-prefix hex string. It is the block serialized by molecule using the schema `table Block`.

### Type `SerializedHeader`

This is a 0x-prefix hex string. It is the block header serialized by molecule using the schema `table Header`.

### Type `Status`

Status for transaction

`Status` is equivalent to `"pending" | "proposed" | "committed"`.

*   Status "pending". The transaction is in the pool, and not proposed yet.
*   Status "proposed". The transaction is in the pool and has been proposed.
*   Status "committed". The transaction has been committed to the canonical chain.


### Type `SyncState`

The overall chain synchronization state of this local node.

#### Fields

`SyncState` is a JSON object with the following fields.

*   `ibd`: `boolean` - Whether the local node is in IBD, Initial Block Download.

    When a node starts and its chain tip timestamp is far behind the wall clock, it will enter the IBD until it catches up the synchronization.

    During IBD, the local node only synchronizes the chain with one selected remote node and stops responding to most P2P requests.

*   `best_known_block_number`: [`BlockNumber`](#type-blocknumber) - This is the best known block number observed by the local node from the P2P network.

    The best here means that the block leads a chain which has the best known accumulated difficulty.

    This can be used to estimate the synchronization progress. If this RPC returns B, and the RPC `get_tip_block_number` returns T, the node has already synchronized T/B blocks.

*   `best_known_block_timestamp`: [`Timestamp`](#type-timestamp) - This is timestamp of the same block described in `best_known_block_number`.

*   `orphan_blocks_count`: [`Uint64`](#type-uint64) - Count of orphan blocks the local node has downloaded.

    The local node downloads multiple blocks simultaneously but blocks must be connected consecutively. If a descendant is downloaded before its ancestors, it becomes an orphan block.

    If this number is too high, it indicates that block download has stuck at some block.

*   `inflight_blocks_count`: [`Uint64`](#type-uint64) - Count of downloading blocks.

*   `fast_time`: [`Uint64`](#type-uint64) - The download scheduler's time analysis data, the fast is the 1/3 of the cut-off point, unit ms

*   `normal_time`: [`Uint64`](#type-uint64) - The download scheduler's time analysis data, the normal is the 4/5 of the cut-off point, unit ms

*   `low_time`: [`Uint64`](#type-uint64) - The download scheduler's time analysis data, the low is the 9/10 of the cut-off point, unit ms


### Type `Timestamp`

The Unix timestamp in milliseconds (1 second is 1000 milliseconds).

For example, 1588233578000 is Thu, 30 Apr 2020 07:59:38 +0000

This is a 64-bit unsigned integer type encoded as the 0x-prefixed hex string in JSON. See examples of [Uint64](#type-uint64).

### Type `Transaction`

The transaction.

Refer to RFC [CKB Transaction Structure](https://github.com/nervosnetwork/rfcs/blob/master/rfcs/0022-transaction-structure/0022-transaction-structure.md).

#### Fields

`Transaction` is a JSON object with the following fields.

*   `version`: [`Version`](#type-version) - Reserved for future usage. It must equal 0 in current version.

*   `cell_deps`: `Array<` [`CellDep`](#type-celldep) `>` - An array of cell deps.

    CKB locates lock script and type script code via cell deps. The script also can uses syscalls to read the cells here.

    Unlike inputs, the live cells can be used as cell deps in multiple transactions.

*   `header_deps`: `Array<` [`H256`](#type-h256) `>` - An array of header deps.

    The block must already be in the canonical chain.

    Lock script and type script can read the header information of blocks listed here.

*   `inputs`: `Array<` [`CellInput`](#type-cellinput) `>` - An array of input cells.

    In the canonical chain, any cell can only appear as an input once.

*   `outputs`: `Array<` [`CellOutput`](#type-celloutput) `>` - An array of output cells.

*   `outputs_data`: `Array<` [`JsonBytes`](#type-jsonbytes) `>` - Output cells data.

    This is a parallel array of outputs. The cell capacity, lock, and type of the output i is `outputs[i]` and its data is `outputs_data[i]`.

*   `witnesses`: `Array<` [`JsonBytes`](#type-jsonbytes) `>` - An array of variable-length binaries.

    Lock script and type script can read data here to verify the transaction.

    For example, the bundled secp256k1 lock script requires storing the signature in `witnesses`.


### Type `TransactionProof`

Merkle proof for transactions in a block.

#### Fields

`TransactionProof` is a JSON object with the following fields.

*   `block_hash`: [`H256`](#type-h256) - Block hash

*   `witnesses_root`: [`H256`](#type-h256) - Merkle root of all transactions' witness hash

*   `proof`: [`MerkleProof`](#type-merkleproof) - Merkle proof of all transactions' hash


### Type `TransactionTemplate`

Transaction template which is ready to be committed in the new block.

#### Fields

`TransactionTemplate` is a JSON object with the following fields.

*   `hash`: [`H256`](#type-h256) - Transaction hash.

*   `required`: `boolean` - Whether miner must include this transaction in the new block.

*   `cycles`: [`Cycle`](#type-cycle) `|` `null` - The hint of how many cycles this transaction consumes.

    Miners can utilize this field to ensure that the total cycles do not exceed the limit while selecting transactions.

*   `depends`: `Array<` [`Uint64`](#type-uint64) `>` `|` `null` - Transaction dependencies.

    This is a hint to help miners selecting transactions.

    This transaction can only be committed if its dependencies are also committed in the new block.

    This field is a list of indices into the array `transactions` in the block template.

    For example, `depends = [1, 2]` means this transaction depends on `block_template.transactions[1]` and `block_template.transactions[2]`.

*   `data`: [`Transaction`](#type-transaction) - The transaction.

    Miners must keep it unchanged when including it in the new block.


### Type `TransactionView`

The JSON view of a Transaction.

This structure is serialized into a JSON object with field `hash` and all the fields in [`Transaction`](#type-transaction).

#### Examples


```
{
  "cell_deps": [
    {
      "dep_type": "code",
      "out_point": {
        "index": "0x0",
        "tx_hash": "0xa4037a893eb48e18ed4ef61034ce26eba9c585f15c9cee102ae58505565eccc3"
      }
    }
  ],
  "hash": "0xa0ef4eb5f4ceeb08a4c8524d84c5da95dce2f608e0ca2ec8091191b0f330c6e3",
  "header_deps": [
    "0x7978ec7ce5b507cfb52e149e36b1a23f6062ed150503c85bbf825da3599095ed"
  ],
  "inputs": [
    {
      "previous_output": {
        "index": "0x0",
        "tx_hash": "0x365698b50ca0da75dca2c87f9e7b563811d3b5813736b8cc62cc3b106faceb17"
      },
      "since": "0x0"
    }
  ],
  "outputs": [
    {
      "capacity": "0x2540be400",
      "lock": {
        "args": "0x",
        "code_hash": "0x28e83a1277d48add8e72fadaa9248559e1b632bab2bd60b27955ebc4c03800a5",
        "hash_type": "data"
      },
      "type": null
    }
  ],
  "outputs_data": [
    "0x"
  ],
  "version": "0x0",
  "witnesses": []
}
```


#### Fields

`TransactionView` is a JSON object with the following fields.

*   `inner`: [`Transaction`](#type-transaction) - All the fields in `Transaction` are included in `TransactionView` in JSON.

*   `hash`: [`H256`](#type-h256) - The transaction hash.


### Type `TransactionWithStatus`

The JSON view of a transaction as well as its status.

#### Fields

`TransactionWithStatus` is a JSON object with the following fields.

*   `transaction`: [`TransactionView`](#type-transactionview) - The transaction.

*   `tx_status`: [`TxStatus`](#type-txstatus) - The Transaction status.


### Type `TxPoolIds`

Array of transaction ids

#### Fields

`TxPoolIds` is a JSON object with the following fields.

*   `pending`: `Array<` [`H256`](#type-h256) `>` - Pending transaction ids

*   `proposed`: `Array<` [`H256`](#type-h256) `>` - Proposed transaction ids


### Type `TxPoolInfo`

Transaction pool information.

#### Fields

`TxPoolInfo` is a JSON object with the following fields.

*   `tip_hash`: [`H256`](#type-h256) - The associated chain tip block hash.

    The transaction pool is stateful. It manages the transactions which are valid to be committed after this block.

*   `tip_number`: [`BlockNumber`](#type-blocknumber) - The block number of the block `tip_hash`.

*   `pending`: [`Uint64`](#type-uint64) - Count of transactions in the pending state.

    The pending transactions must be proposed in a new block first.

*   `proposed`: [`Uint64`](#type-uint64) - Count of transactions in the proposed state.

    The proposed transactions are ready to be committed in the new block after the block `tip_hash`.

*   `orphan`: [`Uint64`](#type-uint64) - Count of orphan transactions.

    An orphan transaction has an input cell from the transaction which is neither in the chain nor in the transaction pool.

*   `total_tx_size`: [`Uint64`](#type-uint64) - Total count of transactions in the pool of all the different kinds of states.

*   `total_tx_cycles`: [`Uint64`](#type-uint64) - Total consumed VM cycles of all the transactions in the pool.

*   `min_fee_rate`: [`Uint64`](#type-uint64) - Fee rate threshold. The pool rejects transactions which fee rate is below this threshold.

    The unit is Shannons per 1000 bytes transaction serialization size in the block.

*   `last_txs_updated_at`: [`Timestamp`](#type-timestamp) - Last updated time. This is the Unix timestamp in milliseconds.


### Type `TxPoolVerbosity`

Tx-pool verbose object

#### Fields

`TxPoolVerbosity` is a JSON object with the following fields.

*   `pending`: `{ [ key:` [`H256`](#type-h256) `]: ` [`TxVerbosity`](#type-txverbosity) `}` - Pending tx verbose info

*   `proposed`: `{ [ key:` [`H256`](#type-h256) `]: ` [`TxVerbosity`](#type-txverbosity) `}` - Proposed tx verbose info


### Type `TxStatus`

Transaction status and the block hash if it is committed.

#### Fields

`TxStatus` is a JSON object with the following fields.

*   `status`: [`Status`](#type-status) - The transaction status, allowed values: "pending", "proposed" and "committed".

*   `block_hash`: [`H256`](#type-h256) `|` `null` - The block hash of the block which has committed this transaction in the canonical chain.


### Type `TxVerbosity`

Transaction verbose info

#### Fields

`TxVerbosity` is a JSON object with the following fields.

*   `cycles`: [`Uint64`](#type-uint64) - Consumed cycles.

*   `size`: [`Uint64`](#type-uint64) - The transaction serialized size in block.

*   `fee`: [`Capacity`](#type-capacity) - The transaction fee.

*   `ancestors_size`: [`Uint64`](#type-uint64) - Size of in-tx-pool ancestor transactions

*   `ancestors_cycles`: [`Uint64`](#type-uint64) - Cycles of in-tx-pool ancestor transactions

*   `ancestors_count`: [`Uint64`](#type-uint64) - Number of in-tx-pool ancestor transactions


### Type `U256`

The 256-bit unsigned integer type encoded as the 0x-prefixed hex string in JSON.

### Type `Uint128`

The  128-bit unsigned integer type encoded as the 0x-prefixed hex string in JSON.

#### Examples

|  JSON | Decimal Value |
| --- |--- |
|  "0x0" | 0 |
|  "0x10" | 16 |
|  "10" | Invalid, 0x is required |
|  "0x01" | Invalid, redundant leading 0 |

### Type `Uint32`

The  32-bit unsigned integer type encoded as the 0x-prefixed hex string in JSON.

#### Examples

|  JSON | Decimal Value |
| --- |--- |
|  "0x0" | 0 |
|  "0x10" | 16 |
|  "10" | Invalid, 0x is required |
|  "0x01" | Invalid, redundant leading 0 |

### Type `Uint64`

The  64-bit unsigned integer type encoded as the 0x-prefixed hex string in JSON.

#### Examples

|  JSON | Decimal Value |
| --- |--- |
|  "0x0" | 0 |
|  "0x10" | 16 |
|  "10" | Invalid, 0x is required |
|  "0x01" | Invalid, redundant leading 0 |

### Type `UncleBlock`

The uncle block used as a parameter in the RPC.

The chain stores only the uncle block header and proposal IDs. The header ensures the block is covered by PoW and can pass the consensus rules on uncle blocks. Proposal IDs are there because a block can commit transactions proposed in an uncle.

A block B1 is considered to be the uncle of another block B2 if all the following conditions are met:

*   They are in the same epoch, sharing the same difficulty;

*   B2 block number is larger than B1;

*   B1's parent is either B2's ancestor or an uncle embedded in B2 or any of B2's ancestors.

*   B2 is the first block in its chain to refer to B1.

#### Fields

`UncleBlock` is a JSON object with the following fields.

*   `header`: [`Header`](#type-header) - The uncle block header.

*   `proposals`: `Array<` [`ProposalShortId`](#type-proposalshortid) `>` - Proposal IDs in the uncle block body.


### Type `UncleBlockView`

The uncle block.

The chain stores only the uncle block header and proposal IDs. The header ensures the block is covered by PoW and can pass the consensus rules on uncle blocks. Proposal IDs are there because a block can commit transactions proposed in an uncle.

A block B1 is considered to be the uncle of another block B2 if all the following conditions are met:

*   They are in the same epoch, sharing the same difficulty;

*   B2 block number is larger than B1;

*   B1's parent is either B2's ancestor or an uncle embedded in B2 or any of B2's ancestors.

*   B2 is the first block in its chain to refer to B1.

#### Fields

`UncleBlockView` is a JSON object with the following fields.

*   `header`: [`HeaderView`](#type-headerview) - The uncle block header.

*   `proposals`: `Array<` [`ProposalShortId`](#type-proposalshortid) `>` - Proposal IDs in the uncle block body.


### Type `UncleTemplate`

The uncle block template of the new block for miners.

#### Fields

`UncleTemplate` is a JSON object with the following fields.

*   `hash`: [`H256`](#type-h256) - The uncle block hash.

*   `required`: `boolean` - Whether miners must include this uncle in the submit block.

*   `proposals`: `Array<` [`ProposalShortId`](#type-proposalshortid) `>` - The proposals of the uncle block.

    Miners must keep this unchanged when including this uncle in the new block.

*   `header`: [`Header`](#type-header) - The header of the uncle block.

    Miners must keep this unchanged when including this uncle in the new block.


### Type `Version`

The simple increasing integer version.

This is a 32-bit unsigned integer type encoded as the 0x-prefixed hex string in JSON. See examples of [Uint32](#type-uint32).