> For the complete documentation index, see [llms.txt](https://docs.eridian.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.eridian.xyz/ethereum-dev/foundry-notes/useful-commands/forge.md).

# Forge

### Inspect

{% code title="List out all the methods and function selectors in a contract" %}

```bash
forge inspect <CONTRACT_NAME> methods
```

{% endcode %}

{% code title="Inspect contract and view storage layout" %}

```bash
forge inspect <CONTRACT_NAME> storageLayout
```

{% endcode %}

{% code title="Create .gas-snapshot for all tests" %}

```bash
forge snapshot
```

{% endcode %}

{% hint style="info" %}
If you see the error `EvmError: NotActivated` when trying to deploy contracts using `forge` it may be that you need to explicitly set the `--evm-version` when running the forge command.

The evm version can also be set in the `foundry.toml` file:

```toml
[profile.default]
evm_version = "cancun"
```

{% endhint %}

### Contract Verification

If automatic contract verification fails during deployment it can be performed manually using forge.

{% code overflow="wrap" %}

```bash
forge verify-contract <CONTRACT_ADDRESS> ./src/<CONTRACT>.sol:<CONTRACT_NAME> --chain-id <CHAIN_ID> --watch --etherscan-api-key <ETHERSCAN_API_KEY>
```

{% endcode %}

* `--watch` leaves the terminal waiting for a status confirmation reply.
* If constructor arguments are required they can be encoded using `cast` e.g for a constructor requiring a single address:

```solidity
cast abi-encode "constructor(address)" <ADDRESS_TO_PASS_INTO_CONSTRUCTOR>
```

* Then use that `cast` output  to add `--constructor-args` to the end of the `forge verify-contract` command.

{% hint style="info" %}
For Ethereum L1 or L1 testnets use the Etherscan API key: <https://etherscan.io/myapikey>

For L2s (e.g. Base) or L2 testnets use a Basescan API key (but still call it `--etherscan-api-key` in the command): <https://basescan.org/myapikey>
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.eridian.xyz/ethereum-dev/foundry-notes/useful-commands/forge.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
