prank
Signature
function prank(address msgSender) external;
function prank(address msgSender, bool delegateCall) external;
function prank(address msgSender, address txOrigin) external;
function prank(address msgSender, address txOrigin, bool delegateCall) external;
Description
prank(address msgSender)
: setsmsg.sender
to the specified address for the next call. “The next call” includes static calls as well, but not delegate calls or calls to the cheat code address.prank(address msgSender, address txOrigin)
: setsmsg.sender
and thetx.origin
addresses for the next call.prank(address msgSender, bool delegateCall)
: ifdelegateCall
value istrue
then setsmsg.sender
to the specified address for the next delegate call.prank(address msgSender, address txOrigin, bool delegateCall)
: ifdelegateCall
value istrue
then setsmsg.sender
and thetx.origin
addresses for the next delegate call.
ℹ️ Note
The delegate calls cannot be pranked from an EOA.
Examples
/// function withdraw() public {
/// require(msg.sender == owner);
vm.prank(owner);
myContract.withdraw(); // [PASS]
SEE ALSO
Forge Standard Library