6.0 KiB
RPC URLs in Use and How Infura Is Accessed
This doc lists which RPC URLs the scripts use and how Infura RPCs are accessed (including the fix for "error sending request" when running from your machine).
Where RPC URLs Come From
| Source | Description |
|---|---|
.env |
All Infura and chain-specific RPC URLs are set here (e.g. ETHEREUM_MAINNET_RPC, RPC_URL_138, POLYGON_MAINNET_RPC). |
scripts/lib/infura.sh |
Builds Infura URLs from INFURA_PROJECT_ID and optional INFURA_PROJECT_SECRET (Basic Auth). |
| Fallbacks | Scripts use public or alias URLs when an env var is unset (e.g. BSC: https://bsc-dataseed.binance.org, Cronos: https://evm.cronos.org). |
RPC URLs Used by Scripts
Required (balance check, verify-all-rpcs, deploy)
| Env var | Example / format | Used by |
|---|---|---|
ETHEREUM_MAINNET_RPC |
https://mainnet.infura.io/v3/<INFURA_PROJECT_ID> |
Balance check, RPC verify, mainnet deploy |
RPC_URL_138 |
http://192.168.11.211:8545 |
Chain 138 balance, deploy, bridge scripts |
Infura chains (from .env when set)
All of these are typically set in .env as plain Infura URLs (project ID only):
ETHEREUM_MAINNET_RPC,ETHEREUM_SEPOLIA_RPCPOLYGON_MAINNET_RPC,POLYGON_AMOY_RPCBASE_MAINNET_RPC,BASE_SEPOLIA_RPCOPTIMISM_MAINNET_RPC,OPTIMISM_SEPOLIA_RPCARBITRUM_MAINNET_RPC,ARBITRUM_SEPOLIA_RPCAVALANCHE_MAINNET_RPC,AVALANCHE_FUJI_RPCBSC_MAINNET_RPC,CELO_MAINNET_RPC,LINEA_MAINNET_RPC- (and other
*_MAINNET_RPC/*_TESTNET_RPCInfura entries in.env)
Other chains (aliases / public)
AVALANCHE_RPC_URL,ARBITRUM_MAINNET_RPC(orARBITRUM_RPC) — sometimes overridden to public RPCs in.envCRONOS_RPC_URL— e.g.https://evm.cronos.org(Cronos not on Infura)
How Infura RPCs Are Accessed
Without secret (plain URL from .env)
- URL format:
https://mainnet.infura.io/v3/<INFURA_PROJECT_ID>(and same for other chains, e.g.https://polygon-mainnet.infura.io/v3/<ID>). - When it’s used: If
INFURA_PROJECT_SECRETis not set, scripts andcastuse this URL as-is. This can fail with "error sending request for url (https://...infura.io/v3/...)" if Infura requires the project secret (e.g. "Private Key Only" or stricter access).
With secret (Basic Auth) — fix for failing Infura from your machine
- URL format:
https://<project_id>:<urlencoded_secret>@mainnet.infura.io/v3/<project_id>(same host path, with Basic Auth). - How it’s built:
scripts/lib/infura.shbuild_infura_rpc(host_path)buildshttps://[id:urlencoded_secret@]host.infura.io/v3/idfromINFURA_PROJECT_IDand optionalINFURA_PROJECT_SECRET.ensure_infura_rpc_url(url)(added for this fix): given any URL, if it is an Infura URL andINFURA_PROJECT_SECRETis set, it returns the same URL with Basic Auth; otherwise returns the URL unchanged. Scripts use this before callingcastso Infura is always accessed with the secret when it’s set.
- Relay (
services/relay) builds the mainnet URL with Basic Auth fromINFURA_PROJECT_IDandINFURA_PROJECT_SECRETin its config (e.g.config.js).
- Which scripts use it:
scripts/deployment/verify-all-rpcs.sh— sourcesinfura.shand passes each RPC throughensure_infura_rpc_url()beforecast block-number.scripts/deployment/check-balances-gas-and-deploy.sh— sourcesinfura.sh;check_network()andget_gas_price_for_chain()useensure_infura_rpc_url()so every Infura RPC used for balance and gas price is Basic Auth when the secret is set.- Other deploy scripts that use
ETHEREUM_MAINNET_RPCor Infura URLs (e.g.deploy-all-mainnet.sh) already use the same pattern or can sourceinfura.shand useensure_infura_rpc_url()for consistency.
So: Infura RPCs are accessed by building a URL from .env (or from build_infura_rpc), and scripts now ensure that when INFURA_PROJECT_SECRET is set, the URL is converted to the Basic Auth form before any cast (or equivalent) call.
Why It Failed From Your Environment (e.g. ASERET)
- Observed: All Infura and some public RPCs failed with "error sending request for url (https://mainnet.infura.io/v3/43b945…)" (and similar); only Chain 138 (e.g.
http://192.168.11.211:8545) worked. - Likely causes:
- Infura requiring the project secret: If the project has "Private Key Only" or similar, requests without Basic Auth are rejected (often reported as connection/request errors).
- Scripts using the plain URL: Previously,
verify-all-rpcs.shandcheck-balances-gas-and-deploy.shpassed the raw.envURL (no secret) tocast, so Infura never received the secret.
Fix Applied
-
scripts/lib/infura.sh- Added
ensure_infura_rpc_url(url): ifurlis an Infura URL andINFURA_PROJECT_SECRETis set, it returns the Basic Auth URL; otherwise returnsurlunchanged.
- Added
-
scripts/deployment/verify-all-rpcs.sh- Sources
scripts/lib/infura.sh. - Before each
cast block-number, the RPC URL is passed throughensure_infura_rpc_url()so Infura endpoints are called with Basic Auth when the secret is set.
- Sources
-
scripts/deployment/check-balances-gas-and-deploy.sh- Sources
scripts/lib/infura.sh. - In
check_network(), the RPC is passed throughensure_infura_rpc_url()beforecast balance. - In
get_gas_price_for_chain(), the RPC URL is passed throughensure_infura_rpc_url()beforecast gas-price.
- Sources
What you need: Ensure .env has both INFURA_PROJECT_ID and INFURA_PROJECT_SECRET set (no need to change the existing *_RPC URLs in .env). Scripts will add Basic Auth when calling Infura. Then re-run:
bash scripts/deployment/verify-all-rpcs.shDEPLOYER_ADDRESS=0x4A66... bash scripts/deployment/check-balances-gas-and-deploy.sh
If Infura still fails, check network/firewall/proxy and that the project secret is correct in the Infura dashboard.