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 5736146
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: motoko/icp_transfer/README.md
+4-4Lines changed: 4 additions & 4 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
-**`toAccountIdHex(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
-**`transferToPrincipal(amount, principal, subaccount)`** — calls `toLedgerAccount` internally. Use this when you have a principal.
13
-
-**`transferToAccountId(amount, accountId)`** — accepts the raw blob directly. Use this when an exchange or external service gives you the destination as an AccountIdentifier rather than as a principal.
13
+
-**`transferToAccountId(amount, accountIdHex)`** — accepts the AccountIdentifier as a 64-char hex string (the format CEXs and block explorers provide).
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
@@ -34,11 +34,11 @@ icp network stop
34
34
`make test` funds the backend with 2 ICP, then:
35
35
1. Compares `icp identity account-id --format ledger` with `toAccountIdHex` to verify the CLI and the backend compute the same AccountIdentifier.
36
36
2. Calls `transferToPrincipal` — transfers 99_990_000 e8s (amount) + 10_000 e8s (fee) = exactly 1 ICP deducted from the backend; confirms both sides via `icp token balance`.
37
-
3. Calls `transferToAccountId` with the AccountIdentifier as `vec nat8` — same 1 ICP deduction, confirming both transfer paths reach the same account and the backend balance reaches zero.
37
+
3. Calls `transferToAccountId` 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.
38
38
39
39
## Security considerations and best practices
40
40
41
41
Refer to the [security best practices](https://docs.internetcomputer.org/guides/security/overview) for information on security and best practices for your ICP app. For this example the following aspects are particularly relevant:
42
42
43
-
-[Inter-canister calls and rollbacks](https://docs.internetcomputer.org/guides/security/overview): issues around inter-canister calls (here the ledger) can lead to time-of-check time-of-use or double-spending bugs.
44
-
-[Certify query responses if they are relevant for security](https://docs.internetcomputer.org/guides/security/overview): essential when displaying financial data that users act on.
43
+
-[Securely handle traps in callbacks](https://docs.internetcomputer.org/guides/security/inter-canister-calls/#securely-handle-traps-in-callbacks): issues around inter-canister calls (here the ledger) can lead to time-of-check time-of-use or double-spending bugs.
44
+
-[Certified variables](https://docs.internetcomputer.org/guides/security/data-integrity-and-authenticity/#certified-variables): essential when displaying financial data that users act on.
0 commit comments