Currently, I am working on integrating an Algorand smart contract with a Next.js application. To sign transactions, I am utilizing Pera wallet. However, I have encountered an issue when attempting to call methods from the contract on the front end using the ABI and AtomicTransactionComposer. The error message received is as follows:
URLTokenBaseHTTPError: Network request error. Received status 400 (): TransactionPool.Remember: transaction BCJJTOCFMIZOJZNRKDFCIOPMXWRFUUQ24DDJWGJWRD46UXUYSZ7A: logic eval error: invalid Box reference 0x3239303135313533. Details: pc=587, opcodes=frame_dig -1; extract 2 0; box_get
Below is the relevant code snippet where I attempt to call the method in the smart contract:
const algodToken = '';
const algodServer = 'https://testnet-api.algonode.cloud';
const algodPort = undefined;
const algodClient = new algosdk.Algodv2(algodToken, algodServer, algodPort);
const suggestedParams = await algodClient.getTransactionParams().do();
console.log('suggestedParams:', suggestedParams);
const contract = new algosdk.ABIContract(myabi);
const atc = new algosdk.AtomicTransactionComposer();
atc.addMethodCall({
suggestedParams,
sender: account,
signer: async (unsignedTxns) => {
const txnGroups = unsignedTxns.map((t) => ({txn: t, signers: [t.from]}));
return await peraWallet.signTransaction([txnGroups]);
},
appID: 468709015,
method: algosdk.getMethodByName(contract.methods, 'readFundsWithdrawnStatus'),
methodArgs: [APN],
});
const results = await atc.execute(algodClient, 3);
console.log(`Contract read success ` + results.methodResults);
return results.methodResults
The specific method that I am trying to call in the smart contract is as follows:
@app.external
def readFundsWithdrawnStatus(item_name: abi.String, *, output: abi.Bool) -> Expr:
existing_sender_funds_item = SenderFundsContract()
return Seq(
existing_sender_funds_item.decode(app.state.sender_funds_item[item_name.get()].get()),
output.set(existing_sender_funds_item.fundsWithdrawn)
)
I suspect that the network error may be due to either the methodArg being passed or potential issues with the AppID deployment. Any insights would be greatly appreciated.