ICRC1 Snapshot = Blob to AccountID (Human readable)

Hi there,

Wondering, how we can take human readable snapshot from the ICRC1 standard.

public query func icrc1_snapshot() : async [(AccountId, Nat)] 
{
 return Trie.toArray<AccountId, Nat, (AccountId, Nat)>(balances, func (k, v) = (k, v));
};   

Above code returns value similar to this which i think Account Blob. How i can convert blob to human readable account id ??

record { blob “\7f\06\e3#\f0\0c\e7\cb\a8\a3_\cc\fe\60\f3\8b\a3\ce\84\dc\fa\93\9aI\c1\c5\89\00\15\0e\92*”; 10_136_400 : nat;};

Thanks in advance

The specification for the textual encoding of ICRC-1 accounts - i.e. human readable text: https://github.com/dfinity/ICRC-1/blob/main/standards/ICRC-1/TextualEncoding.md

There are few libraries listed at the end of the spec. Not sure how up-to-date, except ic-js, the references are.

1 Like

You can also try this method (sonic icrc token repo) for converting blob to hex: This works for me.

1 Like

Thanks for the reply

AccountId is a Blob data type but the encode take Array of Nat8

Now, How we can convert Blob to Array of Nat8 ?

Yeah converted the Blob toArray and then encode returns the account id