Skip to content

docs(bitcoin): expand ckBTC CLI section into a step-by-step walkthrough#171

Merged
marc0olo merged 2 commits into
mainfrom
docs/bitcoin-ckbtc-cli-walkthrough
Apr 29, 2026
Merged

docs(bitcoin): expand ckBTC CLI section into a step-by-step walkthrough#171
marc0olo merged 2 commits into
mainfrom
docs/bitcoin-ckbtc-cli-walkthrough

Conversation

@marc0olo
Copy link
Copy Markdown
Member

@marc0olo marc0olo commented Apr 29, 2026

Summary

  • Heading renamed from ### Interact with ckBTC using icp-cli to ### Deposit, mint, and transfer (icp-cli) — the old name described the tool, not the task. The section covers a full BTC deposit, ckBTC minting, and transfer flow.

  • Five numbered steps with explanatory prose between each command, replacing the flat list of code blocks. Each step now tells the reader what they need to know before running the command, not just what the command does.

  • Step 2: get_minter_info added before update_balance. The minter requires a minimum number of Bitcoin confirmations before minting (currently 6 on mainnet). Showing this call lets readers check min_confirmations, kyt_fee, and retrieve_btc_min_amount before waiting for confirmations, rather than discovering the requirement by getting a NoNewUtxos error.

  • update_balance response explained: a Minted record confirms ckBTC was credited; Err(NoNewUtxos { current_confirmations = opt N }) tells the reader exactly how many confirmations the transaction currently has, so they can see progress without guessing.

  • Transfer command restructured: export RECIPIENT=... is now shown as inline prose before the code block. The icp canister call block is a clean single operation, consistent with all other command blocks in the section.

  • created_at_time = null explained: a sentence after the transfer block clarifies that null skips deduplication (running the command twice sends twice), and that production canister code should set this field to the current nanosecond timestamp. Links to Transferring assets (ICRC-1) where deduplication is documented.

  • KYT terminology corrected: KYT stands for "Know Your Transaction", not "Know Your Token" — fixed in the get_minter_info response description.

Correctness notes

  • min_confirmations = 6 sourced from .sources/portal/docs/references/ckbtc-reference.mdx line 12.
  • retrieve_btc_min_amount = 50,000 satoshis sourced from the same file, line 10.
  • kyt_fee value is not hardcoded — it's governance-adjustable, so the prose describes the field rather than stating a value that could drift.
  • update_balance error variant structure (NoNewUtxos { current_confirmations }) sourced from .sources/icskills/skills/ckbtc/SKILL.md lines 177–186.
  • KYT definition confirmed by user — not in the ckBTC skill, which uses the abbreviation without expanding it.

Related

Opened dfinity/icskills#178 to track updating the ckBTC skill's CLI examples to recommend setting created_at_time instead of null.

Sync recommendation

Informed by dfinity/icskills (skills/ckbtc/SKILL.md); dfinity/portal (docs/references/ckbtc-reference.mdx)

Renamed the section from "Interact with ckBTC using icp-cli" to "Deposit,
mint, and transfer (icp-cli)" to reflect what the section actually covers.

Restructured into five numbered steps with explanatory prose between each
command. Added a get_minter_info call in step 2 so readers can check
min_confirmations (currently 6 on mainnet), kyt_fee, and
retrieve_btc_min_amount before waiting. Clarified the update_balance
response: a Minted record confirms success; Err(NoNewUtxos) with
current_confirmations tells you where you stand if confirmations are not
yet reached. Moved the RECIPIENT setup to inline prose before the transfer
code block so the command block is a single clean operation. Added a note
explaining that created_at_time = null skips deduplication and that
production canister code should set this field to the current nanosecond
timestamp.
@marc0olo marc0olo merged commit 28bacc8 into main Apr 29, 2026
1 check passed
@marc0olo marc0olo deleted the docs/bitcoin-ckbtc-cli-walkthrough branch April 29, 2026 20:48
marc0olo added a commit that referenced this pull request Apr 29, 2026
## Summary

Adds a dedicated `### Transaction deduplication` section to
`docs/guides/digital-assets/ledgers.mdx`, immediately after `### Fee
handling`.

Previously, deduplication was a single sentence at the end of `### Fee
handling`: "Always set `created_at_time` to enable deduplication.
Without it, two identical transfers submitted within 24 hours both
execute." Fee handling and deduplication are separate concerns, and a
developer scanning the page for deduplication guidance would not find it
there.

The new section covers:

- **What it does**: the ledger tracks `(args, created_at_time)` pairs
and rejects exact duplicates within 24 hours with `Duplicate {
duplicate_of: block_index }`. The `duplicate_of` field lets you confirm
the original succeeded without re-submitting.
- **How to enable it**: references the existing `sendTokens` (Motoko:
`Nat64.fromNat(Int.abs(Time.now()))`) and `send_tokens` (Rust:
`ic_cdk::api::time()`) examples already on the page — no redundant code
tabs needed.
- **Boundary errors**: `TooOld` (timestamp older than 24h, window no
longer tracked) and `CreatedInFuture { ledger_time }` (timestamp ahead
of ledger time, `ledger_time` field helps diagnose clock drift).
- **When `null` is acceptable**: one-off manual CLI calls where
double-submission is not a concern.

Also updates the `bitcoin.mdx` CLI note to link to
`#transaction-deduplication` instead of the broader
`#transferring-assets-icrc-1` anchor.

## Related

- Surfaced while writing the ckBTC CLI walkthrough in PR #171
- Opened
[dfinity/icskills#178](dfinity/icskills#178)
to track updating the ckBTC skill's CLI examples

## Sync recommendation

Hand-written. Content is derived from the ICRC-1 specification
(`created_at_time` deduplication semantics) and verified against the
existing Motoko/Rust examples in this file.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant