dfinity / dfinity/icskills

ckBTC skill: CLI examples use created_at_time = null — recommend setting timestamp for deduplication

Open Beginner friendly
#178 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
35
Forks
13
Avg merge
19h 10m
Merged PRs (30d)
22

Description

Problem

The ckBTC skill's CLI examples (in the Deploy & Test / Using icp to Interact with ckBTC Directly section and Verify It Works section) all use created_at_time = null in icrc1_transfer calls:

icp canister call mxzaz-hqaaa-aaaar-qaada-cai icrc1_transfer \
  '(record {
    ...
    created_at_time = null;
  })' -e ic

Setting created_at_time = null disables ICRC-1 transaction deduplication. If a developer copy-pastes this command and runs it twice (a common accident), both transfers execute independently and the amount is sent twice.

This is a correctness issue for anyone using the skill as a reference for CLI-level testing or scripting.

Expected behavior

The ICRC-1 spec deduplication window is 24 hours. When created_at_time is set to the current nanosecond timestamp and the exact same transfer args are submitted again within that window, the ledger returns Duplicate { duplicate_of: block_index } instead of executing again.

The developer docs ledger guide states:

Always set created_at_time to enable deduplication. Without it, two identical transfers submitted within 24 hours both execute.

Suggested fix

Replace created_at_time = null in CLI examples with the current nanosecond timestamp. A portable bash one-liner (works on macOS and Linux):

# Set timestamp once
export NOW_NS=$(python3 -c "import time; print(int(time.time() * 1e9))")

icp canister call mxzaz-hqaaa-aaaar-qaada-cai icrc1_transfer \
  "(record {
    to = record { owner = principal \"$RECIPIENT\"; subaccount = null };
    amount = 100_000;
    fee = opt 10;
    memo = null;
    from_subaccount = null;
    created_at_time = opt ($NOW_NS : nat64);
  })" -e ic

Alternatively, add a note explaining that null disables deduplication and is only appropriate for one-off manual calls where double-submission is not a concern.

Affected files

  • skills/ckbtc/SKILL.md — CLI examples in Deploy & Test and Verify It Works sections

Related

Surfaced while writing the ICP developer docs Bitcoin integration guide.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Open skills/ckbtc/SKILL.md and review the CLI examples in the Deploy & Test / Using icp to Interact with ckBTC Directly and Verify It Works sections. Update the created_at_time guidance and examples so the deduplication behavior is clear, then check that the commands remain consistent and portable.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, shell
Domain
blockchain, documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
76/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.