Byte to int (vice versa) conversion and comparison in Teal

Right, thanks! I think know the issue.

The code I’m debugging creates Stateful contract from SDK. Thus, passing args like this:

appArgs.push(new Uint8Array(Buffer.from("myString")));
appArgs.push(new Uint8Array(Buffer.from(assetID.toString())));

This makes AssetID arg in Teal as byte and 1 becomes 49 after btoi.

On the other hand with goal cli --app-arg "int:1" arg keeps value as 1. As a result this block becomes valid:

gtxn 1 XferAsset // 1
load 11 //1
==

I can’t find the equivalent SDK code for int type arg (--app-arg "int:1") in the documentation. I see the example for Stateless contract: args.push(algosdk.encodeUint64(123)); but this gives the error
err TypeError: algosdk.encodeUint64 is not a function.

1 Like