Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
VITE_BASE_URL=

VITE_ALCHEMY_API_KEY=
VITE_ALCHEMY_RPC_PROXY_URL=

VITE_PRIVY_APP_ID=
VITE_PRIVY_APP_CLIENT_ID=
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ You'll need to provide a Wallet Connect project id to enable onboarding and wall
Set environment variables via `.env`.

- `VITE_BASE_URL` (required): The base URL of the deployment (e.g., `https://www.example.com`).
- `VITE_ALCHEMY_API_KEY` (optional): Add an Alchemy API key for EVM interactions; the app will fall back to public RPCs if not provided.
- `VITE_ALCHEMY_RPC_PROXY_URL` (optional): Base URL of your Alchemy proxy for EVM RPC requests; the proxy injects the secret Alchemy API key so it is not exposed in the web app (e.g., `https://proxy.example.com`).
- `VITE_PK_ENCRYPTION_KEY` (optional): AES encryption key used for signature obfuscation; necessary for enabling the "Remember Me" feature.
- `VITE_V3_TOKEN_ADDRESS` (optional): Address of the V3 $DYDX token.
- `VITE_TOKEN_MIGRATION_URI` (optional): The URL of the token migration website.
Expand Down
29 changes: 15 additions & 14 deletions src/lib/wagmi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,33 +110,34 @@ export enum ChainId {
}

export const getAlchemyRPCUrlForChainId = (chainId: ChainId) => {
const alchemyKey = import.meta.env.VITE_ALCHEMY_API_KEY;
if (!alchemyKey) return undefined;
const alchemyRpcProxyUrl = import.meta.env.VITE_ALCHEMY_RPC_PROXY_URL;
if (!alchemyRpcProxyUrl) return undefined;

switch (chainId) {
case ChainId.ETH_MAINNET:
return `https://eth-mainnet.g.alchemy.com/v2/${alchemyKey}`;
return `${alchemyRpcProxyUrl}/eth-mainnet/v2`;
case ChainId.ETH_SEPOLIA:
return `https://eth-sepolia.g.alchemy.com/v2/${alchemyKey}`;
return `${alchemyRpcProxyUrl}/eth-sepolia/v2`;
case ChainId.POLYGON_MAINNET:
return `https://polygon-mainnet.g.alchemy.com/v2/${alchemyKey}`;
return `${alchemyRpcProxyUrl}/polygon-mainnet/v2`;
case ChainId.POLYGON_MUMBAI:
return `https://polygon-amoy.g.alchemy.com/v2/${alchemyKey}`;
return `${alchemyRpcProxyUrl}/polygon-amoy/v2`;
case ChainId.OPT_MAINNET:
return `https://opt-mainnet.g.alchemy.com/v2/${alchemyKey}`;
return `${alchemyRpcProxyUrl}/opt-mainnet/v2`;
case ChainId.OPT_SEPOLIA:
return `https://opt-sepolia.g.alchemy.com/v2/${alchemyKey}`;
return `${alchemyRpcProxyUrl}/opt-sepolia/v2`;
case ChainId.ARB_MAINNET:
return `https://arb-mainnet.g.alchemy.com/v2/${alchemyKey}`;
return `${alchemyRpcProxyUrl}/arb-mainnet/v2`;
case ChainId.ARB_SEPOLIA:
return `https://arb-sepolia.g.alchemy.com/v2/${alchemyKey}`;
return `${alchemyRpcProxyUrl}/arb-sepolia/v2`;
case ChainId.BASE_MAINNET:
return `https://base-mainnet.g.alchemy.com/v2/${alchemyKey}`;
return `${alchemyRpcProxyUrl}/base-mainnet/v2`;
case ChainId.BASE_SEPOLIA:
return `https://base-sepolia.g.alchemy.com/v2/${alchemyKey}`;
return `${alchemyRpcProxyUrl}/base-sepolia/v2`;
case ChainId.AVALANCHE_MAINNET:
return `https://avax-mainnet.g.alchemy.com/v2/${alchemyKey}`;
return `${alchemyRpcProxyUrl}/avax-mainnet/v2`;
case ChainId.AVALANCHE_FUJI:
return `https://avax-fuji.g.alchemy.com/v2/${alchemyKey}`;
return `${alchemyRpcProxyUrl}/avax-fuji/v2`;
default:
return undefined;
}
Expand Down
Loading