mirror of
https://github.com/luxfi/eoa-contracts.git
synced 2026-10-30 16:58:32 +00:00
17 lines
474 B
Solidity
17 lines
474 B
Solidity
// SPDX-License-Identifier: MIT
|
|
pragma solidity 0.8.17;
|
|
|
|
// Generic contract for estimating gas on any target and data
|
|
contract GasEstimator {
|
|
function estimate(
|
|
address _to,
|
|
bytes calldata _data
|
|
) external returns (bool success, bytes memory result, uint256 gas) {
|
|
// solhint-disable
|
|
uint256 initialGas = gasleft();
|
|
(success, result) = _to.call(_data);
|
|
gas = initialGas - gasleft();
|
|
// solhint-enable
|
|
}
|
|
}
|