Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting UTXO balance insufficient error for token transfer #501

Open
Karthi96 opened this issue Jun 16, 2022 · 0 comments
Open

Getting UTXO balance insufficient error for token transfer #501

Karthi96 opened this issue Jun 16, 2022 · 0 comments

Comments

@Karthi96
Copy link

Hi,

we have integrated the Flint wallet into our DApp and we are using ReactJS as a programming language. The use case we are trying to do is transfer the tokens from the user wallet to the other user.

For token transfer, we are getting all the UTXOs of the user wallet and passing them all to the transaction body. In our case, the user has around ~81 ADA and 100 tokens in the wallet, so that means he has sufficient funds to make a transfer operation. But when we do a transfer we are getting the error as UTXO Balance Insufficient Error but when we do a direct transfer from flint wallet, it is getting success.

so the problem is why we are not able to submit the transaction when we submit using flint? As per your documentation, you are saying to pass all the UTXOs to the transaction body, then why are we getting this error?

How do we resolve this or are we missing anything here?

Attaching the UTXos of the user wallet addr_test1qr0jvqh3yv7r5z7mpnnyd4pjsquxvdltcdgxgc6ws535ntqu08537zvx8rvclq63hg7d2amtzk57m9qg8vngjhcd9nwsvg5nzl before transfer and after transferring for reference.

Screenshot from 2022-06-15 17-49-31

Transaction Hash - https://testnet.cardanoscan.io/transaction/617a2d70de12ead82e73c3c5170b68e1cf02a4eeab5eaf8cb49bdc9b84e7126c

Here is the code what we are using in DApp

      const txBuilder = await initTransactionBuilder();
      const changeAddress = await getChangeAddress();
      const shelleyOutputAddress = Address.from_bech32(transferWalletAddress);
      const shelleyChangeAddress = Address.from_bech32(changeAddress);

      let txOutputBuilder = TransactionOutputBuilder.new();
      txOutputBuilder = await txOutputBuilder.with_address(shelleyOutputAddress);
      txOutputBuilder = await txOutputBuilder.next();

      const multiAsset = MultiAsset.new();
      const assets = Assets.new();
      assets.insert(
        AssetName.new(Buffer.from(assetNameHex, 'hex')), // Asset Name
        BigNum.from_str(assetQuantity) // How much to send
      );
      multiAsset.insert(
        ScriptHash.from_bytes(Buffer.from(assetPolicyIdHex, 'hex')), // PolicyID
        assets
      );

      txOutputBuilder = txOutputBuilder.with_asset_and_min_required_coin(multiAsset, BigNum.from_str(protocolParams.coinsPerUtxoWord));
      const txOutput = txOutputBuilder.build();

      await txBuilder.add_output(txOutput);

      // Find the available UTXOs in the wallet and
      // us them as Inputs
      const txUnspentOutputs = await getTxUnspentOutputs();
      txBuilder.add_inputs_from(txUnspentOutputs, 3);

      // calculate the min fee required and send any change to an address
      txBuilder.add_change_if_needed(shelleyChangeAddress);

      // once the transaction is ready, we build it to get the tx body without witnesses
      const txBody = await txBuilder.build();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant