Asset_holding_get doesn't recognize asset Id

After creating an asset in my sandbox environment,

$ goal asset create \
>   --creator INOJEZ5FFMO7QQOEVCY52VYTW6B5R6DUJV245UCVOVVLTDNKG2NMLQK56A \
>   --name "Some Asset" \
>   --unitname "UNIT" \
>   --total 1 \
>   --decimals 0
Issued transaction from account INOJEZ5FFMO7QQOEVCY52VYTW6B5R6DUJV245UCVOVVLTDNKG2NMLQK56A, txid DLQYPKL5EMY3XVA22RJA4G253D7FIOCC6XEJSMINY5W4JG2ODRNQ (fee 1000)
Transaction DLQYPKL5EMY3XVA22RJA4G253D7FIOCC6XEJSMINY5W4JG2ODRNQ still pending as of round 11
Transaction DLQYPKL5EMY3XVA22RJA4G253D7FIOCC6XEJSMINY5W4JG2ODRNQ still pending as of round 12
Transaction DLQYPKL5EMY3XVA22RJA4G253D7FIOCC6XEJSMINY5W4JG2ODRNQ committed in round 13
Created asset with asset index 1

I have this simple application that checks that the creator of the asset is the current holder.

#pragma version 4
// test_asset_holding_get.teal

addr INOJEZ5FFMO7QQOEVCY52VYTW6B5R6DUJV245UCVOVVLTDNKG2NMLQK56A
int 1
asset_holding_get AssetBalance
#pragma version 4
// clear.teal

int 1

But it fails to recognize the created asset,

$ goal app create \
> --creator INOJEZ5FFMO7QQOEVCY52VYTW6B5R6DUJV245UCVOVVLTDNKG2NMLQK56A \
> --approval-prog test_asset_holding_get.teal \
> --clear-prog clear.teal \
> --global-byteslices 0 \
> --global-ints 0 \
> --local-byteslices 0 \
> --local-ints 0
Couldn't broadcast tx with algod: HTTP 400 Bad Request: TransactionPool.Remember: transaction 3GO7UERI6RG5TPR7MIB3IF7DIK3MHMET5O3CPVUUKALVPGTMCT3Q: logic eval error: invalid Asset reference 1

And when try switching to #pragma version 3 instead, the program then expects an integer for the address,

logic eval error: asset_holding_get arg 0 wanted uint64 but got []byte

Does anybody know where I’m going wrong?

Here are the specs of my dev environment,

$ goal version -v
Version: [v1 v2]
GenesisID: sandnet-v1
Build: 2.7.1.stable [rel/stable] (commit #5e00bcd6)

Hi @Hardik,

You must use the Foreign Asset Array to work with ASA in Stateful ASC1. This means that you should not directly pass the Asset ID to asset_holding_get opcode, but you should instead specify the index of the argument passed through the Foreign Asset Array in the Application Call.

:man_facepalming: Of course - Thanks for the help!

1 Like