Hi Team
I am creating a ICP transaction without memo field and i am able to submit it on chain in testnet but when i fetch that transaction i am getting memo as 0
I want to know the if memo is optional or not?
The memo field is optional but it is set to 0 if not specified. There is another field icrc1_memo which is not set if skipped, e.g. https://dashboard.internetcomputer.org/transaction/1adc9fafeb2c1370165963376757c1313822044c5c0c5d259c6984ab624d34c1?index=22256206. It can also be specified, e.g. https://dashboard.internetcomputer.org/transaction/b762265974c5cacd44a1be0dc5b6f9103e24ea7aea21c4043f073ef89f8fc7e2?index=22256113)
I was wrong. You must have been using the icrc1_transfer endpoint (if you were using transfer or send_dfx the memo field would be mandatory). In case of icrc1_transfer the memo field is always set to 0. You can only specify the optional icrc1_memo (see examples above).
what’s the easiest endpoint to get a transaction memo ? I know it can be retrieved through the dashboard but is this available on chain as the api has a 60-90 second wait time due to aggregation. How could i check the transaction’s memo field directly by calling to the ledger?
You can read it from the ICRC-3 block log which is the unaggregated history chain: ICRC-1/standards/ICRC-3/README.md at main · dfinity/ICRC-1 · GitHub
The ICP ledger does not support ICRC3, but you can use the query_blocks ledger endpoint, e.g.:
dfx canister call ryjl3-tyaaa-aaaaa-aaaba-cai query_blocks '(record {start = 22518030:nat64; length = 1:nat64})' --network ic
or get_blocks archive endpoint:
dfx canister call q3fc5-haaaa-aaaaa-aaahq-cai get_blocks '(record {start = 22256113:nat64; length = 1:nat64})' --network ic