Short answer: The same call throws an error with HTTP status 404 and the message "account asset info not found". Catch it and treat 404 as "not opted in".
// algod = new algosdk.Algodv2("", "https://testnet-api.algonode.cloud", 443)
// indexer, addr (an account address) and USDC (asset id 10458941 on TestNet) are set up before the call
async () => {
try { await algod.accountAssetInformation(unfunded, USDC).do(); return { optedIn: true }; }
catch (e) { return { optedIn: false, status: e.status, message: String(e.response?.body?.message || e.message) }; }
}
{
"optedIn": false,
"status": 404,
"message": "Network request error. Received status 404 (Not Found): account asset info not found"
}
Run against a public TestNet node with algosdk 3.9.0 on 2026-12-03. Amounts are shown as strings because they are bigints.
e.status (404) and e.message held the text "Network request error. Received status 404 (Not Found): account asset info not found". In this run e.response.body.message was empty, so read e.message.All how-tos · howto.json · SDK errors · API errors · costs