@@ -75,11 +75,7 @@ const RPC_FALLBACKS: Record<number, [string, string, string]> = {
7575 'https://polygon.drpc.org' ,
7676 'https://polygon-bor-rpc.publicnode.com' ,
7777 ] ,
78- [ mantle . id ] : [
79- 'https://rpc.mantle.xyz' ,
80- 'https://mantle.drpc.org' ,
81- 'https://rpc.mantle.xyz' ,
82- ] ,
78+ [ mantle . id ] : [ 'https://rpc.mantle.xyz' , 'https://mantle.drpc.org' , 'https://rpc.mantle.xyz' ] ,
8379 [ zksync . id ] : [
8480 'https://mainnet.era.zksync.io' ,
8581 'https://zksync.drpc.org' ,
@@ -100,11 +96,7 @@ const RPC_FALLBACKS: Record<number, [string, string, string]> = {
10096 'https://cronos.drpc.org' ,
10197 'https://cronos-evm.publicnode.com' ,
10298 ] ,
103- [ gravity . id ] : [
104- 'https://rpc.gravity.xyz' ,
105- 'https://rpc.gravity.xyz' ,
106- 'https://rpc.gravity.xyz' ,
107- ] ,
99+ [ gravity . id ] : [ 'https://rpc.gravity.xyz' , 'https://rpc.gravity.xyz' , 'https://rpc.gravity.xyz' ] ,
108100 [ linea . id ] : [ 'https://rpc.linea.build' , 'https://1rpc.io/linea' , 'https://linea.drpc.org' ] ,
109101 [ lisk . id ] : [
110102 'https://rpc.api.lisk.com' ,
@@ -126,21 +118,9 @@ const RPC_FALLBACKS: Record<number, [string, string, string]> = {
126118 'https://polygon-zkevm.drpc.org' ,
127119 'https://zkevm-rpc.com' ,
128120 ] ,
129- [ scroll . id ] : [
130- 'https://rpc.scroll.io' ,
131- 'https://scroll.drpc.org' ,
132- 'https://rpc.scroll.io' ,
133- ] ,
134- [ sei . id ] : [
135- 'https://sei.drpc.org' ,
136- 'https://sei.publicnode.com' ,
137- 'https://sei.drpc.org' ,
138- ] ,
139- [ sonic . id ] : [
140- 'https://rpc.soniclabs.com' ,
141- 'https://sonic.drpc.org' ,
142- 'https://rpc.soniclabs.com' ,
143- ] ,
121+ [ scroll . id ] : [ 'https://rpc.scroll.io' , 'https://scroll.drpc.org' , 'https://rpc.scroll.io' ] ,
122+ [ sei . id ] : [ 'https://sei.drpc.org' , 'https://sei.publicnode.com' , 'https://sei.drpc.org' ] ,
123+ [ sonic . id ] : [ 'https://rpc.soniclabs.com' , 'https://sonic.drpc.org' , 'https://rpc.soniclabs.com' ] ,
144124 [ soneium . id ] : [
145125 'https://rpc.soneium.org' ,
146126 'https://soneium.drpc.org' ,
@@ -168,9 +148,9 @@ const RPC_FALLBACKS: Record<number, [string, string, string]> = {
168148 ] ,
169149} ;
170150
151+ // No retries per URL so fallback kicks in immediately (e.g. 403 from whitelisted Alchemy on localhost).
171152const HTTP_TRANSPORT_OPTIONS = {
172- retryCount : 3 ,
173- retryDelay : 1000 ,
153+ retryCount : 0 ,
174154 timeout : 30_000 ,
175155} ;
176156
@@ -225,10 +205,15 @@ export function getPollingInterval(chainId: number): number {
225205 return CHAIN_POLLING_INTERVALS [ chainId ] ?? DEFAULT_POLLING_INTERVAL ;
226206}
227207
208+ // On localhost, try public RPCs first so whitelisted RPCs (e.g. Alchemy) don't 403.
209+ const USE_PUBLIC_RPC_FIRST =
210+ typeof window !== 'undefined' && window . location ?. hostname === 'localhost' ;
211+
228212function transportForChain ( chainId : number ) {
229213 const urls = RPC_FALLBACKS [ chainId ] ;
230214 if ( ! urls ) return http ( undefined , HTTP_TRANSPORT_OPTIONS ) ;
231- return fallback ( urls . map ( url => http ( url , HTTP_TRANSPORT_OPTIONS ) ) ) ;
215+ const ordered = USE_PUBLIC_RPC_FIRST ? ( [ ...urls ] . reverse ( ) as [ string , string , string ] ) : urls ;
216+ return fallback ( ordered . map ( url => http ( url , HTTP_TRANSPORT_OPTIONS ) ) ) ;
232217}
233218
234219export const config = getDefaultConfig ( {
0 commit comments