Stellar Asked by Ether on August 21, 2021
I am using stellar sdk to send payments from one account to another. When i send payment one by one , there is no error . everything works fine. However when i try to send payments in batch i get error “tx_bad_seq” randomly for few records. I understand the reason for the error , but how can i avoid them ? also the document says even if i get “tx_bad_seq” , the transaction may be valid in future. This is very risky for payments? any help here will be highly appreciated! thanks!
var transaction = new StellarSdk.TransactionBuilder(publickey)
.addOperation(
StellarSdk.Operation.payment({
destination: destAcct,
asset: StellarSdk.Asset.native(),
amount: amountToTransfer
})
)
.setTimeout(5000)
.build();
transaction.sign(
StellarSdk.Keypair.fromSecret(SecretKey)
);
return server.submitTransaction(transaction);
I have checked the post at Error tx_bad_seq , but the node js code pointed out does not demonstrate how to get sequence number and pass it to transaction
i read on channels and went through other similar questions , i created one new channel account and to make it active transferred 1 lumen into channel account , my code now looks like
var transaction =
new StellarSdk.TransactionBuilder(channelAccount)
.addOperation(StellarSdk.Operation.payment({
source: sourcePublicKey,
destination: destAcct,
asset: StellarSdk.Asset.native(),
amount: config.amountToTransfer
}))
// Wait a maximum of three minutes for the transaction
.setTimeout(180)
.build();
transaction.sign(StellarSdk.Keypair.fromSecret(sourceSecretKey)); // base account must sign to approve the payment which is merchant account
transaction.sign(StellarSdk.Keypair.fromSecret(channelSecretKey));
However i get "tx_insufficient_balance" error in response , i want all fees to go through sourcePublicKey which has more then 100 lumens . am i missing something here?
Answered by Ether on August 21, 2021
To avoid tx_bad_seq error during payment, you should use channel account of sender account. Channel account is going to submit the transaction on behalf of sender account. Channel account and sender account both sign the transaction. I am sharing the link below.
Answered by Shan Gorai on August 21, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP