I’m learning the SDKs and in the process of building a simple app in order to better understand how the heck it all works.
I’ve deployed an app to the testnet (app-id 15014315).
I’ve had no issues interacting with this app in python using PyTeal and algosdk.
I’m now trying to interact with this app using Algosigner and javascript.
In my testing in python, I was able to OptInto the contract without passing any arguments. I can then call the application as many times as I want and pass “Again” as the argument.
My two questions are, how do I create an Application OptIn transaction in Javascript using AlgoSigner? and how do I properly format the appArgs?
I would expect the below to work, but i receive “TEAL runtime encountered err opcode” when executing the signTransaction()
function signTransaction(){
AlgoSigner.sign({
type: 'appl',
from: document.getElementById('from').value,
appArgs: ["Again"],
fee: txParams['fee'],
firstRound: txParams['last-round'],
lastRound: txParams['last-round'] + 1000,
genesisID: txParams['genesis-id'],
genesisHash: txParams['genesis-hash'],
appIndex: 15014315
})
.then((d) => {
signedTx = d;
})
.catch((e) => {
console.log(e);
});
}
function sendTransaction(){
AlgoSigner.send({
ledger: 'TestNet',
tx: signedTx.blob
})
}
If I change the appArgs to the following then the signTransaction function works. But when I go to send the transaction I get the error “invalid ApplicationArgs index 0”
appArgs: null,
If I change the appArgs to just have the string “Again” in it. Then the signTransaction functionr eturns the error “appArgs must be an Array of Uint8Array.”
appArgs: "Again",
How can I create a Unit8Array containing just one argument, which would be the word “Again”?
Thanks for whoever reads this and is able to help!