# prank

Description: prank cheatcode documentation

Note: This document was authored using MDX

  Source: https://github.com/NomicFoundation/hardhat-website/tree/main/src/content/docs/docs/reference/cheatcodes/Environment/prank.mdx

  Components used in this page:
    - :::note: An informational callout block. Supports custom title `:::note[Title]` and icon `:::note{icon="name"}` syntax.

{/* This document contains content copied/adapted from the Foundry Book (MIT licensed). See LICENSE in the parent directory. */}

### Signature

```solidity
function prank(address msgSender) external;
```

```solidity
function prank(address msgSender, bool delegateCall) external;
```

```solidity
function prank(address msgSender, address txOrigin) external;
```

```solidity
function prank(address msgSender, address txOrigin, bool delegateCall) external;
```

### Description

- `prank(address msgSender)`: sets `msg.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 cheatcode address.
- `prank(address msgSender, address txOrigin)`: sets `msg.sender` and the `tx.origin` addresses **for the next call**.
- `prank(address msgSender, bool delegateCall)`: if `delegateCall` value is `true` then sets `msg.sender` to the specified address **for the next delegate call**.
- `prank(address msgSender, address txOrigin, bool delegateCall)`: if `delegateCall` value is `true` then sets `msg.sender` and the `tx.origin` addresses **for the next delegate call**.

:::note
The delegate calls cannot be pranked from an EOA.
:::

### Examples

```solidity
/// function withdraw() public {
///     require(msg.sender == owner);

vm.prank(owner);
myContract.withdraw(); // [PASS]
```

### SEE ALSO

Forge Standard Library

[`hoax`](https://getfoundry.sh/reference/forge-std/hoax)
