Seqno is one way to prevent Replay Attacks. When a transaction is sent to a wallet smart contract, it compares the seqno field of the transaction with the one inside its storage. If they match, it's accepted and the stored seqno is incremented by one. If they don't match, the transaction is discarded.
Without seqno (or another mechanism to prevent Replay Attacks), anyone (usually the receiver of funds) can read the transaction data (for example from blockchain explorers) and create another fake transaction and resend it to the original wallet smart contract and force it to resend TON once more, ultimately draining all of its funds.
Great question, seqno
is an interesting concept on TVM that will be highlight
Which is more like the the transaction number of the wallet sending the Tx. Like the nonce
on EVM world.
For more example, if you want to send the Txs through SDK to the blockchain, will use the code like this:
// (=== more codes === ) //
console.log("Interacting with Collection Contract: \n" + contract_address);
let seqno: number = await wallet_address.getSeqno();
let transfer = await wallet_address.sendTransfer({
seqno: seqno,
secretKey: keyPair.secretKey,
messages: [
internal({
value: toNano("0.5"),
to: contract_address,
init: {
code: init.code,
data: init.data,
},
bounce: true,
body: packed,
}),
],
});
You will need to get the seqno
first to send with the parameters in a Transaction.