hi
const seqno = await wallet.methods.seqno().call();
This code cannot get seqno and the return value is null. Is there any possible error that could cause this?
Jan 5, 2024, 6:55 PM
If wallet is uninitialized, it will return null. You should do ?? 0 then.
Jan 6, 2024, 5:53 AM
const TonWeb = require('tonweb');
const tonweb = new TonWeb(new TonWeb.HttpProvider('https://toncenter.com/api/v2/jsonRPC', {apiKey: '3b617d26c48aebc729cf5c4601f4732c0cf14331674ad4762e419180704d1330'}));
const wallet = tonweb.wallet.create({address: 'EQAI9IoJmk--P5U9i4wa3UpI0juy-zcF-vJclvWS5NUa58Vh'});
async function sendTransfer() {
console.log(tonweb)
const seqno = await wallet.methods.seqno().call();
console.log(seqno);
}
sendTransfer();
const tonweb = new TonWeb(new TonWeb.HttpProvider('https://toncenter.com/api/v2/jsonRPC', {apiKey: '3b617d26c48aebc729cf5c4601f4732c0cf14331674ad4762e419180704d1330'}));
const wallet = tonweb.wallet.create({address: 'EQAI9IoJmk--P5U9i4wa3UpI0juy-zcF-vJclvWS5NUa58Vh'});
async function sendTransfer() {
console.log(tonweb)
const seqno = await wallet.methods.seqno().call();
console.log(seqno);
}
sendTransfer();
Jan 6, 2024, 5:54 AM
Are you familiar with ?? JS operator?
Jan 6, 2024, 5:56 AM
Do I need to call a method on tonweb to activate this address?
Jan 6, 2024, 5:57 AM
Outgoing transfer will do that.
Jan 6, 2024, 5:59 AM
I have already transferred money to this address
Jan 6, 2024, 6:00 AM
Yes, and money is there. How the contract would become init when money is transferred?
Jan 6, 2024, 6:01 AM
You must obtain seqno before transferring money, but when I call the tonweb SDK method to obtain seqno, it is null. I don’t understand whether there is a problem with my code or what other operations need to be done.
Jan 6, 2024, 6:05 AM
When seqno is null, it shall be replaced with zero.
Jan 6, 2024, 6:06 AM
ok i try again
thanks
Jan 6, 2024, 6:10 AM
Review your implementation carefully, making sure to follow these steps. It's crucial to obtain the sequence number (seqno) before proceeding:
Note that you most get the seqno first
1. const seqno = await WalletContract.getSeqno(); //Outside your whileloop if are useing try() it should be outside the try()
2. let currentSeqno = seqno; //outside the whileloop
3. while (currentSeqno == seqno) { //set your while condition like so
console.log("waiting for transaction to confirm...");
await sleep(1500);
currentSeqno = await walletContract.getSeqno();
}
console.log("transaction confirmed!");
}
Note that you most get the seqno first
1. const seqno = await WalletContract.getSeqno(); //Outside your whileloop if are useing try() it should be outside the try()
2. let currentSeqno = seqno; //outside the whileloop
3. while (currentSeqno == seqno) { //set your while condition like so
console.log("waiting for transaction to confirm...");
await sleep(1500);
currentSeqno = await walletContract.getSeqno();
}
console.log("transaction confirmed!");
}
Jan 6, 2024, 6:33 AM