Open
Description
Component
Forge
Have you ensured that all of these are up to date?
- Foundry
- Foundryup
What version of Foundry are you on?
1.2.0-nightly
What version of Foundryup are you on?
No response
What command(s) is the bug in?
cast run
Operating System
None
Describe the bug
Description
When using cast run
with the --chain
flag, Foundry appears to ignore the RPC endpoints configured in foundry.toml
and defaults to localhost:8545
instead.
Steps to Reproduce
- Configure custom RPC endpoints in
foundry.toml
:
[rpc_endpoints]
mainnet = "${MAINNET_RPC_URL}"
unichain = "${UNICHAIN_MAINNET_RPC_URL}"
- Set the corresponding environment variables in
.env
:
UNICHAIN_MAINNET_RPC_URL=https://your-unichain-rpc-url
- Run cast with the --chain flag:
cast run 0xb6972b3d91aa4ece3b7f2ef3aff0e3d87f049252eef64f4b6351925fe035b3d4 --chain unichain
Expected Behavior
The command should use the RPC URL configured for the unichain
endpoint in foundry.toml
.
Actual Behavior
The command attempts to connect to localhost:8545
and fails with:
Error: tx not found: 0xb6972b3d91aa4ece3b7f2ef3aff0e3d87f049252eef64f4b6351925fe035b3d4
Context:
- Error #0: error sending request for url (http://localhost:8545/)
- Error #1: client error (Connect)
- Error #2: tcp connect error: Connection refused (os error 61)
Configuration Files
foundry.toml:
[profile.default]
src = "src"
test = "test"
out = "out"
libs = ["lib"]
fs_permissions = [{ access = "read-write", path = ".forge-snapshots/"}, { access = "read-write", path = "log/"}, { access = "read", path = "env"}]
dotenv = true
solc_version = "0.8.27"
evm_version = "cancun"
viaIR = true
optimizer = false
[profile.production]
viaIR = true
optimizer = true
optimizer_runs = 10000
[rpc_endpoints]
mainnet = "${MAINNET_RPC_URL}"
unichain = "${UNICHAIN_MAINNET_RPC_URL}"
[etherscan]
mainnet = { key = "${ETHERSCAN_API_KEY}", url = "https://api.etherscan.io/api" }
unichain = { key = "${UNICHAIN_API_KEY}", url = "https://unichain.blockscout.com/api" }
Metadata
Metadata
Assignees
Type
Projects
Status
Backlog