Successful transaction marked as failed

@mpoplavkov I am deeply sorry if my explanations weren’t clear enough

About your code:

To avoid the transaction reverting, we need to specifically set the transaction’s gasLimit and the maxFee:

  let request = new ScriptTransactionRequest();

    // Adds a `CoinOutput` in favor of the receiver to the TX outputs 
    request = wallet.addTransfer(request, {destination: destinationB256Address, amount: fractionalAmount, assetId});

    const txCost = await wallet.getTransactionCost(request);
    request.gasLimit = txCost.gasUsed;
    request.maxFee = txCost.maxFee;

    // Fetches and add resources (ChageOutput is added for the resources owner)
    request = await wallet.fund(request, txCost);

Why did the funds get transferred?

  • Gas Limit Not Set: The transaction’s gasLimit was not set, so it defaulted to 0. The network accepts the transaction but it reverts due to an OutOfGas error during execution.
  • Spent Inputs: After the transaction reverts, the Fuel VM still spends the transaction inputs for the reason of preventing users from spamming the network with invalid transactions without incurring any fees.
  • Fee Deduction: The VM deducts the fee for its use up to the point of failure from the total amount of the spent inputs.
  • UTXO Generation for CoinOutput: The VM generates new UTXOs for every CoinOutput specified in the transaction. This is why the recipient received their funds despite the transaction reverting. So, since resources were spent, the VM will also generate new ones specified by every CoinOutput.
  • Change UTXO Creation: After generating UTXOs for each CoinOutput, the VM creates a new UTXO with the remaining amount (change) for the address specified in the ChangeOutput of that asset ID. This step ensures that the entity funding the transaction doesn’t lose all their resources. This is why the amount of the ChangeOutput is determined only during execution time.

Please let me know if this clarifies your question.