Closed maschad closed 1 month ago
@maschad this is already possible. The receipt of type script return will be present within the receipts array that will be present within the FuelError metadata property.
However, it is important to be aware that this value won't represent the real gas used.
Since the transaction failed, the Sway project code was not entirely executed, therefore the gas consumed does not represent the gas that would be consumed if the same transaction succeeds.
I believe we can close this issue
@Torres-ssf thanks for clarifying that, and upon reconsideration I think it would probably be more appropriate for the consumer to handle errors related to low gas costs and then allow the user to proceed with the transaction, rather than forcing them to handle all errors.
Currently, when calculating gas costs for a transaction, if there is an error during the dry run it is thrown and no gas costs are returned.
For many use cases this is sufficient, but there are also scenarios where a consumer may still want the gas costs even if an error happened during the dry run, such as in a DEX, here's an example use case taken from this forum post
We should refactor this method to return both the error and the gas cost to accommodate for such a scenario.