# Foundry Verification

[Foundry](https://github.com/foundry-rs/foundry/) is a smart contract development toolchain. Foundry manages your dependencies, compiles your project, runs tests, deploys, and lets you interact with the chain from the command line and via Solidity scripts.

Forge is a command-line tool that ships with Foundry. Forge tests, builds, and deploys your smart contracts. Forge supports contract verification out of the box (<https://book.getfoundry.sh/reference/forge/forge-verify-contract>)

## Verify contract

In forge, contracts can be verified at the time of the deployment (e.g. using `forge script`), or later, if the contracts are already deployed (e.g. using `forge verify-contract`).

#### Tips:

1. Specify the `—verifier=blockscout` flag to use the Quaiscan verification provider. API key for Quaiscan verification is optional.
2. Specify the `--verifier-url=<blockscout_homepage_explorer_url>/api/` flag for connecting to a specific Quaiscan instance (e.g., `--verifier-url=https://eth-sepolia.blockscout.com/api/`).
3. You can specify most configuration options (e.g., evm version, disabling optimizations) via the usual Forge configuration (see <https://github.com/foundry-rs/foundry/blob/master/config/README.md>).

### Example (Deploy and verify)

Verify a contract with Quaiscan right after deployment (make sure you add "/api/" to the end of the Quaiscan homepage explorer URL):

```
forge create \
  --rpc-url <rpc_https_endpoint> \
  --private-key $PRIVATE_KEY \
  <contract_file>:<contract_name> \
  --verify \
  --verifier blockscout \
  --verifier-url <blockscout_homepage_explorer_url>/api/
```

Or if using foundry scripts:

```
forge script <script_file> \
  --rpc-url <rpc_https_endpoint> \
  --private-key $PRIVATE_KEY \
  --broadcast \
  --verify \
  --verifier blockscout \
  --verifier-url <blockscout_homepage_explorer_url>/api/
```

### Example (Verify already deployed contract)

```
forge verify-contract \
  --rpc-url <rpc_https_endpoint> \
  <address> \
  <contract_file>:<contract_name> \
  --verifier blockscout \
  --verifier-url <blockscout_homepage_explorer_url>/api/
```

Or if using foundry scripts for last executed script run:

```
forge script <script_file> \
  --rpc-url <rpc_https_endpoint> \
  --private-key $PRIVATE_KEY \
  --resume \
  --verify \
  --verifier blockscout \
  --verifier-url <blockscout_homepage_explorer_url>/api/
```


---

# Agent Instructions: 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:

```
GET https://docs.quaiscan.io/developer-support/smart-contract-verification/foundry-verification.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
