@@ -2,7 +2,7 @@ import { wagmiConnectors } from "./wagmiConnectors";
2
2
import { Chain , createClient , fallback , http } from "viem" ;
3
3
import { hardhat , mainnet } from "viem/chains" ;
4
4
import { createConfig } from "wagmi" ;
5
- import scaffoldConfig , { DEFAULT_ALCHEMY_API_KEY } from "~~/scaffold.config" ;
5
+ import scaffoldConfig , { DEFAULT_ALCHEMY_API_KEY , ScaffoldConfig } from "~~/scaffold.config" ;
6
6
import { getAlchemyHttpUrl } from "~~/utils/scaffold-eth" ;
7
7
8
8
const { targetNetworks } = scaffoldConfig ;
@@ -19,11 +19,16 @@ export const wagmiConfig = createConfig({
19
19
client ( { chain } ) {
20
20
let rpcFallbacks = [ http ( ) ] ;
21
21
22
- const alchemyHttpUrl = getAlchemyHttpUrl ( chain . id ) ;
23
- if ( alchemyHttpUrl ) {
24
- const isUsingDefaultKey = scaffoldConfig . alchemyApiKey === DEFAULT_ALCHEMY_API_KEY ;
25
- // If using default Scaffold-ETH 2 API key, we prioritize the default RPC
26
- rpcFallbacks = isUsingDefaultKey ? [ http ( ) , http ( alchemyHttpUrl ) ] : [ http ( alchemyHttpUrl ) , http ( ) ] ;
22
+ const rpcOverrideUrl = ( scaffoldConfig . rpcOverrides as ScaffoldConfig [ "rpcOverrides" ] ) ?. [ chain . id ] ;
23
+ if ( rpcOverrideUrl ) {
24
+ rpcFallbacks = [ http ( rpcOverrideUrl ) , http ( ) ] ;
25
+ } else {
26
+ const alchemyHttpUrl = getAlchemyHttpUrl ( chain . id ) ;
27
+ if ( alchemyHttpUrl ) {
28
+ const isUsingDefaultKey = scaffoldConfig . alchemyApiKey === DEFAULT_ALCHEMY_API_KEY ;
29
+ // If using default Scaffold-ETH 2 API key, we prioritize the default RPC
30
+ rpcFallbacks = isUsingDefaultKey ? [ http ( ) , http ( alchemyHttpUrl ) ] : [ http ( alchemyHttpUrl ) , http ( ) ] ;
31
+ }
27
32
}
28
33
29
34
return createClient ( {
0 commit comments