Skip to content

Commit 861cee6

Browse files
authored
docs(receipt-cli): add an offline quick start (#321) (#336)
Co-authored-by: emrekayat <237104270+emrekayat@users.noreply.github.com>
1 parent fb5804e commit 861cee6

1 file changed

Lines changed: 75 additions & 0 deletions

File tree

services/receipt-cli/README.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<!-- SPDX-License-Identifier: MIT -->
2+
# Receipt CLI
3+
4+
Export a round receipt from Soroban RPC, verify a receipt offline, or create a
5+
redacted copy for a public demo. See the canonical [receipt format and verification
6+
guide](../../docs/RECEIPTS.md) for the schema and verification guarantees.
7+
8+
Run the following commands from the repository root after `pnpm install`.
9+
The CLI command runs inside `services/receipt-cli`, so relative file paths below
10+
are relative to that workspace.
11+
12+
## Offline verification
13+
14+
Verify the committed golden fixture without a wallet or network access:
15+
16+
```sh
17+
pnpm --filter @sub-rosa/receipt-cli receipt verify src/fixtures/golden.json
18+
```
19+
20+
Request machine-readable output:
21+
22+
```sh
23+
pnpm --filter @sub-rosa/receipt-cli receipt verify src/fixtures/golden.json --json
24+
```
25+
26+
JSON output includes `valid`, `receiptId`, `roundId`, `checkedAt`, `errors`, and
27+
`warnings`. Successful verification exits with code 0; invalid receipts, unreadable
28+
files, malformed input, and usage errors exit with code 1. Warnings alone do not
29+
make an otherwise valid receipt fail.
30+
31+
To also verify a local artifact, supply a receipt containing `artifactChecksum`
32+
and the exact artifact file whose SHA-256 checksum was recorded in that receipt:
33+
34+
```sh
35+
pnpm --filter @sub-rosa/receipt-cli receipt verify /absolute/path/to/receipt.json --json --verify-artifact-checksum /absolute/path/to/artifact.wasm
36+
```
37+
38+
These are placeholder paths to your own files. A missing file, absent checksum
39+
metadata, or checksum mismatch fails verification. The golden-fixture commands
40+
above do not require an artifact file.
41+
42+
## Export from RPC
43+
44+
Export reads the configured network; it requires no transaction signing.
45+
Replace the contract ID and round ID with a deployed contract and existing round:
46+
47+
```sh
48+
CONTRACT_ID='<deployed-round-contract-id>' pnpm --filter @sub-rosa/receipt-cli receipt export 1
49+
```
50+
51+
The command writes `round-1-receipt.json` in the CLI workspace.
52+
53+
| Variable | Meaning | Default |
54+
| --- | --- | --- |
55+
| `CONTRACT_ID` | Deployed round contract ID (`C…`) | Required |
56+
| `RPC_URL` | Soroban RPC endpoint | `https://soroban-testnet.stellar.org` |
57+
| `NETWORK_PASSPHRASE` | Network passphrase | `Test SDF Network ; September 2015` |
58+
59+
## Redact a copy
60+
61+
Use an explicit output path to keep the original receipt intact:
62+
63+
```sh
64+
pnpm --filter @sub-rosa/receipt-cli receipt redact src/fixtures/golden.json /tmp/sub-rosa-receipt.redacted.json
65+
```
66+
67+
For which fields are removed and how redaction affects verification, consult the
68+
[receipt guide](../../docs/RECEIPTS.md). Review the resulting file before publishing.
69+
70+
## Development checks
71+
72+
```sh
73+
pnpm receipt-cli:test
74+
pnpm receipt-cli:typecheck
75+
```

0 commit comments

Comments
 (0)