-
-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathv2.9.0.yaml
2166 lines (1888 loc) · 85.8 KB
/
v2.9.0.yaml
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
openapi: 3.0.0
servers:
- url: http://localhost:1442/
info:
title: Kupo
version: v2.9.0
license:
name: MPL-2.0
url: https://raw.githubusercontent.com/cardanosolutions/kupo/master/LICENSE
x-logo:
url: ./kupo.png
altText: Kupo!
description: |
> **Disclaimer**
>
> This version of the documentation might contain features that **haven't been**
> **released yet**. This is meant to preview what's coming.
>
> If you're using a specific version, please refer to the appropriate
> documentation's revision as well _(see buttons at the top)_.
# Overview
**Kupo** is fast, lightweight and configurable **chain-index** for the Cardano blockchain. It synchronizes data from the blockchain according to **patterns** matching addresses present in transaction outputs and builds a **lookup table** from matches to their associated **output references**, **values**, **datums** and **scripts**.
# Installation
## From pre-compiled executables
Pre-compiled static binaries can be downloaded as build artifacts from
[latest releases](https://github.com/CardanoSolutions/kupo/releases) or the
continuous [`Nix` Github workflow](https://github.com/CardanoSolutions/kupo/actions).
```
kupo-{x.y.z}-{arch}-{os}.tar.gz
│
├── bin
│ └── kupo
│
└── share
├── kupo
│ ├── LICENSE
│ └── api.yaml
│
├── bash-completion
│ └── completions
│ └── kupo
├── zsh
│ └── site-functions
│ └── _kupo
│
└── man
└── man1
└── kupo.1
```
Once installed, `man kupo` or `kupo --help` comes in handy.
## From docker
Kupo is available as a standalone Docker image on [DockerHub](https://hub.docker.com/repository/docker/cardanosolutions/kupo).
```console
$ docker pull cardanosolutions/kupo
```
## From source
### Pre-requisite
On Linux, make sure to have [nix](https://nixos.org/download.html#nix-install-linux) and [cachix](https://www.cachix.org/) installed.
Configure cachix to use `kupo.cachix.org-1:RzYQ8KVjRJdPNt/Bhq/UqdyGYWFM8ShjEMNG8wzHBQ4=` (`cachix use kupo`).
On MacOS, you'll need `cabal` as well as a few system dependencies. Follow the [instructions to install `cardano-node` on the developer portal](https://developers.cardano.org/docs/get-started/installing-cardano-node#macos) since Kupo share a similar set of dependencies.
### Building
```console
$ make
```
# Getting started
Kupo connects to a _local [cardano-node](https://github.com/input-output-hk/cardano-node/)_
in order to receive information from the blockchain. It goes without saying
that an up-and-running cardano-node (or an equivalent Ogmios connection) is
required to run Kupo!
A single Kupo server is meant to build an index for a specific set of outputs.
Outputs are matched according to flexible patterns. Once
matched, results can be queried as JSON via HTTP GET requests. For
instance, it is possible to synchronize all addresses associated with a
given stake key (e.g. `stake_vkh14hkp0sncfkt76spuqydtww4r900hfmsseezztzlh9sjkkjx6d7q`).
Provided that the configuration and IPC socket for a cardano-node are
available in `some-folder/cardano-node`, one can start a Kupo server as
follows:
```console
$ kupo \
--node-socket some-folder/cardano-node/node.socket \
--node-config some-folder/cardano-node/config.json \
--since origin \
--defer-db-indexes \
--match "*/stake_vkh14hkp0sncfkt76spuqydtww4r900hfmsseezztzlh9sjkkjx6d7q" \
--in-memory
```
## --in-memory / --workdir {dir}
This will build an index from the beginning of the blockchain (i.e.`origin`)
of all transaction outputs where that stake key has been involved in. The
`--in-memory` option tells Kupo to not persist the index on-disk but to
build it fully in-memory. When building such a large index (from origin!),
this is not recommended as it may cause the program memory usage to grow
unbounded.
Let's fix that:
```console
$ kupo \
--node-socket some-folder/cardano-node/node.socket \
--node-config some-folder/cardano-node/config.json \
--since origin \
--defer-db-indexes \
--match "*/stake_vkh14hkp0sncfkt76spuqydtww4r900hfmsseezztzlh9sjkkjx6d7q" \
--workdir ./db
```
Perfect, now Kupo will store all the information in a database on-disk at
the location pointed by `--workdir`. Incidentally, this also allows Kupo to
resume its work from where it lefts it in case the server is interrupted.
Neat!
## --since {slot-no.header_hash}
What if we only need to synchronize from a given point in time? For
example, we may want to skip the entire Byron and Shelley eras because we
know that this stake key may only have been used starting from the Allegra
era onwards. Fortunately, we can use the `--since` to provide a different
starting point!
```console
$ kupo \
--node-socket some-folder/cardano-node/node.socket \
--node-config some-folder/cardano-node/config.json \
--since 16588737.4e9bbbb67e3ae262133d94c3da5bffce7b1127fc436e7433b87668dba34c354a \
--defer-db-indexes \
--match "*/stake_vkh14hkp0sncfkt76spuqydtww4r900hfmsseezztzlh9sjkkjx6d7q" \
--workdir ./db
```
Points are given as `{slot_no}.{header_hash}` and define an exclusive
boundary. Said differently, Kupo will start synchronizing from the **next**
block **following the given point**. In case you need them, see the section
[#era-boundaries] which references points at which era ends for mainnet and
testnet; useful to start syncing from a specific era.
> <sup><strong>TIP</strong></sup> <br/>
> If you just want to start synchronize from _now_, you can pass simply
> pass <code>tip</code> as a value (i.e. `--since tip`).
## --match {pattern}
Kupo can accept one or more matching patterns using the `--match` option.
In case multiple patterns are provided, they'll ALL be used when looking
for addresses. This allows for example to build an index for a list of
payment keys known of a wallet. The syntax for patterns is explained in
greater details in the [Patterns](#section/Patterns) section below.
## --defer-db-indexes
The careful reader that you are would have noticed the `--defer-db-indexes`
flag that we've been passing around. This is a little trick to speed up the
initial indexer synchronization. Indeed, when synchronizing over large chunks
of the chain, Kupo needs to ingest and filter a lot of data. Later, to serve
this data back through structured queries, Kupo leverages fast lookup indexes
in the database. Yet, lookup indexes come with a little extra cost for writing
stuff into the database.
Deferring the creation of indexes only to when you'll need to query therefore
comes in handy and can reduce overall synchronization time by a factor of 2 or
3. The creation of each index is relatively fast (few seconds to a couple of
minutes) and can therefore happen only after a full synchronization by restarting
Kupo without the `--defer-db-indexes` flag.
## --prune-utxo
Sometimes, it isn't necessary to keep old data around. Fear not, Kupo has
got you covered! Using the `--prune-utxo` command-line flag, you can
instrument Kupo to automatically remove inputs that are spent on-chain.
This makes sure to keep only what's truly available on-chain and has a
positive effect on both the final size of the index and the synchronization
time. If you don't set that flag, then all data are kept in the database
and spent inputs are instead marked to know if and when they were spent.
Note that spent inputs aren't removed immediately but only after _at least_
36h (or 2160 guaranteed blocks). This is because data on-chain only becomes
truly immutable after 2160 blocks (though it is stable with a high probability
much before that).
You can then use query flags in the API (`?spent` or `?unspent`) to filter
results based on whether or not they've been spent.
## --ogmios-host {hostname} / --ogmios-port {port-number}
So far, we've connected Kupo to a local cardano-node, using a unix domain
socket as a communication channel. However, Kupo can also connect through
[Ogmios](https://github.com/CardanoSolutions/ogmios#readme); and this works
for either a local or remote instance of Ogmios! To do so, simply swap the
`--node-socket` and `--node-config` options for `--ogmios-host` and
`--ogmios-port`.
For example:
```console
$ kupo \
--ogmios-host my-ogmios-server.io \
--ogmios-port 443 \
--since 16588737.4e9bbbb67e3ae262133d94c3da5bffce7b1127fc436e7433b87668dba34c354a \
--match "*/stake_vkh14hkp0sncfkt76spuqydtww4r900hfmsseezztzlh9sjkkjx6d7q" \
--workdir ./db
```
Kupo will synchronize data directly from Ogmios! Neat isn't it?
## --hydra-host {hostname} / --hydra-port {port-number}
Kupo can also be used to index the layer two ledger available in a
[Hydra](https://github.com/input-output-hk/hydra/#readme) head. For this, we
need to use `--hydra-host` and `--hydra-port` to point to a machine running
a `hydra-node` of a head you want to index and the port of the websocket
API.
For example:
```console
$ kupo \
--hydra-host 0.0.0.0 \
--hydra-port 4001 \
--since origin \
--match * \
--workdir ./db
```
## --help
In case you're lost, don't forget that a summary of this manual is available by running:
```console
$ kupo --help
```
Should you have installed Kupo using the pre-packaged archive from releases, you should also have
access to the user manual through
```console
$ man kupo
```
# Patterns
## Overview
Kupo can construct patterns from pretty much every constituant of an
address, an asset id or an output reference, in any kind of format
(bech32, base16, base58, you name it!).
It also accepts wildcards using the asterisk symbol `*` in certain places.
Conceptually, patterns match the logical structure of addresses, asset ids
or output references. Each are divided in two parts:
- for addresses: a payment part and a delegation part, separated by a `/`;
- for asset ids: a policy id and an asset name, separated by a `.`;
- for output references: an output index and a transaction id, separated by a `@`
> **Note**
>
> To learn more about Cardano addresses, feel free to look [CIP-0019](https://github.com/cardano-foundation/CIPs/tree/master/CIP-0019#readme)
for a deep dive!
Here below is summarized the general syntax for valid patterns. Note that
different patterns may match the same object. By convention `*` will match
_any Cardano address (Byron included)_, whereby `*/*` will match only
Shelley-based addresses (since legacy Byron addresses do not have any
delegation part!).
```
PATTERN =
┏━━━━━━━━━┓
╾┬─┫ ADDRESS ┣───────────────────────────────┬╼
│ ┗━━━━━━━━━┛ │
│ ┏━━━━━━━━━━━━┓ ╭───╮ ┏━━━━━━━━━━━━┓ │
├─┫ CREDENTIAL ┣───┤ / ├─┫ CREDENTIAL ┣─────┤
│ ┗━━━━━━━━━━━━┛ ╰───╯ ┗━━━━━━━━━━━━┛ │
│ ┏━━━━━━━━━━━┓ ╭───╮ ┏━━━━━━━━━━━━┓ │
├─┫ POLICY_ID ┣────┤ . ├─┫ ASSET_NAME ┣─────┤
│ ┗━━━━━━━━━━━┛ ╰───╯ ┗━━━━━━━━━━━━┛ │
│ ┏━━━━━━━━━━━━━━┓ ╭───╮ ┏━━━━━━━━━━━━━━━━┓ │
├─┫ OUTPUT_INDEX ┣─┤ @ ├─┫ TRANSACTION_ID ┣─┤
│ ┗━━━━━━━━━━━━━━┛ ╰───╯ ┗━━━━━━━━━━━━━━━━┛ │
│ ┏━━━━━━━━━━━━━━┓ │
└─┫ METADATA_TAG ┣──────────────────────────┘
┗━━━━━━━━━━━━━━┛
```
## Address
```
ADDRESS =
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
╾┬─┫ ADDRESS OR LEGACY ADDRESS ┣─────────────┬╼
│ ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ │
│ ┏━━━━━━━━━━━━━━━┓ │
├─┫ STAKE ADDRESS ┣─────────────────────────┤
│ ┗━━━━━━━━━━━━━━━┛ │
│ ╭───╮ │
└─┤ * ├─────────────────────────────────────┘
╰───╯
```
### Examples
| Pattern | Description |
| --- | --- |
| `addr1vyc29pvl2uyzqt8nwxrcxnf558ffm27u3d9calxn8tdudjgz4xq9p` | Outputs to a specific address |
| `stake1vyc29pvl2uyzqt8nwxrcxnf558ffm27u3d9calxn8tdudjgydsx9n` | Outputs whose address is delegated to a specific stake address |
| `*` | Any output (incl. to legacy addresses) |
## Credential
```
CREDENTIAL =
┏━━━━━━━━━━━┓
╾┬─┫ 64 HEXDIG ┣───────────────────────────────────────────┬╼
│ ┗━━━━━━━━━━━┛ │
│ ┏━━━━━━━━━━━━━━━━━━━━━━━━━┓ ┏━━━━━━━━━━━━┓ │
├─┫ vk / addr_vk / stake_vk ┣──────────────┫ *BECH32DIG ┣─┤
│ ┗━━━━━━━━━━━━━━━━━━━━━━━━━┛ ┗━━━━━━━━━━━━┛ │
│ ┏━━━━━━━━━━━┓ │
├─┫ 56 HEXDIG ┣───────────────────────────────────────────┤
│ ┗━━━━━━━━━━━┛ │
│ ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ ┏━━━━━━━━━━━━┓ │
├─┫ vkh / addr_vkh / stake_vkh / script ┣──┫ *BECH32DIG ┣─┤
│ ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ ┗━━━━━━━━━━━━┛ │
│ ╭───╮ │
└─┤ * ├───────────────────────────────────────────────────┘
╰───╯
HEXDIG = %x30–39 / %x41-%46
BECH32DIG = %x61 / %x63-68 / %x6A-6E / %x70-7A / 0-9
```
### Examples
Examples below are given for patterns in the form of `CREDENTIAL / CREDENTIAL` since a `CREDENTIAL` is never specified alone.
| Pattern | Description |
| --- | --- |
| `*/*` | Any output to a Shelley-based address |
| `addr_vk1x7da0l25j04my8sej5ntrgdn38wmshxhplxdfjskn07ufavsgtkqn5hljl/*` | Outputs whose address carries a specific payment key (bech32 encoded) |
| `dca1e44765b9f80c8b18105e17de90d4a07e4d5a83de533e53fee32e0502d17e/*` | Outputs whose address carries a specific payment key (hex encoded) |
| `*/script1cda3khwqv60360rp5m7akt50m6ttapacs8rqhn5w342z7r35m37` | Outputs whose stake is governed by a specific script |
## Asset id
```
POLICY_ID = ASSET_NAME =
┏━━━━━━━━━━━┓ ┏━━━━━━━━━━━━━┓
╾┬─┫ 56 HEXDIG ┣─┬╼ ╾┬─┫ 0*64 HEXDIG ┣─┬╼
│ ┗━━━━━━━━━━━┛ │ │ ┗━━━━━━━━━━━━━┛ │
│ ╭───╮ │ │ ╭───╮ │
└─┤ * ├─────────┘ └─┤ * ├───────────┘
╰───╯ ╰───╯
HEXDIG = %x30–39 / %x41-%46
```
### Examples
| Pattern | Description |
| --- | --- |
| `dca1e44765b9f80c8b18105e17de90d4a07e4d5a83de533e53fee32e0502d17e.*` | Outputs that contains any asset from a specific policy |
| `dca1e44765b9f80c8b18105e17de90d4a07e4d5a83de533e53fee32e0502d17e.FFCC00` | Outputs that contains any quantity of a specific asset |
## Output reference
```
OUTPUT_INDEX = TRANSACTION_ID =
┏━━━━━━━━━━━┓ ┏━━━━━━━━━━━┓
╾┬─┫ 1*3 DIGIT ┣─┬╼ ╾─┫ 64 HEXDIG ┣─╼
│ ┗━━━━━━━━━━━┛ │ ┗━━━━━━━━━━━┛
│ ╭───╮ │
└─┤ * ├─────────┘
╰───╯
HEXDIG = %x30–39 / %x41-%46
```
## Metadata tag
> <sup><strong>WARNING</strong></sup> <br/>
>
> This pattern can only be used for indexing, not for querying.
```
METADATA_TAG =
╭───╮ ┏━━━━━━━━━━━━━━┓ ╭───╮
╾─┤ { ├──┫ METADATA TAG ┣──┤ } ├─╼
╰───╯ ┗━━━━━━━━━━━━━━┛ ╰───╯
```
### Examples
| Pattern | Description |
| --- | --- |
| `{25}` | Outputs of any transaction that has metadata with label 25 |
| `{42}` | Outputs of any transaction that has metadata with label 42 |
# Accessing results
Matches can be queried from the server via HTTP GET requests. For example:
```console
$ curl http://localhost:1442/matches
```
will return all matches currently present in the database (be careful when
combined with very permissive patterns and wildcards!). The `/matches`
endpoint actually accept patterns, which may be different from the one
provided in the command-line. So it for instance possible to build an index
for all addresses but then, lookup only a single address as:
```console
$ curl http://localhost:1442/matches/addr1vyc29pvl2uyzqt8nwxrcxnf558ffm27u3d9calxn8tdudjgz4xq9p
```
Optionally, you can query only `unspent` or `spent` results using the respective query flags:
```console
$ curl http://localhost:1442/matches/*/*?unspent
```
The complete API reference is available below.
# Rollbacks & chain forks
## Problem
Cardano is a distributed permissionless ledger and, as such, provides only
eventual consensus. This means that information in the system only becomes
immutable after some delay—however, the probability of something remaining
true increases exponentially as time passes.
This matters for client applications using an indexer like Kupo. Indeed,
any information obtained from Kupo only reflects the local view of the
global system that Kupo has (or, more specifically, the node it is
connected to). Recent information that enters the system may therefore be
invalidated at a later stage. This is typically called _a rollback_, which
happens when the node switches to a different version of the chain.
## How Kupo deals with rollbacks
Rollbacks are relatively frequent on Cardano, but they remain usually small
(a couple of blocks) because the network resolves them promptly. Yet, in
theory, rollbacks can go as far as the protocol's security parameter,
defined in each network's genesis configuration. For example, on `mainnet`
and `preprod`, this security parameter equals `2160`; on `preview`, it
equals `432`. Furthermore, the Ouroboros Praos protocol (used by Cardano at
the moment) guarantees that there are at least `k` blocks in a window of
`3k / f` slots where `f` is the _active slot coefficient_.
Said differently, we can't guarantee that information newer than ~36h will
be immutable. However, the probability of non-settlement approaches 0
extremely fast, much sooner (after a hundred blocks, the likelihood of
rollback is typically less than 0.01%). This is why Kupo does not get rid
of any data immediately, even when `--prune-utxo` is specified. Instead,
Kupo takes a _mark and sweep_ approach akin to garbage collectors. First,
spent UTxO entries are marked until it is safe to remove them and such that
the indexer database can constantly be rolled back when necessary. Then,
after a rollback, Kupo automatically (and quickly) catches up with the
chain.
## How can your application deal with rollbacks
As a client application, you have to care extra about using information
from the indexer and use patterns that are resilient to rollbacks. So
naturally, Kupo provides mechanisms to help you deal with rollbacks.
First, any results from Kupo are delivered with a timestamp `created_at`,
which gives you the absolute slot number at which an entry has been created
and the block header hash that contains the associated output. These pieces
of information are crucial to detect whether something has changed. Indeed,
when switching to a different fork of the chain, outputs may or may not
disappear. Yet, they may end up in another block than the one they were
initially advertised in. Thus controlling both the slot number and the
header hash between requests gives your application ways to notice if
something has changed. Plus, comparing the absolute slot number with the
network tip helps you build confidence about how immutable some information
is.
Second, any response from the server contains some practical header fields:
- `X-Most-Recent-Checkpoint`: an absolute slot number of the most recent block indexed by Kupo at the moment of the request.
- `ETag`: a hex-encoded block header hash digest of that same most recent block.
With this, client applications can know precisely which point on the chain
a query is accurate. Knowing this is also helpful when polling a specific
endpoint to see whether something has changed, particularly when combined
with standard HTTP caching practices. For example, a client application can
specify a [`If-None-Match`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Caching#etagif-none-match)
header in requests to only fetch a response if it has changed.
# Era boundaries
<div class="tabs">
<input type="radio" checked name="tab" id="tab-mainnet">
<label for="tab-mainnet">Mainnet</label>
<input type="radio" name="tab" id="tab-testnet">
<label for="tab-testnet">Testnet</label>
<input type="radio" name="tab" id="tab-preview">
<label for="tab-preview">Preview</label>
<input type="radio" name="tab" id="tab-preprod">
<label for="tab-preprod">Preprod</label>
<div class="tab">
| Era Bound | SlotNo | Block Header Hash |
| --- | --- | --- |
| Last Byron block | 4492799 | f8084c61b6a238acec985b59310b6ecec49c0ab8352249afd7268da5cff2a457 |
| Last Shelley block | 16588737 | 4e9bbbb67e3ae262133d94c3da5bffce7b1127fc436e7433b87668dba34c354a |
| Last Allegra block | 23068793 | 69c44ac1dda2ec74646e4223bc804d9126f719b1c245dadc2ad65e8de1b276d7 |
| Last Mary block | 39916796 | e72579ff89dc9ed325b723a33624b596c08141c7bd573ecfff56a1f7229e4d09 |
| Last Alonzo block | 72316796 | c58a24ba8203e7629422a24d9dc68ce2ed495420bf40d9dab124373655161a20 |
| Last Babbage block | N/A | N/A |
See <a target="_blank" href="https://github.com/input-output-hk/cardano-configurations/tree/master/network/mainnet">configuration files for <strong>Mainnet</strong></a>.
</div>
<div class="tab">
| Era Bound | SlotNo | Block Header Hash |
| --- | --- | --- |
| Last Byron block | 1598399 | 7e16781b40ebf8b6da18f7b5e8ade855d6738095ef2f1c58c77e88b6e45997a4 |
| Last Shelley block | 13694363 | b596f9739b647ab5af901c8fc6f75791e262b0aeba81994a1d622543459734f2 |
| Last Allegra block | 18014387 | 9914c8da22a833a777d8fc1f735d2dbba70b99f15d765b6c6ee45fe322d92d93 |
| Last Mary block | 36158304 | 2b95ce628d36c3f8f37a32c2942b48e4f9295ccfe8190bcbc1f012e1e97c79eb |
| Last Alonzo block | 62510369 | d931221f9bc4cae34de422d9f4281a2b0344e86aac6b31eb54e2ee90f44a09b9 |
| Last Babbage block | N/A | N/A |
> <sup><strong>WARNING</strong></sup> <br/>
>
> The testnet network is now deprecated and may be retired at any time. Use `Preview` or `Preprod` instead.
See <a target="_blank" href="https://github.com/input-output-hk/cardano-configurations/tree/master/network/testnet">configuration files for <strong>Testnet</strong></a>.
</div>
<div class="tab">
| Era Bound | SlotNo | Block Header Hash |
| --- | --- | --- |
| Last Byron block | N/A | N/A |
| Last Shelley block | N/A | N/A |
| Last Allegra block | N/A | N/A |
| Last Mary block | N/A | N/A |
| Last Alonzo block | 259180 | 0ad91d3bbe350b1cfa05b13dba5263c47c5eca4f97b3a3105eba96416785a487 |
| Last Babbage block | N/A | N/A |
See <a target="_blank" href="https://github.com/input-output-hk/cardano-configurations/tree/master/network/preview">configuration files for <strong>Preview</strong></a>.
</div>
<div class="tab">
| Era Bound | SlotNo | Block Header Hash |
| --- | --- | --- |
| Last Byron block | 84242 | 45899e8002b27df291e09188bfe3aeb5397ac03546a7d0ead93aa2500860f1af |
| Last Shelley block | 518360 | f9d8b6c77fedd60c3caf5de0ce63a0aeb9d1753269c9c07503d9aa09d5144481 |
| Last Allegra block | 950340 | 74c03af754bcde9cd242c5a168689edcab1756a3f7ae4d5dca1a31d86839c7b1 |
| Last Mary block | 1382348 | af5fddc7d16a349e1a2af8ba89f4f5d3273955a13095b3709ef6e3db576a0b33 |
| Last Alonzo block | 3542390 | f93e682d5b91a94d8660e748aef229c19cb285bfb9830db48941d6a78183d81f |
| Last Babbage block | N/A | N/A |
See <a target="_blank" href="https://github.com/input-output-hk/cardano-configurations/tree/master/network/preprod">configuration files for <strong>Preprod</strong></a>.
</div>
</div>
<div align="center">
<pre style="background: none; border: none; color: inherit; display: inline-block; text-align: left;">
●
/\__\__/\
/✿ \
\ (ミ ⌒ ● ⌒ ミ) つ ━✫ ✧・゚* KUPO! *:・゚✧*:・゚💖
</pre>
</div>
x-tagGroups:
- name: General
tags:
- Matches
- Patterns
- name: Auxiliary Data
tags:
- Scripts
- Datums
- Metadata
- name: Monitoring
tags:
- Checkpoints
- Health
components:
headers: &default-headers
Content-Type:
schema:
type: string
enum:
- "application/json;charset=utf-8"
X-Most-Recent-Checkpoint:
description: |
Kupo's most recent indexed block's slot number. This allows to know which slot a query is accurate of.
schema:
type: integer
minimum: 0
ETag:
description: |
A cache value generated by the server to indicate whether a response has changed or not. The `ETag` always corresponds to the block header hash of the most recent indexed block.
This can be used in combination with [`If-None-Match`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Caching#etagif-none-match) to provide some efficient client-side caching.
schema:
type: string
contentEncoding: base16
responses:
304:
description: |
Not Modified
Returned when a `If-None-Match` request header matches the current `ETag` for the response.
This is meant to provide efficient caching and polling. The `ETag` corresponds to the most
recent block header hash processed by Kupo.
headers: *default-headers
schemas:
Address_Shelley: &Address_Shelley
title: Shelley
oneOf:
- title: bech32
type: string
contentEncoding: bech32
description: A standard payment address, in bech32 (i.e. starting with `addr|addr_test`).
example: addr1vy3qpx09uscywhpp0ekg9zwmq2yj5vp08husfq6qyh2mpps865j6t
- title: base16
type: string
contentEncoding: base16
description: A standard payment address, in base16
example: 7a5e61936081db3b2117cbf59bd2123748f58ac96786567067f3314661
Address_Stake: &Address_Stake
title: Stake
oneOf:
- title: bech32
type: string
contentEncoding: bech32
description: A stake address, in bech32 (i.e. starting with `stake|stake_test`).
example: stake1vyc29pvl2uyzqt8nwxrcxnf558ffm27u3d9calxn8tdudjgydsx9n
- title: base16
type: string
contentEncoding: bech32
description: A stake address, in base16.
example: 7a5e61936081db3b2117cbf59bd2123748f58ac96786567067f3314661
Address_Bootstrap: &Address_Bootstrap
title: Bootstrap
oneOf:
- title: base58
description: A Bootstrap (a.k.a Byron) address (legacy), in base58.
type: string
contentEncoding: base58
example: DdzFFzCqrhsnWCKDVxHipmLW7acroB11zWxe1BGP1gCh7EqmgjVPe2qes6HrsQs
- title: base16
description: A Bootstrap (a.k.a Byron) address (legacy), in base16.
type: string
contentEncoding: base16
example: 73b81dc65c31ab02195bb9264982233513cabc14df8ff07ed7c55cc326833753a5c23b10ef4121f1757cdf3c0038
Address_Credentials: &Address_Credentials
type: string
title: Credentials
description: |
```
┏━━━━━━━━━━━━┓ ╭───╮ ┏━━━━━━━━━━━━┓
╾─┫ CREDENTIAL ┣─┤ / ├─┫ CREDENTIAL ┣─╼
┗━━━━━━━━━━━━┛ ╰───╯ ┗━━━━━━━━━━━━┛
```
One or two address credentials, separated by a `/`. The left-side identifies the payment
part of the address, and the right-side identifies the delegation part. Both are optional
an can be instead a wildcard (`*`).
Examples:
- `addr_vk1x7da0l25j04my8sej5ntrgdn38wmshxhplxdfjskn07ufavsgtkqn5hljl/*`
- `*/script1cda3khwqv60360rp5m7akt50m6ttapacs8rqhn5w342z7r35m37`
- `dca1e44765b9f80c8b18105e17de90d4a07e4d5a83de533e53fee32e0502d17e/*`
- `*/4fc6bb0c93780ad706425d9f7dc1d3c5e3ddbf29ba8486dce904a5fc`
- `*/*`
examples:
- "addr_vk1x7da0l25j04my8sej5ntrgdn38wmshxhplxdfjskn07ufavsgtkqn5hljl/*"
- "*/script1cda3khwqv60360rp5m7akt50m6ttapacs8rqhn5w342z7r35m37"
- "dca1e44765b9f80c8b18105e17de90d4a07e4d5a83de533e53fee32e0502d17e/*"
- "*/4fc6bb0c93780ad706425d9f7dc1d3c5e3ddbf29ba8486dce904a5fc"
- "*/*"
Address:
description: A Cardano address, in any era.
anyOf:
- <<: *Address_Shelley
- <<: *Address_Bootstrap
AddressPattern:
title: Address
description: A Cardano address or stake address.
anyOf:
- <<: *Address_Credentials
- <<: *Address_Shelley
- <<: *Address_Stake
- <<: *Address_Bootstrap
AssetIdPattern:
type: string
title: AssetId
pattern: "[0-9a-f]{56}\\.(*|[0-9a-f]{2,64})"
description: |
```
┏━━━━━━━━━━━┓ ╭───╮ ┏━━━━━━━━━━━━┓
╾─┫ POLICY_ID ┣─┤ . ├─┫ ASSET_NAME ┣─╼
┗━━━━━━━━━━━┛ ╰───╯ ┗━━━━━━━━━━━━┛
```
A policy id (base16-encoded) and an optional asset name (base16-encoded), dot-separated.
Examples:
- `1220099e5e430475c219518179efc7e6c8289db028904834025d5b086.*`
- `1220099e5e430475c219518179efc7e6c8289db028904834025d5b086.08661220099e`
examples:
- "1220099e5e430475c219518179efc7e6c8289db028904834025d5b086.*"
- "1220099e5e430475c219518179efc7e6c8289db028904834025d5b086.08661220099e"
BadRequest:
type: object
additionalProperties: false
properties:
hint:
type: string
description: Some hint about what went wrong.
Datum:
title: Datum
type: object
required:
- datum
additionalProperties: false
properties:
datum:
type: string
description: A serialized Plutus' datum.
contentEncoding: base16
example: d87980
DatumHash:
description: A blake2b-256 hash digest of a Plutus' datum, if any.
oneOf:
- title: Digest
type: string
description: A blake2b-256 hash digest of a Plutus' datum.
contentEncoding: base16
example: 3097...b635
minLength: 64
maxLength: 64
- title: Nothing
description: N/A
type: "null"
DatumType:
description: |
Categorize the type of datum in the output:
- `hash`: means that the output only contains a reference to the datum;
- `inline`: means that the ouput originally contained a full inline datum.
In both cases however, Kupo returns only a `datum_hash`, and full datums
can be retrieved via the [`GET /datums/{datum-hash}`](#tag/Datums/paths/~1datums~1{datum-hash}/get)
endpoint.
This field is only present when `datum_hash` is not `null`.
type: string
enum:
- hash
- inline
Deleted:
type: object
required:
- deleted
properties:
deleted:
description: Number of entities effectively deleted.
type: integer
minimum: 0
ForcedRollback:
type: object
additionalProperties: false
required:
- rollback_to
properties:
rollback_to:
type: object
required:
- slot_no
description: |
A mandatory point to rollback the synchronization to.
Note that the synchronization will therefore begin starting from the point **immediately after** the provided point!
> <sup><strong>NOTE (1)</strong></sup> <br/>
> If you need to query ancestors from any given known point, see [`GET /checkpoints/{slot-no}`](#operation/getCheckpointBySlot)
> <sup><strong>NOTE (2)</strong></sup> <br/>
> The `header_hash` is **optional**! However if provided, Kupo will check that it rolls back exactly to the specified point by comparing header hashes.
> If it's omitted, Kupo will rollback to the given slot number or, any closest ancestor if no point is found at the given slot.
properties:
slot_no:
$ref: "#/components/schemas/SlotNo"
header_hash:
$ref: "#/components/schemas/HeaderHash"
limit:
type: string
description: |
Specify the server behavior when rolling back out of the _safe
zone_. As mentioned in the user manual, when running Kupo with
`--prune-utxo` enabled, the server gets rid of spent UTxOs, but it
only does so after a certain time. That time is exactly `129600`
slots (or 36h on Mainnet/Testnet). This is because the core
protocol cannot roll back further than this particular depth and it
is the point after which it is 100% safe to remove data from the
database.
However, this endpoint allows you to break this invariant and
rollback to points that are even older in the past. As a
consequence, while syncing, the index may be in a somewhat
inconsistent state because some inputs spent at a later time may
not have been recovered during the rollback. This may be surprising
if you're expecting to see and query those transient inputs after
rolling back.
By default, you won't be allowed to rollback beyond the safe zone.
If, however, you know what you're doing, you're kindly asked to
pass `unsafe_allow_beyond_safe_zone` as a token of acknowledgment.
Passing `within_safe_zone` has no effects other than the default.
Note that, once synchronized again, the index will always be in the
expected state and problems reflecting reality only occurs _while
catching up_, after a long rollback.
default: within_safe_zone
enum:
- unsafe_allow_beyond_safe_zone
- within_safe_zone
HeaderHash: &HeaderHash
type: string
description: A blake2b-256 hash digest of a block header.
contentEncoding: base16
example: 9d09...31bf
minLength: 64
maxLength: 64
Metadata:
type: object
additionalProperties: false
required:
- hash
- schema
- raw
properties:
hash:
type: string
description: A blake2b-256 hash digest of the raw serialized data
contentEncoding: base16
example: cd6a5d31bf9d309706b92ad83402e682fdab9fc889b1b63565ee3de14e09dedf
minLength: 64
maxLength: 64
raw:
type: string
description: A [CBOR](https://www.rfc-editor.org/rfc/rfc8949.html)-encoded binary payload.
contentEncoding: base16
schema:
type: object
description: |
A high-level description of the raw data. The top-level object is an object where all keys are integers (possibly negative) and points to objects representing one of 5 primitives:
- int
- string
- bytes
- list
- map
This schema is meant to give a faithful representation of the underlying [CBOR](https://www.rfc-editor.org/rfc/rfc8949.html) encoding, which is slightly more expressive than pure JSON (e.g. keys of maps can be arbitrary CBOR objects).
This is why it is generally not possible to ensure a 1:1 conversion between low-level CBOR and JSON, and why this intermediate representation is necessary to safely represent **any** metadata object.
propertyNames:
type: integer
additionalProperties:
x-additionalPropertiesName: "label (integer)"
$ref: "#/components/schemas/Metadatum"
example:
{
"64": {"string": "some text"},
"32": {"int": 42},
"16": {
"map": [
{
"k": {"string": "numbers"},
"v": {"list": [{"int": 1}, {"int": 2}, {"int": 4}, {"int": 8}]}
},
{
"k": {"string": "alphabet"},
"v": {
"map": [
{"k": {"string": "A"}, "v": {"int": 65}},
{"k": {"string": "B"}, "v": {"int": 66}},
{"k": {"string": "C"}, "v": {"int": 67}}
]
}
}
]
},
"-8": { "bytes": "48656c6c6f2c2043617264616e6f21" }
}
Metadatum:
oneOf:
- $ref: "#/components/schemas/Metadatum_Int"
- $ref: "#/components/schemas/Metadatum_String"
- $ref: "#/components/schemas/Metadatum_Bytes"
- $ref: "#/components/schemas/Metadatum_List"
- $ref: "#/components/schemas/Metadatum_Map"
Metadatum_Int:
title: int
type: object
additionalProperties: false
required:
- int
properties:
int:
type: integer
description: |
An integer or arbitrary size.
Example:
```json
{ "int": 42 }
```
Metadatum_String:
title: string
type: object
additionalProperties: false
required:
- string
properties:
string:
type: string
contentEncoding: utf-8
maxLength: 64
description: |
A text string, which is at most 64 bytes.
Example:
```json
{ "string": "kupo!" }
```