Trouble Decoding Block 80543 in ckBTC: Seeking Resolution

I’ve encountered an issue with a specific block, number 80543, within the ckBTC canister (nbsys-saaaa-aaaar-qaaga-cai). This block does not seem to align with the current IDL definition of icrc1. I’ve attached a screenshot from the DFINITY dashboard displaying the error message:

Canister nbsys-saaaa-aaaar-qaaga-cai trapped explicitly: failed to decode block 161086: failed to decode a block: Semantic(None, "invalid type: integer `1696594164110199924`, expected struct TimeStamp")

this issue is unique to block 80543; other blocks from ckBTC can be fetched without any problems.

Also, this issue is occurring when using the DFINITY agent library in JavaScript.

I’m looking for insights on the root cause of this error and suggestions on how to resolve it. Has anyone encountered a similar problem or can provide guidance on addressing this issue?

2 Likes

Hi, regarding the start of your message, I think one of my colleague will be more useful than me but, I’m curious about the JS part. Can you tell me which library exactly and version?

Hi @jaesharma ,

We had to change the IDL definition of Approve blocks because it wasn’t matching the incoming ICRC-3 spec. The expires_at field written by the ckBTC Ledger was a struct instead of what it should be, that is a number. We still need to upgrade the libraries to follow the new schema.

@mariop
can you point me where i will find updated IDL file? I can use @dfinity/agent library with updated IDL to query this block then.

sure, @peterparker i’m using “@dfinity/agent”: “0.11.2”,

Ahhhhh thanks for the answer. Any particular reason why you do not use @dfinity/ledger-icrc?
It contains an up-to-date did files regarding that matters.

1 Like

was not familiar with this library. i’ll check. thanks.

1 Like

Great. In the same repo there is also in a @dfinity/ckbtc library. All these libs are used notably in NNS dapp. We keep those up-to-date. Let me know if you have any questions.

1 Like

Hello @peterparker ,
I’m experiencing difficulties in retrieving blocks using the “@dfinity/ledger-icrc” library. Here’s the code I’m attempting to run:


import { IcrcIndexCanister } from "@dfinity/ledger-icrc";

const agent = await createAgent({
  identity: id,
  host: "https://ic0.app",
});

const { getTransactions } = IcrcIndexCanister.create({
  agent,
  canisterId: "mxzaz-hqaaa-aaaar-qaada-cai",
});

const tx = await getTransactions({
  start: 0,
  length: 20,
});

Unfortunately, I’m encountering this error:

TypeError: Cannot destructure property 'owner' of 'undefined' as it is undefined.

I’ve also explored the “@dfinity/ckbtc” library, but I wasn’t able to find any solutions that would allow me to retrieve a specific block from Ckbtc. Can you provide any guidance or assistance on this matter? Thank you.

You do not use TypeScript I guess?

I think it’s because you don’t supply the account.

const tx = await getTransactions({
  start: 0,
  length: 20,
  account: {owner: etc...} // <---- This is missing
});

Params: https://github.com/dfinity/ic-js/blob/main/packages/ledger-icrc/src/types/index.params.ts#L4

@peterparker
if i supply account id then get another error.
this is updated code i’m trying to execute:

const tx = await getTransactions({
  max_results: 20,
  account: {
    owner: id,
  },
});

in this case i get this error:

                      ^

Error: Invalid record {max_results:nat; start:opt nat; account:record {owner:principal; subaccount:opt vec nat8}} argument: 

field account -> Invalid record {owner:principal; subaccount:opt vec nat8} argument: 

looking for answers of these questions:

  1. why we need to supply owner here?
  2. cause of this error? in javascript how to change nat8 or nat64 in nat type.

Type definition of the parameter:

export interface IcrcAccount {
  owner: Principal;
  subaccount?: Subaccount;
}

Are you sude your id is a Principal and not a string or something else?

You are looking to query the transactions. Those transactions are attached to an account. An account can be a user, a canister, or else. Anything or anyone that hold transactions through an account.

2 Likes

So this method will return transactions of that specific account only?

1 Like

Yes, that’s correct.

1 Like

Hello @peterparker ,
I’m continuing my efforts to find a solution for this issue, but I’m still unable to resolve it. I’ve also double-checked on the DFINITY dashboard, and the error there remains the same.

Could you please provide an update on the current status of this issue? Additionally, it would be greatly appreciated if you could direct me to the most recent version of the IDL for the ledger canister, which I can use to access transaction 80543 of the ckbtc token.

Which issue, the expires_at field? Don’t know much about this, @mariop knows best.
Or are you speaking about another issue?

I updated @dfinity/ledger-icrc last week. You can find the related did files in the repo or use the next version of the library (npm i @dfinity/ledger-icrc@next). Is this what you are looking for?

I’m currently working on resolving this problem:

My goal is to obtain transaction details using the ‘@dfinity/agent’ library. I’m avoiding the use of the ‘@dfinity/icrc-ledger’ library because it requires supplying an account owner, which doesn’t align with my current requirements. I attempted to utilize the ledger canister IDL from the ‘ledger-icrc’ repository, but I’m still encountering the same error when dealing with this specific transaction.

I don’t think it’s different but, you can try your luck with the did files from the IC main repo: https://github.com/dfinity/ic/tree/master/rs/rosetta-api/icrc1/ledger/ledger.did

I’ve given it a shot, but I’m still encountering same error. I’m finding it a bit challenging to grasp why this particular block is proving difficult to decode. If there have been any changes to the block or transaction definitions, I’m curious why this information (IDL or the part which got change for that specific transaction) hasn’t been made public yet. Additionally, it seems that the dashboard hasn’t been updated with the latest IDL, if there’s been any update at all.

Please keep me posted in this thread if you come across any updates or solutions.

Thanks for the trying and for the feedback! I’m also a consumer of the ledger rather than an actor so, I forwarded your question to the team. They’ll comeback with updates.

1 Like