So this is what I am trying to achieve :
I have an Escrow account that is holding 1 ASA and some Algos to do transactions (let say 1 algo).
Then somebody buys this ASA for 10 algos. So now the Escrow account holds 0 ASA and around 11 Algos.
This works fine.
Then now is the part I am trying to make it work.
I am trying to delete the App (aka Escrow account) and empty it (with repartition) in the same Atomic transfer. I want 8 of these algos to go the 1 person (creator of the ASA), and the rest to me, like for a commission.
When I don’t specify any CloseRemainerTo, the money (8 algos) goes fine to the creator, and the app is deleted, but as soon as I specify the CloseRemainerTo, the transaction is not valid and I got :
"TransactionPool.Remember: transaction 3FG2QRBUM7357GWVTVM33YUHSKWJ73AJ7F7OKAC2PC3LTME6I7VA: cannot close: 1 outstanding assets"
So I am wondering , what am I doing wrong ? Maybe it’s an ordering of the two transactions in the atomic array ? Maybe I need to set a third transaction that does only the CloseRemainer ? Or maybe I need to un-opt from the ASA first ? or ME optIn in the ASA ?
const callTxn = algosdk.makeApplicationDeleteTxn( MY_ADDR, params, appId ) const paymentTxn = algosdk.makePaymentTxnWithSuggestedParams( ESCROW_ADDR, CREATOR_ADDR, ASA_PRICE * 800000, // price is fine since it works without CloseRemainerTo) MY_ADDR, // This breaks everything new Uint8Array(0), params ) algosdk.assignGroupID([paymentTxn, callTxn]) // order OK ? // ME I am signing the delete app call const signedCall = callTxn.signTxn(plateformSK) // The escrow account sign the payment to the creator of ASA (8 algos) const lsig = new algosdk.LogicSigAccount( new Uint8Array(Buffer.from(XX, 'base64')) ) const signedPayment = algosdk.signLogicSigTransaction( paymentTxn, lsig ) const signed = [signedPayment.blob, signedCall] // Order OK ? const createTxId = await algodClient.sendRawTransaction(signed).do()
Thanks you guys so much!!!