# interceptInitcode

Description: interceptInitcode 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/intercept-initcode.mdx

### Signature

```solidity
function interceptInitcode() external;
```

### Description

Causes the next contract creation (via new) to fail and return its initcode in the returndata buffer.
This allows type-safe access to the initcode payload that would be used for contract creation.
Example usage:

```solidity
vm.interceptInitcode();
bytes memory initcode;
try new MyContract(param1, param2) { assert(false); }
catch (bytes memory interceptedInitcode) { initcode = interceptedInitcode; }
```
