next.jserror-handlingsequenceton

How to retrieve SEQNO with TONWEB SDK


image from the object Hello stackoverflow community, this is my first question and I will try to be as much detailed as I can.

Question:

I am trying to retrieve SEQNO with TONWEB SDK but I am running into an error. I think I know where the error is but I do not know how to resolve it.

When I use const wallet = useTonWallet() and log it to the console I get objects but I think the SEQNO object is missing.

This is how I try to retrieve the SEQNO in nextjs

const getSeqno = await wallet.methods.seqno().call(); console.log(getSeqno);

according to the tonweb docs the above is the correct way.

and when I am doing that I get this error

TypeError: Cannot read properties of undefined (reading 'seqno')

I will upload an image with the objects from the const wallet = useTonWallet()


Solution

  • After connecting tonweb to a toncenter apis do this. Also need to check the code inside that useTonWallet function

    const key = await mnemonicToKeyPair(mnemonic.split(" "));
    const WalletClass = tonweb.wallet.all["v3R2"];
    const wallet = new WalletClass(tonweb.provider, { publicKey: key.publicKey });
    const seqno = await wallet.methods.seqno().call() || 0;