1

not sure if this is possible, but I was wondering if one function can calculate the gas cost of another function?

Also can a function run a series of computations to match the gas cost of the function?

function checkGasCostToRunFunctionX() public view returns(uint) {
  return uint(gasCostOfRunningFunctionX())
}

function functionX() public {
 10000000000000000000000 + 10000000000000000000000;
}

function cloneFunctionXGasCost() public {
// small computation
1 + 1;
someKindOfPaddingComputationToMakeThisFunctionCostTheSameAsFunctionX;
}

function checkCloneFunctionCostsSameAsFunctionX() public view returns(uint) {
 if (gasCostOfFunctionX == gasCostOfCloneFunction) {
    return = true;
}

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.