#Tealscript: Encountered "Unavailable Asset" error when trying to opt-in a smart contract to an asset

21 messages · Page 1 of 1 (latest)

tender oyster
#

Hi, I am trying to opt-in a smart contract to an ASA asset but got the Unavailable Asset error when running the opt-in code.

This is the Tealscript code that I have to opt-in to the asset

   assert(this.txn.sender === this.sender.value);
   assert(!this.app.address.isOptedInToAsset(this.assetId.value));

   verifyPayTxn(mbrTxn, {
     receiver: this.app.address,
     amount: globals.minBalance + globals.assetOptInMinBalance,
   });

   sendAssetTransfer({
     xferAsset: this.assetId.value,
     assetAmount: 0,
     fee: 0,
     assetReceiver: globals.currentApplicationAddress,
   });
 }```
hot jay
tender oyster
hot jay
tender oyster
hot jay
echo viper
#

Are you using the typescript appclient? If so, you can set populateAppCallResources: true in transactionsParams. This will automatically provide the reference to the asset for you

prime mist
#

Hey @tender oyster, just checking in—let us know if you're still experiencing the issue or if we can go ahead and close it

tender oyster
tender oyster
echo viper
#

can you share the code snippet where you are setting populateAppCallResources: true?

tender oyster
normal reef
#

Don’t have assets listed thee at all. That might ne telling populate to NOT do that part.

echo viper
#

yeah like Patrick said, try

    { mbrTxn: transaction },
    { populateAppCallResources: true }
  );
tender oyster
#

ok, I will try that. Thanks!

prime mist
#

@tender oyster let us know if you are still facing issue or if its resolved

placid ember
#

Hello everyone Please I am working on a smart contract and this error was developed on testing any idea the possible cause and available solution: Network request error. Received status 400 (): TransactionPool.Remember: transaction X5FZRJDVQ6KSHHRYEHF5IKEGEWV4ICDTBQI5DC3UKGAZR5SKGOKA: transaction rejected by ApprovalProgram. Aborting payment

normal reef
#

it just means your contract is simply failing - and not via an assert (err) - exiting not returning a positive value.

placid ember
hybrid raptorBOT
#

Gave +1 Rep to @normal reef (current: #4 - 140)