1

When using the DELEGATECALL opcode via assembly, we can pass a specific amount of gas:

let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)

But the high-level DELEGATECALL does not have such argument:

(bool success, bytes memory returndata) = target.delegatecall(data);

How can we alter the gas stipend that we give to the delegated contract?

1 Answer 1

2

You can specify the gas using the gas modifier (in brackets) before the function args, e.g.:

(bool success, bytes memory returndata) = target.delegatecall{ gas: 10000 }(data);

The modifiers are documented here:

https://docs.soliditylang.org/en/v0.8.16/types.html#address

1

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.