foundry-rs / foundry-rs/foundry
bug(`forge script`): `forge script --multi` causes issues with Etherscan providers
- Dominant language
- Rust
- Stars
- 10.6k
- Forks
- 2.6k
- Avg merge
- 18h 20m
- Merged PRs (30d)
- 510
Description
### Component
Forge
### Have you ensured that all of these are up to date?
- [x] Foundry
- [x] Foundryup
### What version of Foundry are you on?
forge Version: 1.0.0-stable
### What version of Foundryup are you on?
foundryup: 1.0.1
### What command(s) is the bug in?
forge script ${PATH_TO_SCRIPT} --slow --multi --broadcast --private-key $PRIVATE_KEY --verify
### Operating System
macOS (Apple Silicon)
### Describe the bug
I'm running the following commands and always getting the same output
`forge script ${PATH_TO_SCRIPT} --slow --multi --broadcast --private-key $PRIVATE_KEY --verify`
Output:
```
Error: Encountered an error verifying this contract:
Response: `NOTOK`
Details:`Invalid API Key (#err2)|BASEELASTIC2`
```
Here is my Foundry.toml:
```toml
[profile.default]
src = "src"
out = "out"
libs = ["lib"]
fs_permissions = [
{ access = "read-write", path = "configs/agent-config.json" }
]
[rpc_endpoints]
ethereum = "${MAINNET_RPC_URL}"
optimism = "${OPTIMISM_RPC_URL}"
polygon = "${POLYGON_RPC_URL}"
base = "${BASE_RPC_URL}"
arbitrum = "${ARBITRUM_RPC_URL}"
[etherscan]
ethereum = { key = '${ETHERSCAN_API_KEY}'}
optimism = { key ='${OPTIMISMSCAN_API_KEY}' }
polygon = { key = '${POLYGONSCAN_API_KEY}' }
base = { key = '${BASESCAN_API_KEY}' }
arbitrum = { key = '${ARBITRUMSCAN_API_KEY}' }
```
The script is deploying multiple contracts like this:
```solidity
vm.createSelectFork(_chain.chainName);
// Add validation for contract existence
require(address(_chain.staticAggregationHookFactory).code.length > 0, "StaticAggregationHookFactory not deployed");
require(address(_chain.merkleTreeHook).code.length > 0, "MerkleTreeHook not deployed");
require(address(_chain.pausableHook).code.length > 0, "PausableHook not deployed");
vm.startBroadcast();
// deploy the IGP
InterchainGasPaymaster igp = new InterchainGasPaymaster();
// Add debug logs
console.log("IGP deployed at:", address(igp));
ProxyAdmin proxyAdmin = new ProxyAdmin(_owner);
bytes memory initData = abi.encodeWithSelector(InterchainGasPaymaster.initialize.selector, _owner, _beneficiary);
// Add more debug logs
console.log("ProxyAdmin deployed at:", address(proxyAdmin));
TransparentUpgradeableProxy igpProxy = new TransparentUpgradeableProxy(address(igp), address(proxyAdmin), initData);
console.log("IGP Proxy deployed at:", address(igpProxy));
// deploy the gas oracle with owner parameter
StorageGasOracle gasOracle = new StorageGasOracle();
console.log("Gas Oracle deployed at:", address(gasOracle));
console.log("Gas Oracle code size:", address(gasOracle).code.length);
// set the gas oracle for the IGP
InterchainGasPaymaster(address(igpProxy)).setDestinationGasConfigs(
_createGasConfigs(_chainHooks, address(gasOracle))
);
// bind the address for the staticAggregationHookFactory from _chain
address[] memory hooks = new address[](3);
hooks[0] = address(igpProxy);
hooks[1] = address(_chain.merkleTreeHook);
hooks[2] = address(_chain.pausableHook);
address staticAggHook = StaticAggregationHookFactory(address(_chain.staticAggregationHookFactory)).deploy(hooks);
console.log("Static Aggregation Hook deployed at:", address(staticAggHook));
vm.stopBroadcast();
```
I've triple checked my API keys and they are correct in my .env.
Contributor guide
Assessment
This issue has not been assessed yet.