> For the complete documentation index, see [llms.txt](https://startower.gitbook.io/star-tower-chain/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://startower.gitbook.io/star-tower-chain/untitled/smart-contract-verification/foundry-verification.md).

# Foundry Verification

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&#x20;

### Verify contract <a href="#verify-contract" id="verify-contract"></a>

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 Blockscout verification provider. API key for SAVWSCAN verification is optional.
2. Specify the `--verifier-url=<blockscout_homepage_explorer_url>/api/` flag for connecting to a specific SAVWSCAN instance (e.g., `--verifier-url=https://``savwscan.com/api/`).
3. You can specify most configuration options (e.g., evm version, disabling optimizations) via the usual Forge configuration

#### Example (Deploy and verify) <a href="#example-deploy-and-verify" id="example-deploy-and-verify"></a>

Verify a contract with SAVWSCAN right after deployment (make sure you add "/api/" to the end of the Blockscout 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) <a href="#example-verify-already-deployed-contract" id="example-verify-already-deployed-contract"></a>

```
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/
```
