Skip to content

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

@marc0olo

Description

@marc0olo

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions