pub fn caller_gas_allowance<DB>(
db: &mut DB,
env: &impl TransactionEnv,
) -> Result<u64, EthApiError>where
DB: Database,
EthApiError: From<<DB as Database>::Error>,
Available on crate feature
rpc
only.Expand description
Calculates the caller gas allowance.
allowance = (account.balance - tx.value) / tx.gas_price
Returns an error if the caller has insufficient funds.
Caution: This assumes non-zero env.gas_price
. Otherwise, zero allowance will be returned.
Note: this takes the mut [Database] trait because the loaded sender can be reused for the
following operation like eth_call
.