# Avoid account identifiers; use ICRC-1

**URL:** <https://forum.dfinity.org/t/avoid-account-identifiers-use-icrc-1/23163>\
**Category:** Developers\
**Created:** [September 19, 2023, 9:27am UTC](https://forum.dfinity.org/t/avoid-account-identifiers-use-icrc-1/23163 "2023-09-19T09:27:21Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![dskloet](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/dskloet/32/10783_2.png) [@dskloet](https://forum.dfinity.org/u/dskloet)\
**Post date:** [September 19, 2023, 9:27am UTC](https://forum.dfinity.org/t/avoid-account-identifiers-use-icrc-1/23163/1 "2023-09-19T09:27:21Z")

</div>

**TL;DR**

Calculating account identifiers can be dangerous. Please use ICRC-1 or the new `account_identifier` method on the ICP ledger canister.

**The Incident**

Starting July 20th, we started getting reports from people not being able to log in with Internet Identity. You can read more about it [here](https://forum.dfinity.org/t/upgrade-agent-js-to-resolve-a-chrome-issue/22364), but in the end we identified the problem was using a specific hashing library. Unfortunately the same hashing library that was causing login problems, was also being used to calculate account identifiers. If this goes wrong, you still get something that looks like an account identifier and you only really notice that it isn’t when money that’s sent there doesn’t appear in your account. Sadly this is what [happened](https://forum.dfinity.org/t/assistance-requested-subaccount-calculation-issue/22550) on August 23rd.

**The response**

We have already switched [ic-js](https://github.com/dfinity/ic-js) to using a different hashing library ([@noble/hashes](https://www.npmjs.com/package/@noble/hashes)). However we realize that we can’t guarantee that this other library will always work correctly. Fortunately if you transfer tokens using the [ICRC-1 interface](https://github.com/dfinity/ic/blob/def91661e9d7eb18303b850f88a903112b1c6b6a/rs/rosetta-api/icp_ledger/ledger.did#L450) you don’t need to calculate an identifier on the client and can specify the owner principal and subaccount directly.

**What we are asking the community**

Therefore we want to urge all developers to use ICRC-1 whenever possible. For the cases where an account identifier is unavoidable, we have also [implemented](https://github.com/dfinity/ic/commit/def91661e9d7eb18303b850f88a903112b1c6b6a) a new canister method to get an account identifier without having to calculate it in the client.

---

<div class="post-metadata">

**Author:** ![ICPSwap](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/icpswap/32/11193_2.png) [@ICPSwap](https://forum.dfinity.org/u/ICPSwap)\
**Post date:** [September 19, 2023, 1:02pm UTC](https://forum.dfinity.org/t/avoid-account-identifiers-use-icrc-1/23163/2 "2023-09-19T13:02:07Z")

</div>

Thank you to the DFINITY dev team for your assistance, prompt responses, and quick updates!

---

<div class="post-metadata">

**Author:** ![levi](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/levi/32/22608_2.png) [@levi](https://forum.dfinity.org/u/levi)\
**Post date:** [September 19, 2023, 5:21pm UTC](https://forum.dfinity.org/t/avoid-account-identifiers-use-icrc-1/23163/3 "2023-09-19T17:21:14Z")

</div>

> [@dskloet](#):
>
> we have also [implemented](https://github.com/dfinity/ic/commit/def91661e9d7eb18303b850f88a903112b1c6b6a) a new canister method to get an account identifier without having to calculate it in the client.

Good move.

Is there a way we can make the exchanges (coinbase/binance) compatible with [the icrc1-textual encoding format](https://github.com/dfinity/ICRC-1/blob/main/standards/ICRC-1/TextualEncoding.md)?

---

<div class="post-metadata">

**Author:** ![zohaib29](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/zohaib29/32/29625_2.png) [@zohaib29](https://forum.dfinity.org/u/zohaib29)\
**Post date:** [September 20, 2023, 4:08am UTC](https://forum.dfinity.org/t/avoid-account-identifiers-use-icrc-1/23163/4 "2023-09-20T04:08:32Z")

</div>

Is this new method ‘account identifier’ deployed for ICP Ledger?  
I am trying to use this method by pulling the latest wasm, but the method is not available.

---

<div class="post-metadata">

**Author:** ![dskloet](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/dskloet/32/10783_2.png) [@dskloet](https://forum.dfinity.org/u/dskloet)\
**Post date:** [September 20, 2023, 5:47am UTC](https://forum.dfinity.org/t/avoid-account-identifiers-use-icrc-1/23163/5 "2023-09-20T05:47:12Z")

</div>

> Is this new method ‘account identifier’ deployed for ICP Ledger?

Thanks for pointing this out. The ICP ledger canister hasn’t been deployed since the new method was added. I’ll ask when it might be deployed.

In the meantime you should be able to test it locally by installing it with

```bash
$ dfx start --clean
# In another terminal:
$ rm "$(dfx cache show)/wasms/ledger-canister_notify-method.wasm" # if it already didn't exist, that's fine
$ DFX_IC_COMMIT=e63cc8e68d591dd0ca3e68ec46ed1d9c2c1d7797 dfx nns install
$ dfx nns import
$ dfx canister call nns-ledger account_identifier '(record {owner = principal "l6jli-p5bub-kxvlf-jovmc-hq6lb-3qifz-i6d52-nvhni-bbjuc-n76fc-hqe"; subaccount = opt blob "\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\01" })'

```

---

<div class="post-metadata">

**Author:** ![dskloet](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/dskloet/32/10783_2.png) [@dskloet](https://forum.dfinity.org/u/dskloet)\
**Post date:** [September 20, 2023, 5:49am UTC](https://forum.dfinity.org/t/avoid-account-identifiers-use-icrc-1/23163/6 "2023-09-20T05:49:34Z")

</div>

> [@levi](#):
>
> Is there a way we can make the exchanges (coinbase/binance) compatible with [the icrc1-textual encoding format](https://github.com/dfinity/ICRC-1/blob/main/standards/ICRC-1/TextualEncoding.md)?

I recommend you contact them directly.

---

<div class="post-metadata">

**Author:** ![levi](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/levi/32/22608_2.png) [@levi](https://forum.dfinity.org/u/levi)\
**Post date:** [September 20, 2023, 7:35pm UTC](https://forum.dfinity.org/t/avoid-account-identifiers-use-icrc-1/23163/7 "2023-09-20T19:35:23Z")

</div>

That is a strange recommendation.

---

<div class="post-metadata">

**Author:** ![dskloet](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/dskloet/32/10783_2.png) [@dskloet](https://forum.dfinity.org/u/dskloet)\
**Post date:** [September 20, 2023, 7:41pm UTC](https://forum.dfinity.org/t/avoid-account-identifiers-use-icrc-1/23163/8 "2023-09-20T19:41:48Z")

</div>

Maybe I misunderstood the question? I don’t think there’s anything we can do to make Coinbase work with ICRC-1 without changing Coinbase itself. And I expect their decision to do it will have mostly to do with whether they think there is demand for it.  
But I do not use Coinbase myself so maybe I’m misunderstanding what you are referring to.

I also suspect that there are some business/partnership people at DFINITY who might want to encourage them, but that doesn’t change that independent demand would help. But I am an engineer myself and I’m not involved in/aware of those discussions so this is the best advice I have.

---

<div class="post-metadata">

**Author:** ![levi](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/levi/32/22608_2.png) [@levi](https://forum.dfinity.org/u/levi)\
**Post date:** [September 25, 2023, 3:11am UTC](https://forum.dfinity.org/t/avoid-account-identifiers-use-icrc-1/23163/9 "2023-09-25T03:11:09Z")

</div>

Did someone at dfinity register the icp token / rosetta node on the major exchanges? How do they know the bounds/function/specification of the first icp account identifier?
