simulateAndRevert method
Future<SafeContractEncodedCall>
simulateAndRevert({
- required ETHAddress targetContract,
- required List<
int> calldataPayload,
override
"stateMutability": "nonpayable",
Executes a DELEGATECALL to the specified targetContract
within the context of the current contract (self).
Notes:
- The call is internally reverted to prevent state changes, making this method effectively static (read-only).
- When reverted, the revert data encodes the execution result as:
abi.encodePacked(uint256(success), uint256(response.length), bytes(response))
This means the returned data layout is: success:uint256 || response.length:uint256 || response:bytes
Parameters:
targetContract: Address of the contract containing the code to execute.calldataPayload: Calldata sent to the target contract (includes the encoded function selector and arguments).
Implementation
@override
Future<SafeContractEncodedCall> simulateAndRevert({
required ETHAddress targetContract,
required List<int> calldataPayload,
}) async {
final params = [targetContract, calldataPayload];
return encodeTransactionCall(
functionName: SafeContractFunction.simulateAndRevert,
params: params,
);
}