Is there a way to get the total GAS provided to a transaction? gasLeft only provides the remaining gas at the time that it's called. Even when called immediately, there is a discrepancy, which I assume is related to the costs of invoking the function.
The objective I'm trying to achieve is to calculate what the balance of the callers address was immediately before the transaction.
I am using the following calculate it, however it seems to be off by a fair few Wei.
uint _gasleft = gasleft();
uint balanceBeforeTx = (_gasleft + 21000 ) * tx.gasprice + block.basefee + msg.value + address(msg.sender).balance;