I’m making my way through the Smart Contract docs and have a couple points I hope someone can clarify for me. I’m looking at the Hash Time Lock Contract template (https://developer.algorand.org/docs/reference/teal/templates/htlc/) and the SDK page (https://developer.algorand.org/docs/features/asc1/sdks/).
- So after I initialize the client and params, I would do something like this to initialize the HTLC contract account:
let program = new Uint8Array(Buffer.from(" txn Fee
[…] ", “base64”));
let args = [“placeholder_receiver_addr”, “sha256”, “placeholder_hashimg”, params.lastRound+parseInt(3000), “placeholder_own_addr”, algodclient.suggestedFee()+parseInt(100)];
let lsig = algosdk.makeLogicSig(program, args);
So the HTLC account is expecting 6 parameters (TMPL_RCV, TMPL_HASHFN, TMPL_HASHIMG, TMPL_TIMEOUT, TMPL_OWN, TMPL_FEE), does it assume based on the order of args I passed that algodclient.suggestedFee()+parseInt(100)] is TMPL_FEE, seems like I never defined the names of the arguments anywhere.
https://developer.algorand.org/docs/reference/teal/templates/htlc/ mentions the contract is checking that TMPL_HASHFN(arg_0) is equal to TMPL_HASHIMG, is arg_0 the first argument I’m passing when I compile the logsig (“placeholder_receiver_addr”), or does it refer to something else?
- Since Alg Smart Contract only yield true/false and doesn’t create transactions, for HTLC, when the time expires, the amount is not automatically disbursed to TMPL_OWN. So someone has to create another transaction with Receiver = TMPL_OWN to get it approved by the HTLC account, right? So if I’m using HTLC in an application, I would save the TMPL_TIMEOUT in my server and create a separate transaction if the HTLC address still has balance after TMPL_TIMEOUT.