Hi, I’m new to Algorand.
I created a Stateful SmartContract with the method claim_asset that can be called from any account that opts in.
It has asset_id arguments.
When I called from AlgoSDK js with just makeApplicationCallTxn it worked,
And also when I built AtomicTransactionComposer with addMethodCall it also worked.
But when I try to add multiple addMethodCall with different asset_id arguments it fails with the error transaction already in ledger.
Any idea what might be the cause?
Do I implement the AtomicTransfer wrong?
The error is thrown when a transaction with such ID was seen previously. Please double check you are calling the method with actual different value in asset_id. I think it is quite common when developing an app to re-run an app that sends the same transactions (since there is no difference in parameters between runs) so a workaround for this is to set the Note field to some unique value per run/send. In this case rerunning you app for the same asset_id, sender and other fields.
Thanks for the response.
Yep, I found out the error was the signer that I use for the AtomicTransaction group.
signer: async (unsignedTxn) => unsignedTxn.map((t) => t.signTxn(owner.sk)),
Idk what exactly happened but it seems the value of the signer got cached or something while running the loop.
When I try to send a Dryrun request it produces the same signature for each transaction.
To fix the problem I used makeBasicAccountTransactionSigner from algosdk to create the signer and it worked.