# Contract Verification Guide
## Getting Encoded Constructor Arguments
Look at the deployment transaction's initialization code to get the encoded constructor arguments.
Find the first constructor argument (like <CONTRACT_ADDRESS>) in the raw initialization code. Everything after this point contains the constructor arguments.
Alternative: Use [https://abi.hashex.org/](https://abi.hashex.org/)
## Method 1: Foundry Verify + JSON Input
Command to run in the repository:
```bash
forge verify-contract <CONTRACT_ADDRESS> <CONTRACT_PATH>:<CONTRACT_NAME> \
--optimizer-runs=<OPTIMIZER_RUNS> \
--constructor-args "<CONSTRUCTOR_ARGS>" \
--chain-id <CHAIN_ID> \
--show-standard-json-input > etherscan.json
```
Values to replace:
- `<CONTRACT_ADDRESS>`: Deployed contract address
- `<CONTRACT_PATH>`: Contract file path (e.g., `src/contracts/MyContract.sol`)
- `<CONTRACT_NAME>`: Contract name
- `<OPTIMIZER_RUNS>`: Optimizer runs (200 by default)
- `<CONSTRUCTOR_ARGS>`: Encoded constructor arguments (no 0x prefix)
- `<CHAIN_ID>`: Network ID
Next steps:
1. Open Etherscan
2. Pick "Solidity (Standard-JSON-Input)"
3. Use the `etherscan.json` file
This method is more reliable for verification.
## Method 2: Flattened Contract
Run this command:
```bash
forge flatten <CONTRACT_PATH> --output <OUTPUT_PATH>
```
Example:
```bash
forge flatten src/contracts/MyContract.sol --output flattened/MyContract.sol
```
Next:
1. Open Etherscan
2. Pick "Solidity (Single File)"
3. Use the flattened contract file
Note: Keep the constructor arguments and compiler settings from deployment for verification.