You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 1382f67
Browse filesBrowse the repository at this point in the historyBrowse files
refine(rust/icp_transfer): accept hex string in transfer_to_account_id
Passing a 64-char hex string (the format CEXs and block explorers provide)
is cleaner than a raw blob: AccountIdentifier::from_hex validates the CRC32
in one call with no byte-manipulation, the Makefile test passes the hex
string directly, and the Candid type text avoids vec nat8 complexity.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: rust/icp_transfer/README.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,7 @@ The example exposes three functions to make this concrete:
10
10
11
11
-**`to_account_id_hex(principal, subaccount)`** — query returning the AccountIdentifier as a 64-char lowercase hex string, the format shown in block explorers and CEX deposit screens.
12
12
-**`transfer_to_principal(amount, principal, subaccount)`** — calls `AccountIdentifier::new` internally. Use this when you have a principal.
13
-
-**`transfer_to_account_id(amount, account_id)`** — accepts the raw 32-byte blob directly. Use this when an exchange or external service gives you the destination as an AccountIdentifier rather than as a principal.
13
+
-**`transfer_to_account_id(amount, account_id_hex)`** — accepts the AccountIdentifier as a 64-char hex string (the format CEXs and block explorers provide). Validates the embedded CRC32 checksum before transferring.
14
14
15
15
> The ICP ledger also supports the [ICRC-1](https://github.com/dfinity/ICRC-1) standard via `icrc1_transfer`. For new token integrations that don't require AccountIdentifier compatibility, ICRC-1 is the recommended interface. A comprehensive ICRC ledger example is planned.
16
16
@@ -33,7 +33,7 @@ icp network stop
33
33
`make test` funds the backend with 2 ICP, then:
34
34
1. Compares `icp identity account-id --format ledger` with `to_account_id_hex` to verify CLI and backend compute the same AccountIdentifier.
35
35
2. Calls `transfer_to_principal` — transfers 99_990_000 e8s (amount) + 10_000 e8s (fee) = exactly 1 ICP deducted from the backend; confirms both sides via `icp token balance`.
36
-
3. Calls `transfer_to_account_id` with the AccountIdentifier as `vec { N : nat8; ... }` — same 1 ICP deduction, confirming both transfer paths reach the same account and the backend balance reaches zero.
36
+
3. Calls `transfer_to_account_id` with the hex string from step 1 — same 1 ICP deduction, confirming both transfer paths reach the same account and the backend balance reaches zero.
0 commit comments