Skip to main content
This page shows how to deploy and verify a contract on Whitechain Sepolia using Foundry. You pass the RPC URL and the explorer URL directly to forge, so forge needs no chain config file. It is for developers who use Foundry and work from the command line.

Before you deploy

  • A funded testnet account. Claim test WBT from the faucet.
  • The private key for that account. Use a throwaway key for testing.
Never commit a private key, and never reuse a mainnet key for testing. Anyone with the key controls the funds.

1. Install Foundry

Foundryup requires a Unix shell. macOS and Linux work directly. On Windows, run Foundry inside WSL.
Install Foundry, then run foundryup to fetch forge, cast, and anvil.
Terminal
If foundryup is not found after the first command, restart your terminal and run it again.

2. Create a project

Scaffold a project and move into it.
Terminal
Pin the Solidity version in foundry.toml so the compiler matches the contract. Verification fails if the compiler version differs.
foundry.toml

3. Add the contract

Create src/Storage.sol. You can delete the sample Counter files that forge init created.
src/Storage.sol

4. Set environment variables

Create a .env file with the private key, then load it into the shell.
.env
Terminal
For a safer setup, import the key into an encrypted keystore with cast wallet import, then pass --account <name> instead of --private-key.

5. Add a deploy script

Create script/DeployStorage.s.sol.
script/DeployStorage.s.sol

6. Deploy the contract

Terminal
forge script only sends transactions when --broadcast is present. Without it, forge runs a simulation and deploys nothing.
forge prints the deployed address under Contract Address. Copy it for verification.

7. Verify the contract

Verify the deployed contract on the Whitechain Blockscout explorer.
Terminal
The Blockscout verifier URL ends with /api/. A missing or wrong suffix makes the request fail. To verify during deployment instead, add --verify --verifier blockscout --verifier-url https://explorer.testnet.whitechain.io/api/ to the forge script command in step 6.

Verify the result

Open the contract address on the explorer. A verified contract shows its source code and a verified marker.

Troubleshooting

The --broadcast flag is missing. Add --broadcast to send the transaction.
The account holds no WBT. Claim test WBT from the faucet. Do not send mainnet WBT to the testnet.
The solc version differs from the pragma. Pin solc = "0.8.30" in foundry.toml, rebuild, and verify again.
The --verifier-url is missing the /api/ suffix. Use https://explorer.testnet.whitechain.io/api/.
The explorer or RPC may be experiencing an outage. Check the status page.