1use alloy_primitives::{Address, address};
2use core::{cmp::Ordering, fmt, time::Duration};
3use num_enum::TryFromPrimitiveError;
4
5#[allow(unused_imports)]
6use alloc::string::String;
7
8#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
30#[derive(strum::IntoStaticStr)] #[derive(strum::VariantNames)] #[derive(strum::VariantArray)] #[derive(strum::EnumString)] #[derive(strum::EnumIter)] #[derive(strum::EnumCount)] #[derive(num_enum::TryFromPrimitive)] #[cfg_attr(feature = "serde", derive(serde::Deserialize))]
38#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
39#[strum(serialize_all = "kebab-case")]
40#[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))]
41#[repr(u64)]
42#[allow(missing_docs)]
43#[non_exhaustive]
44pub enum NamedChain {
45 #[strum(to_string = "mainnet", serialize = "ethlive")]
46 #[cfg_attr(feature = "serde", serde(alias = "ethlive"))]
47 Mainnet = 1,
48 Morden = 2,
49 Ropsten = 3,
50 Rinkeby = 4,
51 Goerli = 5,
52 Kovan = 42,
53 Holesky = 17000,
54 Hoodi = 560048,
55 Sepolia = 11155111,
56
57 #[cfg_attr(feature = "serde", serde(alias = "odyssey"))]
58 Odyssey = 911867,
59
60 Optimism = 10,
61 #[cfg_attr(feature = "serde", serde(alias = "optimism-kovan"))]
62 OptimismKovan = 69,
63 #[cfg_attr(feature = "serde", serde(alias = "optimism-goerli"))]
64 OptimismGoerli = 420,
65 #[cfg_attr(feature = "serde", serde(alias = "optimism-sepolia"))]
66 OptimismSepolia = 11155420,
67
68 #[strum(to_string = "bob")]
69 #[cfg_attr(feature = "serde", serde(alias = "bob"))]
70 Bob = 60808,
71 #[strum(to_string = "bob-sepolia")]
72 #[cfg_attr(feature = "serde", serde(alias = "bob-sepolia"))]
73 BobSepolia = 808813,
74
75 #[cfg_attr(feature = "serde", serde(alias = "arbitrum_one", alias = "arbitrum-one"))]
76 Arbitrum = 42161,
77 ArbitrumTestnet = 421611,
78 #[cfg_attr(feature = "serde", serde(alias = "arbitrum-goerli"))]
79 ArbitrumGoerli = 421613,
80 #[cfg_attr(feature = "serde", serde(alias = "arbitrum-sepolia"))]
81 ArbitrumSepolia = 421614,
82 #[cfg_attr(feature = "serde", serde(alias = "arbitrum-nova"))]
83 ArbitrumNova = 42170,
84
85 Cronos = 25,
86 CronosTestnet = 338,
87
88 Rsk = 30,
89 RskTestnet = 31,
90
91 #[strum(to_string = "telos")]
92 #[cfg_attr(feature = "serde", serde(alias = "telos", alias = "telos_evm"))]
93 TelosEvm = 40,
94 #[strum(to_string = "telos-testnet")]
95 #[cfg_attr(
96 feature = "serde",
97 serde(alias = "telos_testnet", alias = "telos-evm-testnet", alias = "telos_evm_testnet")
98 )]
99 TelosEvmTestnet = 41,
100
101 #[strum(to_string = "crab")]
102 #[cfg_attr(feature = "serde", serde(alias = "crab"))]
103 Crab = 44,
104 #[strum(to_string = "darwinia")]
105 #[cfg_attr(feature = "serde", serde(alias = "darwinia"))]
106 Darwinia = 46,
107 #[strum(to_string = "koi")]
108 #[cfg_attr(feature = "serde", serde(alias = "koi"))]
109 Koi = 701,
110
111 #[strum(to_string = "bsc", serialize = "binance-smart-chain", serialize = "bnb-smart-chain")]
115 #[cfg_attr(
116 feature = "serde",
117 serde(alias = "bsc", alias = "bnb-smart-chain", alias = "binance-smart-chain")
118 )]
119 BinanceSmartChain = 56,
120 #[strum(
121 to_string = "bsc-testnet",
122 serialize = "binance-smart-chain-testnet",
123 serialize = "bnb-smart-chain-testnet"
124 )]
125 #[cfg_attr(
126 feature = "serde",
127 serde(
128 alias = "bsc_testnet",
129 alias = "bsc-testnet",
130 alias = "bnb-smart-chain-testnet",
131 alias = "binance-smart-chain-testnet"
132 )
133 )]
134 BinanceSmartChainTestnet = 97,
135
136 Poa = 99,
137 Sokol = 77,
138
139 Scroll = 534352,
140 #[cfg_attr(
141 feature = "serde",
142 serde(alias = "scroll_sepolia_testnet", alias = "scroll-sepolia")
143 )]
144 ScrollSepolia = 534351,
145
146 Metis = 1088,
147
148 #[cfg_attr(feature = "serde", serde(alias = "conflux-espace-testnet"))]
149 CfxTestnet = 71,
150 #[cfg_attr(feature = "serde", serde(alias = "conflux-espace"))]
151 Cfx = 1030,
152
153 #[strum(to_string = "xdai", serialize = "gnosis", serialize = "gnosis-chain")]
154 #[cfg_attr(feature = "serde", serde(alias = "xdai", alias = "gnosis", alias = "gnosis-chain"))]
155 Gnosis = 100,
156
157 Polygon = 137,
158 #[strum(to_string = "amoy", serialize = "polygon-amoy")]
159 #[cfg_attr(feature = "serde", serde(alias = "amoy", alias = "polygon-amoy"))]
160 PolygonAmoy = 80002,
161
162 Fantom = 250,
163 FantomTestnet = 4002,
164
165 Moonbeam = 1284,
166 MoonbeamDev = 1281,
167
168 Moonriver = 1285,
169
170 Moonbase = 1287,
171
172 Dev = 1337,
173 #[strum(to_string = "anvil-hardhat", serialize = "anvil", serialize = "hardhat")]
174 #[cfg_attr(
175 feature = "serde",
176 serde(alias = "anvil", alias = "hardhat", alias = "anvil-hardhat")
177 )]
178 AnvilHardhat = 31337,
179
180 #[strum(to_string = "gravity-alpha-mainnet")]
181 #[cfg_attr(feature = "serde", serde(alias = "gravity-alpha-mainnet"))]
182 GravityAlphaMainnet = 1625,
183 #[strum(to_string = "gravity-alpha-testnet-sepolia")]
184 #[cfg_attr(feature = "serde", serde(alias = "gravity-alpha-testnet-sepolia"))]
185 GravityAlphaTestnetSepolia = 13505,
186
187 Evmos = 9001,
188 EvmosTestnet = 9000,
189
190 Plasma = 9745,
191
192 Chiado = 10200,
193
194 Oasis = 26863,
195
196 Emerald = 42262,
197 EmeraldTestnet = 42261,
198
199 FilecoinMainnet = 314,
200 FilecoinCalibrationTestnet = 314159,
201
202 Avalanche = 43114,
203 #[strum(to_string = "fuji", serialize = "avalanche-fuji")]
204 #[cfg_attr(feature = "serde", serde(alias = "fuji"))]
205 AvalancheFuji = 43113,
206
207 Celo = 42220,
208 CeloSepolia = 11142220,
209
210 Aurora = 1313161554,
211 AuroraTestnet = 1313161555,
212
213 Canto = 7700,
214 CantoTestnet = 740,
215
216 Boba = 288,
217
218 Base = 8453,
219 #[cfg_attr(feature = "serde", serde(alias = "base-goerli"))]
220 BaseGoerli = 84531,
221 #[cfg_attr(feature = "serde", serde(alias = "base-sepolia"))]
222 BaseSepolia = 84532,
223 #[cfg_attr(feature = "serde", serde(alias = "syndr"))]
224 Syndr = 404,
225 #[cfg_attr(feature = "serde", serde(alias = "syndr-sepolia"))]
226 SyndrSepolia = 444444,
227
228 Shimmer = 148,
229
230 Ink = 57073,
231 #[cfg_attr(feature = "serde", serde(alias = "ink_sepolia_testnet", alias = "ink-sepolia"))]
232 InkSepolia = 763373,
233
234 #[strum(to_string = "fraxtal")]
235 #[cfg_attr(feature = "serde", serde(alias = "fraxtal"))]
236 Fraxtal = 252,
237 #[strum(to_string = "fraxtal-testnet")]
238 #[cfg_attr(feature = "serde", serde(alias = "fraxtal-testnet"))]
239 FraxtalTestnet = 2522,
240
241 Blast = 81457,
242 #[cfg_attr(feature = "serde", serde(alias = "blast-sepolia"))]
243 BlastSepolia = 168587773,
244
245 Linea = 59144,
246 #[cfg_attr(feature = "serde", serde(alias = "linea-goerli"))]
247 LineaGoerli = 59140,
248 #[cfg_attr(feature = "serde", serde(alias = "linea-sepolia"))]
249 LineaSepolia = 59141,
250
251 #[strum(to_string = "zksync")]
252 #[cfg_attr(feature = "serde", serde(alias = "zksync"))]
253 ZkSync = 324,
254 #[strum(to_string = "zksync-testnet")]
255 #[cfg_attr(feature = "serde", serde(alias = "zksync_testnet", alias = "zksync-testnet"))]
256 ZkSyncTestnet = 300,
257
258 #[strum(to_string = "mantle")]
259 #[cfg_attr(feature = "serde", serde(alias = "mantle"))]
260 Mantle = 5000,
261 #[strum(to_string = "mantle-sepolia")]
262 #[cfg_attr(feature = "serde", serde(alias = "mantle-sepolia"))]
263 MantleSepolia = 5003,
264
265 #[strum(to_string = "xai")]
266 #[cfg_attr(feature = "serde", serde(alias = "xai"))]
267 Xai = 660279,
268 #[strum(to_string = "xai-sepolia")]
269 #[cfg_attr(feature = "serde", serde(alias = "xai-sepolia"))]
270 XaiSepolia = 37714555429,
271
272 #[strum(to_string = "happychain-testnet")]
273 #[cfg_attr(feature = "serde", serde(alias = "happychain-testnet"))]
274 HappychainTestnet = 216,
275
276 Viction = 88,
277
278 Zora = 7777777,
279 #[cfg_attr(feature = "serde", serde(alias = "zora-sepolia"))]
280 ZoraSepolia = 999999999,
281
282 Pgn = 424,
283 #[cfg_attr(feature = "serde", serde(alias = "pgn-sepolia"))]
284 PgnSepolia = 58008,
285
286 Mode = 34443,
287 #[cfg_attr(feature = "serde", serde(alias = "mode-sepolia"))]
288 ModeSepolia = 919,
289
290 Elastos = 20,
291
292 #[cfg_attr(feature = "serde", serde(alias = "etherlink"))]
293 Etherlink = 42793,
294
295 #[cfg_attr(feature = "serde", serde(alias = "etherlink-testnet"))]
296 EtherlinkTestnet = 128123,
297
298 Degen = 666666666,
299
300 #[strum(to_string = "opbnb-mainnet")]
301 #[cfg_attr(
302 feature = "serde",
303 serde(rename = "opbnb_mainnet", alias = "opbnb-mainnet", alias = "op-bnb-mainnet")
304 )]
305 OpBNBMainnet = 204,
306 #[strum(to_string = "opbnb-testnet")]
307 #[cfg_attr(
308 feature = "serde",
309 serde(rename = "opbnb_testnet", alias = "opbnb-testnet", alias = "op-bnb-testnet")
310 )]
311 OpBNBTestnet = 5611,
312
313 Ronin = 2020,
314
315 #[cfg_attr(feature = "serde", serde(alias = "ronin-testnet"))]
316 RoninTestnet = 2021,
317
318 Taiko = 167000,
319 #[cfg_attr(feature = "serde", serde(alias = "taiko-hekla"))]
320 TaikoHekla = 167009,
321
322 #[strum(to_string = "autonomys-nova-testnet")]
323 #[cfg_attr(
324 feature = "serde",
325 serde(rename = "autonomys_nova_testnet", alias = "autonomys-nova-testnet")
326 )]
327 AutonomysNovaTestnet = 490000,
328
329 Flare = 14,
330 #[cfg_attr(feature = "serde", serde(alias = "flare-coston2"))]
331 FlareCoston2 = 114,
332
333 #[strum(to_string = "acala")]
334 #[cfg_attr(feature = "serde", serde(alias = "acala"))]
335 Acala = 787,
336 #[strum(to_string = "acala-mandala-testnet")]
337 #[cfg_attr(feature = "serde", serde(alias = "acala-mandala-testnet"))]
338 AcalaMandalaTestnet = 595,
339 #[strum(to_string = "acala-testnet")]
340 #[cfg_attr(feature = "serde", serde(alias = "acala-testnet"))]
341 AcalaTestnet = 597,
342
343 #[strum(to_string = "karura")]
344 #[cfg_attr(feature = "serde", serde(alias = "karura"))]
345 Karura = 686,
346 #[strum(to_string = "karura-testnet")]
347 #[cfg_attr(feature = "serde", serde(alias = "karura-testnet"))]
348 KaruraTestnet = 596,
349 #[strum(to_string = "pulsechain")]
350 #[cfg_attr(feature = "serde", serde(alias = "pulsechain"))]
351 Pulsechain = 369,
352 #[strum(to_string = "pulsechain-testnet")]
353 #[cfg_attr(feature = "serde", serde(alias = "pulsechain-testnet"))]
354 PulsechainTestnet = 943,
355
356 #[strum(to_string = "cannon")]
357 #[cfg_attr(feature = "serde", serde(alias = "cannon"))]
358 Cannon = 13370,
359
360 #[strum(to_string = "immutable")]
361 #[cfg_attr(feature = "serde", serde(alias = "immutable"))]
362 Immutable = 13371,
363 #[strum(to_string = "immutable-testnet")]
364 #[cfg_attr(feature = "serde", serde(alias = "immutable-testnet"))]
365 ImmutableTestnet = 13473,
366
367 #[strum(to_string = "soneium")]
368 #[cfg_attr(feature = "serde", serde(alias = "soneium"))]
369 Soneium = 1868,
370
371 #[strum(to_string = "soneium-minato-testnet")]
372 #[cfg_attr(feature = "serde", serde(alias = "soneium-minato-testnet"))]
373 SoneiumMinatoTestnet = 1946,
374
375 #[cfg_attr(feature = "serde", serde(alias = "worldchain"))]
376 World = 480,
377 #[strum(to_string = "world-sepolia")]
378 #[cfg_attr(feature = "serde", serde(alias = "worldchain-sepolia", alias = "world-sepolia"))]
379 WorldSepolia = 4801,
380 Iotex = 4689,
381 Core = 1116,
382 Merlin = 4200,
383 Bitlayer = 200901,
384 Vana = 1480,
385 Zeta = 7000,
386 Kaia = 8217,
387 Story = 1514,
388 Sei = 1329,
389 #[strum(to_string = "sei-testnet")]
390 #[cfg_attr(feature = "serde", serde(alias = "sei-testnet"))]
391 SeiTestnet = 1328,
392 #[strum(to_string = "stable-mainnet")]
393 #[cfg_attr(feature = "serde", serde(alias = "stable-mainnet"))]
394 StableMainnet = 988,
395 #[strum(to_string = "stable-testnet")]
396 #[cfg_attr(feature = "serde", serde(alias = "stable-testnet"))]
397 StableTestnet = 2201,
398
399 #[strum(to_string = "xdc-mainnet")]
400 #[cfg_attr(feature = "serde", serde(alias = "xdc-mainnet"))]
401 XdcMainnet = 50,
402 #[strum(to_string = "xdc-testnet")]
403 #[cfg_attr(feature = "serde", serde(alias = "xdc-testnet"))]
404 XdcTestnet = 51,
405
406 Unichain = 130,
407 #[strum(to_string = "unichain-sepolia")]
408 #[cfg_attr(feature = "serde", serde(alias = "unichain-sepolia"))]
409 UnichainSepolia = 1301,
410
411 #[strum(to_string = "signet-pecorino")]
412 #[cfg_attr(feature = "serde", serde(alias = "signet-pecorino"))]
413 SignetPecorino = 14174,
414
415 #[strum(to_string = "apechain")]
416 #[cfg_attr(feature = "serde", serde(alias = "apechain"))]
417 ApeChain = 33139,
418 #[strum(to_string = "curtis", serialize = "apechain-testnet")]
419 #[cfg_attr(feature = "serde", serde(alias = "apechain-testnet", alias = "curtis"))]
420 Curtis = 33111,
421
422 #[strum(to_string = "sonic")]
423 #[cfg_attr(feature = "serde", serde(alias = "sonic"))]
424 Sonic = 146,
425 #[strum(to_string = "sonic-testnet")]
426 #[cfg_attr(feature = "serde", serde(alias = "sonic-testnet"))]
427 SonicTestnet = 14601,
428
429 #[strum(to_string = "treasure")]
430 #[cfg_attr(feature = "serde", serde(alias = "treasure"))]
431 Treasure = 61166,
432
433 #[strum(to_string = "treasure-topaz", serialize = "treasure-topaz-testnet")]
434 #[cfg_attr(
435 feature = "serde",
436 serde(alias = "treasure-topaz-testnet", alias = "treasure-topaz")
437 )]
438 TreasureTopaz = 978658,
439
440 #[strum(to_string = "berachain-bepolia", serialize = "berachain-bepolia-testnet")]
441 #[cfg_attr(
442 feature = "serde",
443 serde(alias = "berachain-bepolia-testnet", alias = "berachain-bepolia")
444 )]
445 BerachainBepolia = 80069,
446
447 Berachain = 80094,
448
449 #[strum(to_string = "superposition-testnet")]
450 #[cfg_attr(feature = "serde", serde(alias = "superposition-testnet"))]
451 SuperpositionTestnet = 98985,
452
453 #[strum(to_string = "superposition")]
454 #[cfg_attr(feature = "serde", serde(alias = "superposition"))]
455 Superposition = 55244,
456
457 #[strum(serialize = "monad")]
458 #[cfg_attr(feature = "serde", serde(alias = "monad"))]
459 Monad = 143,
460
461 #[strum(serialize = "monad-testnet")]
462 #[cfg_attr(feature = "serde", serde(alias = "monad-testnet"))]
463 MonadTestnet = 10143,
464
465 #[strum(to_string = "hyperliquid")]
466 #[cfg_attr(feature = "serde", serde(alias = "hyperliquid"))]
467 Hyperliquid = 999,
468
469 #[strum(to_string = "abstract")]
470 #[cfg_attr(feature = "serde", serde(alias = "abstract"))]
471 Abstract = 2741,
472
473 #[strum(to_string = "abstract-testnet")]
474 #[cfg_attr(feature = "serde", serde(alias = "abstract-testnet"))]
475 AbstractTestnet = 11124,
476
477 #[strum(to_string = "corn")]
478 #[cfg_attr(feature = "serde", serde(alias = "corn"))]
479 Corn = 21000000,
480
481 #[strum(to_string = "corn-testnet")]
482 #[cfg_attr(feature = "serde", serde(alias = "corn-testnet"))]
483 CornTestnet = 21000001,
484
485 #[strum(to_string = "sophon")]
486 #[cfg_attr(feature = "serde", serde(alias = "sophon"))]
487 Sophon = 50104,
488
489 #[strum(to_string = "sophon-testnet")]
490 #[cfg_attr(feature = "serde", serde(alias = "sophon-testnet"))]
491 SophonTestnet = 531050104,
492
493 #[strum(to_string = "polkadot-testnet")]
494 #[cfg_attr(feature = "serde", serde(alias = "polkadot-testnet"))]
495 PolkadotTestnet = 420420417,
496
497 #[strum(to_string = "lens")]
498 #[cfg_attr(feature = "serde", serde(alias = "lens"))]
499 Lens = 232,
500
501 #[strum(to_string = "lens-testnet")]
502 #[cfg_attr(feature = "serde", serde(alias = "lens-testnet"))]
503 LensTestnet = 37111,
504
505 #[strum(to_string = "injective")]
506 #[cfg_attr(feature = "serde", serde(alias = "injective"))]
507 Injective = 1776,
508
509 #[strum(to_string = "injective-testnet")]
510 #[cfg_attr(feature = "serde", serde(alias = "injective-testnet"))]
511 InjectiveTestnet = 1439,
512
513 #[strum(to_string = "katana")]
514 #[cfg_attr(feature = "serde", serde(alias = "katana"))]
515 Katana = 747474,
516
517 #[strum(to_string = "lisk")]
518 #[cfg_attr(feature = "serde", serde(alias = "lisk"))]
519 Lisk = 1135,
520
521 #[strum(to_string = "fuse")]
522 #[cfg_attr(feature = "serde", serde(alias = "fuse"))]
523 Fuse = 122,
524 #[strum(to_string = "fluent-devnet")]
525 #[cfg_attr(feature = "serde", serde(alias = "fluent-devnet"))]
526 FluentDevnet = 20993,
527
528 #[strum(to_string = "fluent-testnet")]
529 #[cfg_attr(feature = "serde", serde(alias = "fluent-testnet"))]
530 FluentTestnet = 20994,
531
532 #[strum(to_string = "skale-base")]
533 #[cfg_attr(feature = "serde", serde(alias = "skale-base"))]
534 SkaleBase = 1562508942,
535
536 #[strum(to_string = "skale-base-sepolia-testnet")]
537 #[cfg_attr(feature = "serde", serde(alias = "skale-base-sepolia-testnet"))]
538 SkaleBaseSepoliaTestnet = 324705682,
539
540 #[strum(to_string = "memecore")]
543 #[cfg_attr(feature = "serde", serde(alias = "memecore"))]
544 MemeCore = 4352,
545 #[strum(to_string = "formicarium", serialize = "memecore-formicarium")]
546 #[cfg_attr(feature = "serde", serde(alias = "formicairum", alias = "memecore-formicarium"))]
547 Formicarium = 43521,
548 #[strum(to_string = "insectarium", serialize = "memecore-insectarium")]
549 #[cfg_attr(feature = "serde", serde(alias = "insectarium", alias = "memecore-insectarium"))]
550 Insectarium = 43522,
551
552 TempoTestnet = 42429,
553}
554
555impl Default for NamedChain {
558 #[inline]
559 fn default() -> Self {
560 Self::Mainnet
561 }
562}
563
564macro_rules! impl_into_numeric {
565 ($($t:ty)+) => {$(
566 impl From<NamedChain> for $t {
567 #[inline]
568 fn from(chain: NamedChain) -> Self {
569 chain as $t
570 }
571 }
572 )+};
573}
574
575impl_into_numeric!(u64 i64 u128 i128);
576#[cfg(target_pointer_width = "64")]
577impl_into_numeric!(usize isize);
578
579macro_rules! impl_try_from_numeric {
580 ($($native:ty)+) => {
581 $(
582 impl TryFrom<$native> for NamedChain {
583 type Error = TryFromPrimitiveError<NamedChain>;
584
585 #[inline]
586 fn try_from(value: $native) -> Result<Self, Self::Error> {
587 (value as u64).try_into()
588 }
589 }
590 )+
591 };
592}
593
594impl_try_from_numeric!(u8 i8 u16 i16 u32 i32 usize isize);
595
596impl fmt::Display for NamedChain {
597 #[inline]
598 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
599 self.as_str().fmt(f)
600 }
601}
602
603impl AsRef<str> for NamedChain {
604 #[inline]
605 fn as_ref(&self) -> &str {
606 self.as_str()
607 }
608}
609
610impl PartialEq<u64> for NamedChain {
611 #[inline]
612 fn eq(&self, other: &u64) -> bool {
613 (*self as u64) == *other
614 }
615}
616
617impl PartialOrd<u64> for NamedChain {
618 #[inline]
619 fn partial_cmp(&self, other: &u64) -> Option<Ordering> {
620 (*self as u64).partial_cmp(other)
621 }
622}
623
624#[cfg(feature = "serde")]
625impl serde::Serialize for NamedChain {
626 #[inline]
627 fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
628 s.serialize_str(self.as_ref())
629 }
630}
631
632#[cfg(feature = "rlp")]
633impl alloy_rlp::Encodable for NamedChain {
634 #[inline]
635 fn encode(&self, out: &mut dyn alloy_rlp::BufMut) {
636 (*self as u64).encode(out)
637 }
638
639 #[inline]
640 fn length(&self) -> usize {
641 (*self as u64).length()
642 }
643}
644
645#[cfg(feature = "rlp")]
646impl alloy_rlp::Decodable for NamedChain {
647 #[inline]
648 fn decode(buf: &mut &[u8]) -> alloy_rlp::Result<Self> {
649 let n = u64::decode(buf)?;
650 Self::try_from(n).map_err(|_| alloy_rlp::Error::Overflow)
651 }
652}
653
654#[cfg(feature = "arbitrary")]
655impl<'a> arbitrary::Arbitrary<'a> for NamedChain {
656 fn arbitrary(u: &mut arbitrary::Unstructured<'a>) -> arbitrary::Result<Self> {
657 use strum::{EnumCount, VariantArray};
658 let idx = u.choose_index(NamedChain::COUNT)?;
659 Ok(NamedChain::VARIANTS[idx])
660 }
661}
662
663#[allow(clippy::match_like_matches_macro)]
666#[deny(unreachable_patterns, unused_variables)]
667impl NamedChain {
668 #[inline]
670 pub fn as_str(&self) -> &'static str {
671 self.into()
672 }
673
674 pub const fn is_ethereum(&self) -> bool {
676 use NamedChain::*;
677
678 matches!(self, Mainnet | Morden | Ropsten | Rinkeby | Goerli | Kovan | Holesky | Sepolia)
679 }
680
681 pub const fn is_optimism(self) -> bool {
683 use NamedChain::*;
684
685 matches!(
686 self,
687 Optimism
688 | OptimismGoerli
689 | OptimismKovan
690 | OptimismSepolia
691 | Base
692 | BaseGoerli
693 | BaseSepolia
694 | Fraxtal
695 | FraxtalTestnet
696 | Ink
697 | InkSepolia
698 | Mode
699 | ModeSepolia
700 | Pgn
701 | PgnSepolia
702 | Zora
703 | ZoraSepolia
704 | BlastSepolia
705 | OpBNBMainnet
706 | OpBNBTestnet
707 | Soneium
708 | SoneiumMinatoTestnet
709 | Odyssey
710 | World
711 | WorldSepolia
712 | Unichain
713 | UnichainSepolia
714 | HappychainTestnet
715 | Lisk
716 | Celo
717 | Katana
718 )
719 }
720
721 pub const fn is_gnosis(self) -> bool {
723 use NamedChain::*;
724
725 matches!(self, Gnosis | Chiado)
726 }
727
728 pub const fn is_polygon(self) -> bool {
730 use NamedChain::*;
731
732 matches!(self, Polygon | PolygonAmoy)
733 }
734
735 pub const fn is_arbitrum(self) -> bool {
737 use NamedChain::*;
738
739 matches!(self, Arbitrum | ArbitrumTestnet | ArbitrumGoerli | ArbitrumSepolia | ArbitrumNova)
740 }
741
742 pub const fn is_elastic(self) -> bool {
744 use NamedChain::*;
745
746 matches!(
747 self,
748 ZkSync
749 | ZkSyncTestnet
750 | Abstract
751 | AbstractTestnet
752 | Sophon
753 | SophonTestnet
754 | Lens
755 | LensTestnet
756 )
757 }
758
759 pub const fn is_tempo(self) -> bool {
761 use NamedChain::*;
762
763 matches!(self, TempoTestnet)
764 }
765
766 pub const fn average_blocktime_hint(self) -> Option<Duration> {
785 use NamedChain::*;
786
787 Some(Duration::from_millis(match self {
788 Mainnet | Taiko | TaikoHekla | SignetPecorino => 12_000,
789
790 Arbitrum
791 | ArbitrumTestnet
792 | ArbitrumGoerli
793 | ArbitrumSepolia
794 | GravityAlphaMainnet
795 | GravityAlphaTestnetSepolia
796 | Xai
797 | XaiSepolia
798 | Syndr
799 | SyndrSepolia
800 | ArbitrumNova
801 | ApeChain
802 | Curtis
803 | SuperpositionTestnet
804 | Superposition => 260,
805
806 Optimism | OptimismGoerli | OptimismSepolia | Base | BaseGoerli | BaseSepolia
807 | Blast | BlastSepolia | Fraxtal | FraxtalTestnet | Zora | ZoraSepolia | Mantle
808 | MantleSepolia | Mode | ModeSepolia | Pgn | PgnSepolia | HappychainTestnet
809 | Soneium | SoneiumMinatoTestnet | Bob | BobSepolia => 2_000,
810
811 Ink | InkSepolia | Odyssey | Plasma => 1_000,
812
813 Viction => 2_000,
814
815 Polygon | PolygonAmoy => 2_100,
816
817 Acala | AcalaMandalaTestnet | AcalaTestnet | Karura | KaruraTestnet => 12_500,
818
819 Moonbeam | Moonriver => 6_500,
820
821 BinanceSmartChain | BinanceSmartChainTestnet => 750,
822
823 Avalanche | AvalancheFuji => 2_000,
824
825 Fantom | FantomTestnet => 1_200,
826
827 Cronos | CronosTestnet | Canto | CantoTestnet => 5_700,
828
829 Evmos | EvmosTestnet => 1_900,
830
831 Aurora | AuroraTestnet => 1_100,
832
833 Oasis => 5_500,
834
835 Emerald | Darwinia | Crab | Koi => 6_000,
836
837 Dev | AnvilHardhat => 200,
838
839 Celo | CeloSepolia => 1_000,
840
841 FilecoinCalibrationTestnet | FilecoinMainnet => 30_000,
842
843 Scroll | ScrollSepolia => 3_000,
844
845 Shimmer => 5_000,
846
847 Gnosis | Chiado => 5_000,
848
849 Elastos => 5_000,
850
851 Etherlink => 5_000,
852
853 EtherlinkTestnet => 5_000,
854
855 Degen => 600,
856
857 Cfx | CfxTestnet => 500,
858
859 OpBNBMainnet | OpBNBTestnet | AutonomysNovaTestnet => 1_000,
860
861 Ronin | RoninTestnet => 3_000,
862
863 Flare => 1_800,
864
865 FlareCoston2 => 2_500,
866
867 Pulsechain => 10000,
868 PulsechainTestnet => 10101,
869
870 Immutable | ImmutableTestnet => 2_000,
871
872 World | WorldSepolia => 2_000,
873
874 Iotex => 5_000,
875 Core => 3_000,
876 Merlin => 3_000,
877 Bitlayer => 3_000,
878 Vana => 6_000,
879 Zeta => 6_000,
880 Kaia => 1_000,
881 Story => 2_500,
882 Sei | SeiTestnet => 500,
883 StableMainnet | StableTestnet => 700,
884
885 XdcMainnet => 2400,
886 XdcTestnet => 2400,
887
888 Sonic | SonicTestnet => 1_000,
889
890 TelosEvm | TelosEvmTestnet => 500,
891
892 UnichainSepolia | Unichain => 1_000,
893
894 BerachainBepolia | Berachain => 2_000,
895
896 Monad | MonadTestnet | TempoTestnet => 400,
897
898 Hyperliquid => 2_000,
899
900 Abstract | AbstractTestnet => 1_000,
901 ZkSync | ZkSyncTestnet => 1_000,
902 Sophon | SophonTestnet => 1_000,
903 Lens | LensTestnet => 1_000,
904 Rsk | RskTestnet => 25_000,
905 Injective | InjectiveTestnet => 700,
906 Katana => 1_000,
907 Lisk => 2_000,
908 Fuse => 5_000,
909 FluentDevnet => 3_000,
910 FluentTestnet => 1_000,
911 MemeCore | Formicarium | Insectarium => 7_000,
912
913 SkaleBase | SkaleBaseSepoliaTestnet => 1_000,
914
915 Morden | Ropsten | Rinkeby | Goerli | Kovan | Sepolia | Holesky | Hoodi | Moonbase
916 | MoonbeamDev | OptimismKovan | Poa | Sokol | EmeraldTestnet | Boba | Metis | Linea
917 | LineaGoerli | LineaSepolia | Treasure | TreasureTopaz | Corn | CornTestnet
918 | Cannon | PolkadotTestnet => {
919 return None;
920 }
921 }))
922 }
923
924 pub const fn is_legacy(self) -> bool {
935 use NamedChain::*;
936
937 match self {
938 Elastos | Emerald | EmeraldTestnet | Fantom | FantomTestnet | OptimismKovan | Ronin
940 | RoninTestnet | Rsk | RskTestnet | Shimmer | Treasure | TreasureTopaz | Viction
941 | Sophon | SophonTestnet => true,
942
943 Mainnet
945 | Goerli
946 | Sepolia
947 | Holesky
948 | Hoodi
949 | Odyssey
950 | Acala
951 | AcalaMandalaTestnet
952 | AcalaTestnet
953 | ArbitrumTestnet
954 | Base
955 | BaseGoerli
956 | BaseSepolia
957 | Boba
958 | Metis
959 | Oasis
960 | Blast
961 | BlastSepolia
962 | Celo
963 | CeloSepolia
964 | Fraxtal
965 | FraxtalTestnet
966 | Optimism
967 | OptimismGoerli
968 | OptimismSepolia
969 | Bob
970 | BobSepolia
971 | Polygon
972 | PolygonAmoy
973 | Avalanche
974 | AvalancheFuji
975 | Arbitrum
976 | ArbitrumGoerli
977 | ArbitrumSepolia
978 | ArbitrumNova
979 | GravityAlphaMainnet
980 | GravityAlphaTestnetSepolia
981 | Xai
982 | XaiSepolia
983 | HappychainTestnet
984 | Syndr
985 | SyndrSepolia
986 | FilecoinMainnet
987 | Linea
988 | LineaGoerli
989 | LineaSepolia
990 | FilecoinCalibrationTestnet
991 | Gnosis
992 | Chiado
993 | Zora
994 | ZoraSepolia
995 | Ink
996 | InkSepolia
997 | Mantle
998 | MantleSepolia
999 | Mode
1000 | ModeSepolia
1001 | Pgn
1002 | PgnSepolia
1003 | Etherlink
1004 | EtherlinkTestnet
1005 | Degen
1006 | OpBNBMainnet
1007 | OpBNBTestnet
1008 | Taiko
1009 | TaikoHekla
1010 | AutonomysNovaTestnet
1011 | Flare
1012 | FlareCoston2
1013 | Scroll
1014 | ScrollSepolia
1015 | Darwinia
1016 | Cfx
1017 | CfxTestnet
1018 | Crab
1019 | Pulsechain
1020 | PulsechainTestnet
1021 | Koi
1022 | Immutable
1023 | ImmutableTestnet
1024 | Soneium
1025 | SoneiumMinatoTestnet
1026 | Sonic
1027 | SonicTestnet
1028 | World
1029 | WorldSepolia
1030 | Unichain
1031 | UnichainSepolia
1032 | SignetPecorino
1033 | ApeChain
1034 | BerachainBepolia
1035 | Berachain
1036 | Curtis
1037 | SuperpositionTestnet
1038 | Superposition
1039 | Monad
1040 | MonadTestnet
1041 | Hyperliquid
1042 | Corn
1043 | CornTestnet
1044 | ZkSync
1045 | ZkSyncTestnet
1046 | AbstractTestnet
1047 | Abstract
1048 | Lens
1049 | LensTestnet
1050 | BinanceSmartChain
1051 | BinanceSmartChainTestnet
1052 | Karura
1053 | KaruraTestnet
1054 | TelosEvm
1055 | TelosEvmTestnet
1056 | FluentDevnet
1057 | FluentTestnet
1058 | Plasma
1059 | MemeCore
1060 | Formicarium
1061 | Insectarium => false,
1062
1063 Dev
1065 | AnvilHardhat
1066 | Morden
1067 | Ropsten
1068 | Rinkeby
1069 | Cronos
1070 | CronosTestnet
1071 | Kovan
1072 | Sokol
1073 | Poa
1074 | Moonbeam
1075 | MoonbeamDev
1076 | Moonriver
1077 | Moonbase
1078 | Evmos
1079 | EvmosTestnet
1080 | Aurora
1081 | AuroraTestnet
1082 | Canto
1083 | CantoTestnet
1084 | Iotex
1085 | Core
1086 | Merlin
1087 | Bitlayer
1088 | Vana
1089 | Zeta
1090 | Kaia
1091 | Story
1092 | Sei
1093 | SeiTestnet
1094 | StableMainnet
1095 | StableTestnet
1096 | Injective
1097 | InjectiveTestnet
1098 | Katana
1099 | Lisk
1100 | Fuse
1101 | Cannon
1102 | SkaleBase
1103 | SkaleBaseSepoliaTestnet
1104 | PolkadotTestnet
1105 | XdcMainnet
1106 | XdcTestnet
1107 | TempoTestnet => false,
1108 }
1109 }
1110
1111 pub const fn supports_shanghai(self) -> bool {
1115 use NamedChain::*;
1116
1117 matches!(
1118 self,
1119 Mainnet
1120 | Goerli
1121 | Sepolia
1122 | Holesky
1123 | Hoodi
1124 | AnvilHardhat
1125 | Optimism
1126 | OptimismGoerli
1127 | OptimismSepolia
1128 | Bob
1129 | BobSepolia
1130 | Odyssey
1131 | Base
1132 | BaseGoerli
1133 | BaseSepolia
1134 | Blast
1135 | BlastSepolia
1136 | Celo
1137 | CeloSepolia
1138 | Fraxtal
1139 | FraxtalTestnet
1140 | Ink
1141 | InkSepolia
1142 | Gnosis
1143 | Chiado
1144 | ZoraSepolia
1145 | Mantle
1146 | MantleSepolia
1147 | Mode
1148 | ModeSepolia
1149 | Polygon
1150 | Arbitrum
1151 | ArbitrumNova
1152 | ArbitrumSepolia
1153 | GravityAlphaMainnet
1154 | GravityAlphaTestnetSepolia
1155 | Xai
1156 | XaiSepolia
1157 | Syndr
1158 | SyndrSepolia
1159 | Etherlink
1160 | EtherlinkTestnet
1161 | Scroll
1162 | ScrollSepolia
1163 | HappychainTestnet
1164 | Shimmer
1165 | BinanceSmartChain
1166 | BinanceSmartChainTestnet
1167 | OpBNBMainnet
1168 | OpBNBTestnet
1169 | Taiko
1170 | TaikoHekla
1171 | Avalanche
1172 | AvalancheFuji
1173 | AutonomysNovaTestnet
1174 | Acala
1175 | AcalaMandalaTestnet
1176 | AcalaTestnet
1177 | Karura
1178 | KaruraTestnet
1179 | Darwinia
1180 | Crab
1181 | Cfx
1182 | CfxTestnet
1183 | Pulsechain
1184 | PulsechainTestnet
1185 | Koi
1186 | Immutable
1187 | ImmutableTestnet
1188 | Soneium
1189 | SoneiumMinatoTestnet
1190 | World
1191 | WorldSepolia
1192 | Iotex
1193 | Unichain
1194 | UnichainSepolia
1195 | SignetPecorino
1196 | StableMainnet
1197 | StableTestnet
1198 | ApeChain
1199 | Curtis
1200 | SuperpositionTestnet
1201 | Superposition
1202 | Monad
1203 | MonadTestnet
1204 | Corn
1205 | CornTestnet
1206 | Rsk
1207 | RskTestnet
1208 | Berachain
1209 | BerachainBepolia
1210 | Injective
1211 | InjectiveTestnet
1212 | FluentDevnet
1213 | FluentTestnet
1214 | Cannon
1215 | MemeCore
1216 | Formicarium
1217 | Insectarium
1218 )
1219 }
1220
1221 pub const fn is_testnet(self) -> bool {
1223 use NamedChain::*;
1224
1225 match self {
1226 Goerli | Holesky | Kovan | Sepolia | Morden | Ropsten | Rinkeby | Hoodi => true,
1228
1229 ArbitrumGoerli
1231 | ArbitrumSepolia
1232 | ArbitrumTestnet
1233 | SyndrSepolia
1234 | AuroraTestnet
1235 | AvalancheFuji
1236 | Odyssey
1237 | BaseGoerli
1238 | BaseSepolia
1239 | BlastSepolia
1240 | BinanceSmartChainTestnet
1241 | CantoTestnet
1242 | CronosTestnet
1243 | CeloSepolia
1244 | EmeraldTestnet
1245 | EvmosTestnet
1246 | FantomTestnet
1247 | FilecoinCalibrationTestnet
1248 | FraxtalTestnet
1249 | HappychainTestnet
1250 | LineaGoerli
1251 | LineaSepolia
1252 | InkSepolia
1253 | MantleSepolia
1254 | MoonbeamDev
1255 | OptimismGoerli
1256 | OptimismKovan
1257 | OptimismSepolia
1258 | BobSepolia
1259 | PolygonAmoy
1260 | ScrollSepolia
1261 | Shimmer
1262 | ZkSyncTestnet
1263 | ZoraSepolia
1264 | ModeSepolia
1265 | PgnSepolia
1266 | EtherlinkTestnet
1267 | OpBNBTestnet
1268 | RoninTestnet
1269 | TaikoHekla
1270 | AutonomysNovaTestnet
1271 | FlareCoston2
1272 | AcalaMandalaTestnet
1273 | AcalaTestnet
1274 | KaruraTestnet
1275 | CfxTestnet
1276 | PulsechainTestnet
1277 | GravityAlphaTestnetSepolia
1278 | XaiSepolia
1279 | Koi
1280 | ImmutableTestnet
1281 | SoneiumMinatoTestnet
1282 | WorldSepolia
1283 | UnichainSepolia
1284 | SignetPecorino
1285 | Curtis
1286 | TreasureTopaz
1287 | SonicTestnet
1288 | BerachainBepolia
1289 | SuperpositionTestnet
1290 | MonadTestnet
1291 | RskTestnet
1292 | TelosEvmTestnet
1293 | AbstractTestnet
1294 | LensTestnet
1295 | SophonTestnet
1296 | PolkadotTestnet
1297 | InjectiveTestnet
1298 | FluentDevnet
1299 | FluentTestnet
1300 | SeiTestnet
1301 | StableTestnet
1302 | CornTestnet
1303 | Formicarium
1304 | Insectarium
1305 | SkaleBaseSepoliaTestnet
1306 | XdcTestnet
1307 | TempoTestnet => true,
1308
1309 Dev | AnvilHardhat | Cannon => true,
1311
1312 Mainnet | Optimism | Arbitrum | ArbitrumNova | Blast | Syndr | Cronos | Rsk
1314 | BinanceSmartChain | Poa | Sokol | Scroll | Metis | Gnosis | Polygon | Fantom
1315 | Moonbeam | Moonriver | Moonbase | Evmos | Chiado | Oasis | Emerald | Plasma
1316 | FilecoinMainnet | Avalanche | Celo | Aurora | Canto | Boba | Base | Fraxtal | Ink
1317 | Linea | ZkSync | Mantle | GravityAlphaMainnet | Xai | Zora | Pgn | Mode | Viction
1318 | Elastos | Degen | OpBNBMainnet | Ronin | Taiko | Flare | Acala | Karura
1319 | Darwinia | Cfx | Crab | Pulsechain | Etherlink | Immutable | World | Iotex | Core
1320 | Merlin | Bitlayer | ApeChain | Vana | Zeta | Kaia | Treasure | Bob | Soneium
1321 | Sonic | Superposition | Berachain | Monad | Unichain | TelosEvm | Story | Sei
1322 | StableMainnet | Hyperliquid | Abstract | Sophon | Lens | Corn | Katana | Lisk
1323 | Fuse | Injective | MemeCore | SkaleBase | XdcMainnet => false,
1324 }
1325 }
1326
1327 pub const fn native_currency_symbol(self) -> Option<&'static str> {
1329 use NamedChain::*;
1330
1331 Some(match self {
1332 Mainnet | Goerli | Holesky | Kovan | Sepolia | Morden | Ropsten | Rinkeby | Scroll
1333 | ScrollSepolia | Taiko | TaikoHekla | Unichain | UnichainSepolia
1334 | SuperpositionTestnet | Superposition | Abstract | ZkSync | ZkSyncTestnet | Katana
1335 | Lisk | Base | BaseGoerli | BaseSepolia | Optimism | OptimismSepolia => "ETH",
1336
1337 Mantle | MantleSepolia => "MNT",
1338
1339 GravityAlphaMainnet | GravityAlphaTestnetSepolia => "G",
1340
1341 Celo | CeloSepolia => "CELO",
1342
1343 Xai | XaiSepolia => "XAI",
1344
1345 HappychainTestnet => "HAPPY",
1346
1347 BinanceSmartChain | BinanceSmartChainTestnet | OpBNBMainnet | OpBNBTestnet => "BNB",
1348
1349 Etherlink | EtherlinkTestnet => "XTZ",
1350
1351 Degen => "DEGEN",
1352
1353 Ronin | RoninTestnet => "RON",
1354
1355 Shimmer => "SMR",
1356
1357 Flare => "FLR",
1358
1359 FlareCoston2 => "C2FLR",
1360
1361 Darwinia => "RING",
1362
1363 Crab => "CRAB",
1364
1365 Koi => "KRING",
1366
1367 Cfx | CfxTestnet => "CFX",
1368 Pulsechain | PulsechainTestnet => "PLS",
1369
1370 Immutable => "IMX",
1371 ImmutableTestnet => "tIMX",
1372
1373 World | WorldSepolia => "WRLD",
1374
1375 Iotex => "IOTX",
1376 Core => "CORE",
1377 Merlin => "BTC",
1378 Bitlayer => "BTC",
1379 Vana => "VANA",
1380 Zeta => "ZETA",
1381 Kaia => "KAIA",
1382 Story => "IP",
1383 Sei | SeiTestnet => "SEI",
1384 StableMainnet | StableTestnet => "gUSDT",
1385 ApeChain | Curtis => "APE",
1386
1387 XdcMainnet => "XDC",
1388 XdcTestnet => "TXDC",
1389
1390 Treasure | TreasureTopaz => "MAGIC",
1391
1392 BerachainBepolia | Berachain => "BERA",
1393
1394 Monad | MonadTestnet => "MON",
1395
1396 Sonic | SonicTestnet => "S",
1397
1398 TelosEvm | TelosEvmTestnet => "TLOS",
1399
1400 Hyperliquid => "HYPE",
1401
1402 SignetPecorino => "USDS",
1403
1404 Polygon | PolygonAmoy => "POL",
1405
1406 Corn | CornTestnet => "BTCN",
1407
1408 Sophon | SophonTestnet => "SOPH",
1409
1410 LensTestnet => "GRASS",
1411 Lens => "GHO",
1412
1413 Rsk => "RBTC",
1414 RskTestnet => "tRBTC",
1415
1416 Injective | InjectiveTestnet => "INJ",
1417
1418 Plasma => "XPL",
1419
1420 MemeCore => "M",
1421 Formicarium => "tM",
1422 Insectarium => "tM",
1423
1424 _ => return None,
1425 })
1426 }
1427
1428 pub const fn etherscan_urls(self) -> Option<(&'static str, &'static str)> {
1446 use NamedChain::*;
1447
1448 Some(match self {
1449 Mainnet => ("https://api.etherscan.io/v2/api?chainid=1", "https://etherscan.io"),
1450 Sepolia => {
1451 ("https://api.etherscan.io/v2/api?chainid=11155111", "https://sepolia.etherscan.io")
1452 }
1453 Holesky => {
1454 ("https://api.etherscan.io/v2/api?chainid=17000", "https://holesky.etherscan.io")
1455 }
1456 Hoodi => {
1457 ("https://api.etherscan.io/v2/api?chainid=560048", "https://hoodi.etherscan.io")
1458 }
1459 Polygon => ("https://api.etherscan.io/v2/api?chainid=137", "https://polygonscan.com"),
1460 PolygonAmoy => {
1461 ("https://api.etherscan.io/v2/api?chainid=80002", "https://amoy.polygonscan.com")
1462 }
1463 Avalanche => ("https://api.etherscan.io/v2/api?chainid=43114", "https://snowscan.xyz"),
1464 AvalancheFuji => {
1465 ("https://api.etherscan.io/v2/api?chainid=43113", "https://testnet.snowscan.xyz")
1466 }
1467 Optimism => {
1468 ("https://api.etherscan.io/v2/api?chainid=10", "https://optimistic.etherscan.io")
1469 }
1470 OptimismSepolia => (
1471 "https://api.etherscan.io/v2/api?chainid=11155420",
1472 "https://sepolia-optimism.etherscan.io",
1473 ),
1474 Bob => ("https://explorer.gobob.xyz/api", "https://explorer.gobob.xyz"),
1475 BobSepolia => (
1476 "https://bob-sepolia.explorer.gobob.xyz/api",
1477 "https://bob-sepolia.explorer.gobob.xyz",
1478 ),
1479 BinanceSmartChain => {
1480 ("https://api.etherscan.io/v2/api?chainid=56", "https://bscscan.com")
1481 }
1482 BinanceSmartChainTestnet => {
1483 ("https://api.etherscan.io/v2/api?chainid=97", "https://testnet.bscscan.com")
1484 }
1485 OpBNBMainnet => {
1486 ("https://api.etherscan.io/v2/api?chainid=204", "https://opbnb.bscscan.com")
1487 }
1488 OpBNBTestnet => (
1489 "https://api.etherscan.io/v2/api?chainid=5611",
1490 "https://opbnb-testnet.bscscan.com",
1491 ),
1492 Arbitrum => ("https://api.etherscan.io/v2/api?chainid=42161", "https://arbiscan.io"),
1493 ArbitrumSepolia => {
1494 ("https://api.etherscan.io/v2/api?chainid=421614", "https://sepolia.arbiscan.io")
1495 }
1496 ArbitrumNova => {
1497 ("https://api.etherscan.io/v2/api?chainid=42170", "https://nova.arbiscan.io")
1498 }
1499 GravityAlphaMainnet => {
1500 ("https://explorer.gravity.xyz/api", "https://explorer.gravity.xyz")
1501 }
1502 GravityAlphaTestnetSepolia => {
1503 ("https://explorer-sepolia.gravity.xyz/api", "https://explorer-sepolia.gravity.xyz")
1504 }
1505 HappychainTestnet => {
1506 ("https://explorer.testnet.happy.tech/api", "https://explorer.testnet.happy.tech")
1507 }
1508 XaiSepolia => (
1509 "https://api.etherscan.io/v2/api?chainid=37714555429",
1510 "https://sepolia.xaiscan.io",
1511 ),
1512 Xai => ("https://api.etherscan.io/v2/api?chainid=660279", "https://xaiscan.io"),
1513 Syndr => ("https://explorer.syndr.com/api", "https://explorer.syndr.com"),
1514 SyndrSepolia => {
1515 ("https://sepolia-explorer.syndr.com/api", "https://sepolia-explorer.syndr.com")
1516 }
1517 Cronos => ("https://api.etherscan.io/v2/api?chainid=25", "https://cronoscan.com"),
1518 Moonbeam => {
1519 ("https://api.etherscan.io/v2/api?chainid=1284", "https://moonbeam.moonscan.io")
1520 }
1521 Moonbase => {
1522 ("https://api.etherscan.io/v2/api?chainid=1287", "https://moonbase.moonscan.io")
1523 }
1524 Moonriver => {
1525 ("https://api.etherscan.io/v2/api?chainid=1285", "https://moonriver.moonscan.io")
1526 }
1527 Gnosis => ("https://api.etherscan.io/v2/api?chainid=100", "https://gnosisscan.io"),
1528 Scroll => ("https://api.etherscan.io/v2/api?chainid=534352", "https://scrollscan.com"),
1529 ScrollSepolia => {
1530 ("https://api.etherscan.io/v2/api?chainid=534351", "https://sepolia.scrollscan.com")
1531 }
1532 Ink => ("https://explorer.inkonchain.com/api/v2", "https://explorer.inkonchain.com"),
1533 InkSepolia => (
1534 "https://explorer-sepolia.inkonchain.com/api/v2",
1535 "https://explorer-sepolia.inkonchain.com",
1536 ),
1537 Shimmer => {
1538 ("https://explorer.evm.shimmer.network/api", "https://explorer.evm.shimmer.network")
1539 }
1540 Metis => (
1541 "https://api.routescan.io/v2/network/mainnet/evm/1088/etherscan",
1542 "https://explorer.metis.io",
1543 ),
1544 Chiado => {
1545 ("https://gnosis-chiado.blockscout.com/api", "https://gnosis-chiado.blockscout.com")
1546 }
1547 Plasma => (
1548 "https://api.routescan.io/v2/network/mainnet/evm/9745/etherscan/api",
1549 "https://plasmascan.to",
1550 ),
1551 FilecoinCalibrationTestnet => (
1552 "https://api.calibration.node.glif.io/rpc/v1",
1553 "https://calibration.filfox.info/en",
1554 ),
1555 Rsk => ("https://blockscout.com/rsk/mainnet/api", "https://blockscout.com/rsk/mainnet"),
1556 RskTestnet => (
1557 "https://rootstock-testnet.blockscout.com/api",
1558 "https://rootstock-testnet.blockscout.com",
1559 ),
1560 Emerald => {
1561 ("https://explorer.emerald.oasis.dev/api", "https://explorer.emerald.oasis.dev")
1562 }
1563 EmeraldTestnet => (
1564 "https://testnet.explorer.emerald.oasis.dev/api",
1565 "https://testnet.explorer.emerald.oasis.dev",
1566 ),
1567 Aurora => ("https://api.aurorascan.dev/api", "https://aurorascan.dev"),
1568 AuroraTestnet => {
1569 ("https://testnet.aurorascan.dev/api", "https://testnet.aurorascan.dev")
1570 }
1571 Celo => ("https://api.etherscan.io/v2/api?chainid=42220", "https://celoscan.io"),
1572 CeloSepolia => {
1573 ("https://api.etherscan.io/v2/api?chainid=11142220", "https://sepolia.celoscan.io")
1574 }
1575 Boba => ("https://api.bobascan.com/api", "https://bobascan.com"),
1576 Base => ("https://api.etherscan.io/v2/api?chainid=8453", "https://basescan.org"),
1577 BaseSepolia => {
1578 ("https://api.etherscan.io/v2/api?chainid=84532", "https://sepolia.basescan.org")
1579 }
1580 Fraxtal => ("https://api.etherscan.io/v2/api?chainid=252", "https://fraxscan.com"),
1581 FraxtalTestnet => {
1582 ("https://api.etherscan.io/v2/api?chainid=2522", "https://holesky.fraxscan.com")
1583 }
1584 Blast => ("https://api.etherscan.io/v2/api?chainid=81457", "https://blastscan.io"),
1585 BlastSepolia => (
1586 "https://api.etherscan.io/v2/api?chainid=168587773",
1587 "https://sepolia.blastscan.io",
1588 ),
1589 ZkSync => ("https://api.etherscan.io/v2/api?chainid=324", "https://era.zksync.network"),
1590 ZkSyncTestnet => (
1591 "https://api.etherscan.io/v2/api?chainid=300",
1592 "https://sepolia-era.zksync.network",
1593 ),
1594 Linea => ("https://api.etherscan.io/v2/api?chainid=59144", "https://lineascan.build"),
1595 LineaSepolia => {
1596 ("https://api.etherscan.io/v2/api?chainid=59141", "https://sepolia.lineascan.build")
1597 }
1598 Mantle => ("https://api.etherscan.io/v2/api?chainid=5000", "https://mantlescan.xyz"),
1599 MantleSepolia => {
1600 ("https://api.etherscan.io/v2/api?chainid=5003", "https://sepolia.mantlescan.xyz")
1601 }
1602 Viction => ("https://www.vicscan.xyz/api", "https://www.vicscan.xyz"),
1603 Zora => ("https://explorer.zora.energy/api", "https://explorer.zora.energy"),
1604 ZoraSepolia => {
1605 ("https://sepolia.explorer.zora.energy/api", "https://sepolia.explorer.zora.energy")
1606 }
1607 Mode => ("https://explorer.mode.network/api", "https://explorer.mode.network"),
1608 ModeSepolia => (
1609 "https://sepolia.explorer.mode.network/api",
1610 "https://sepolia.explorer.mode.network",
1611 ),
1612 Elastos => ("https://esc.elastos.io/api", "https://esc.elastos.io"),
1613 Etherlink => ("https://explorer.etherlink.com/api", "https://explorer.etherlink.com"),
1614 EtherlinkTestnet => (
1615 "https://testnet.explorer.etherlink.com/api",
1616 "https://testnet.explorer.etherlink.com",
1617 ),
1618 Degen => ("https://explorer.degen.tips/api", "https://explorer.degen.tips"),
1619 Ronin => ("https://skynet-api.roninchain.com/ronin", "https://app.roninchain.com"),
1620 RoninTestnet => (
1621 "https://api-gateway.skymavis.com/rpc/testnet",
1622 "https://saigon-app.roninchain.com",
1623 ),
1624 Taiko => ("https://api.etherscan.io/v2/api?chainid=167000", "https://taikoscan.io"),
1625 TaikoHekla => {
1626 ("https://api.etherscan.io/v2/api?chainid=167009", "https://hekla.taikoscan.io")
1627 }
1628 Flare => {
1629 ("https://flare-explorer.flare.network/api", "https://flare-explorer.flare.network")
1630 }
1631 FlareCoston2 => (
1632 "https://coston2-explorer.flare.network/api",
1633 "https://coston2-explorer.flare.network",
1634 ),
1635 Acala => ("https://blockscout.acala.network/api", "https://blockscout.acala.network"),
1636 AcalaMandalaTestnet => (
1637 "https://blockscout.mandala.aca-staging.network/api",
1638 "https://blockscout.mandala.aca-staging.network",
1639 ),
1640 Karura => {
1641 ("https://blockscout.karura.network/api", "https://blockscout.karura.network")
1642 }
1643 Darwinia => {
1644 ("https://explorer.darwinia.network/api", "https://explorer.darwinia.network")
1645 }
1646 Crab => {
1647 ("https://crab-scan.darwinia.network/api", "https://crab-scan.darwinia.network")
1648 }
1649 Cfx => ("https://evmapi.confluxscan.net/api", "https://evm.confluxscan.io"),
1650 CfxTestnet => {
1651 ("https://evmapi-testnet.confluxscan.net/api", "https://evmtestnet.confluxscan.io")
1652 }
1653 Pulsechain => ("https://api.scan.pulsechain.com", "https://scan.pulsechain.com"),
1654 PulsechainTestnet => (
1655 "https://api.scan.v4.testnet.pulsechain.com",
1656 "https://scan.v4.testnet.pulsechain.com",
1657 ),
1658 Immutable => ("https://explorer.immutable.com/api", "https://explorer.immutable.com"),
1659 ImmutableTestnet => (
1660 "https://explorer.testnet.immutable.com/api",
1661 "https://explorer.testnet.immutable.com",
1662 ),
1663 Soneium => ("https://soneium.blockscout.com/api", "https://soneium.blockscout.com"),
1664 SoneiumMinatoTestnet => (
1665 "https://soneium-minato.blockscout.com/api",
1666 "https://soneium-minato.blockscout.com",
1667 ),
1668 Odyssey => {
1669 ("https://odyssey-explorer.ithaca.xyz/api", "https://odyssey-explorer.ithaca.xyz")
1670 }
1671 World => ("https://api.etherscan.io/v2/api?chainid=480", "https://worldscan.org"),
1672 WorldSepolia => {
1673 ("https://api.etherscan.io/v2/api?chainid=4801", "https://sepolia.worldscan.org")
1674 }
1675 Unichain => ("https://api.etherscan.io/v2/api?chainid=130", "https://uniscan.xyz"),
1676 UnichainSepolia => {
1677 ("https://api.etherscan.io/v2/api?chainid=1301", "https://sepolia.uniscan.xyz")
1678 }
1679 SignetPecorino => {
1680 ("https://explorer.pecorino.signet.sh/api", "https://explorer.pecorino.signet.sh")
1681 }
1682 Core => ("https://openapi.coredao.org/api", "https://scan.coredao.org"),
1683 Merlin => ("https://scan.merlinchain.io/api", "https://scan.merlinchain.io"),
1684 Bitlayer => ("https://api.btrscan.com/scan/api", "https://www.btrscan.com"),
1685 Vana => ("https://api.vanascan.io/api", "https://vanascan.io"),
1686 Zeta => ("https://zetachain.blockscout.com/api", "https://zetachain.blockscout.com"),
1687 Kaia => ("https://mainnet-oapi.kaiascan.io/api", "https://kaiascan.io"),
1688 Story => ("https://www.storyscan.xyz/api/v2", "https://www.storyscan.xyz"),
1689 Sei => ("https://api.etherscan.io/v2/api?chainid=1329", "https://seiscan.io"),
1690 SeiTestnet => {
1691 ("https://api.etherscan.io/v2/api?chainid=1328", "https://testnet.seiscan.io")
1692 }
1693 StableMainnet => {
1694 ("https://api.etherscan.io/v2/api?chainid=988", "https://stablescan.xyz")
1695 }
1696 StableTestnet => {
1697 ("https://api.etherscan.io/v2/api?chainid=2201", "https://testnet.stablescan.xyz")
1698 }
1699 XdcMainnet => ("https://api.etherscan.io/v2/api?chainid=50", "https://xdcscan.com"),
1700 XdcTestnet => {
1701 ("https://api.etherscan.io/v2/api?chainid=51", "https://testnet.xdcscan.com")
1702 }
1703 ApeChain => ("https://api.etherscan.io/v2/api?chainid=33139", "https://apescan.io"),
1704 Curtis => {
1705 ("https://api.etherscan.io/v2/api?chainid=33111", "https://curtis.apescan.io")
1706 }
1707 Sonic => ("https://api.etherscan.io/v2/api?chainid=146", "https://sonicscan.org"),
1708 SonicTestnet => {
1709 ("https://api.etherscan.io/v2/api?chainid=14601", "https://testnet.sonicscan.org")
1710 }
1711 BerachainBepolia => {
1712 ("https://api.etherscan.io/v2/api?chainid=80069", "https://testnet.berascan.com")
1713 }
1714 Berachain => ("https://api.etherscan.io/v2/api?chainid=80094", "https://berascan.com"),
1715 SuperpositionTestnet => (
1716 "https://testnet-explorer.superposition.so/api",
1717 "https://testnet-explorer.superposition.so",
1718 ),
1719 Superposition => {
1720 ("https://explorer.superposition.so/api", "https://explorer.superposition.so")
1721 }
1722 Monad => ("https://api.etherscan.io/v2/api?chainid=143", "https://monadscan.com"),
1723 MonadTestnet => {
1724 ("https://api.etherscan.io/v2/api?chainid=10143", "https://testnet.monadscan.com")
1725 }
1726 TelosEvm => ("https://api.teloscan.io/api", "https://teloscan.io"),
1727 TelosEvmTestnet => {
1728 ("https://api.testnet.teloscan.io/api", "https://testnet.teloscan.io")
1729 }
1730 Hyperliquid => {
1731 ("https://api.etherscan.io/v2/api?chainid=999", "https://hyperevmscan.io")
1732 }
1733 Abstract => ("https://api.etherscan.io/v2/api?chainid=2741", "https://abscan.org"),
1734 AbstractTestnet => {
1735 ("https://api.etherscan.io/v2/api?chainid=11124", "https://sepolia.abscan.org")
1736 }
1737 Corn => (
1738 "https://api.routescan.io/v2/network/mainnet/evm/21000000/etherscan/api",
1739 "https://cornscan.io",
1740 ),
1741 CornTestnet => (
1742 "https://api.routescan.io/v2/network/testnet/evm/21000001/etherscan/api",
1743 "https://testnet.cornscan.io",
1744 ),
1745 Sophon => ("https://api.etherscan.io/v2/api?chainid=50104", "https://sophscan.xyz"),
1746 SophonTestnet => (
1747 "https://api.etherscan.io/v2/api?chainid=531050104",
1748 "https://testnet.sophscan.xyz",
1749 ),
1750 Lens => ("https://explorer-api.lens.xyz", "https://explorer.lens.xyz"),
1751 LensTestnet => (
1752 "https://block-explorer-api.staging.lens.zksync.dev",
1753 "https://explorer.testnet.lens.xyz",
1754 ),
1755 Katana => ("https://api.etherscan.io/v2/api?chainid=747474", "https://katanascan.com"),
1756 Lisk => ("https://blockscout.lisk.com/api", "https://blockscout.lisk.com"),
1757 Fuse => ("https://explorer.fuse.io/api", "https://explorer.fuse.io"),
1758 Injective => (
1759 "https://blockscout-api.injective.network/api",
1760 "https://blockscout.injective.network",
1761 ),
1762 InjectiveTestnet => (
1763 "https://testnet.blockscout-api.injective.network/api",
1764 "https://testnet.blockscout.injective.network",
1765 ),
1766 FluentDevnet => {
1767 ("https://blockscout.dev.gblend.xyz/api", "https://blockscout.dev.gblend.xyz")
1768 }
1769 FluentTestnet => {
1770 ("https://testnet.fluentscan.xyz/api", "https://testnet.fluentscan.xyz")
1771 }
1772 MemeCore => ("https://api.etherscan.io/v2/api?chainid=4352", "https://memecorescan.io"),
1773 Formicarium => (
1774 "https://api.etherscan.io/v2/api?chainid=43521",
1775 "https://formicarium.memecorescan.io",
1776 ),
1777 Insectarium => (
1778 "https://insectarium.blockscout.memecore.com/api",
1779 "https://insectarium.blockscout.memecore.com",
1780 ),
1781 SkaleBase => (
1782 "https://skale-base-explorer.skalenodes.com/api",
1783 "https://skale-base-explorer.skalenodes.com",
1784 ),
1785 SkaleBaseSepoliaTestnet => (
1786 "https://base-sepolia-testnet-explorer.skalenodes.com/api",
1787 "https://base-sepolia-testnet-explorer.skalenodes.com",
1788 ),
1789 TempoTestnet => ("https://scout.tempo.xyz/api", "https://scout.tempo.xyz"),
1790
1791 AcalaTestnet | AnvilHardhat | ArbitrumGoerli | ArbitrumTestnet
1792 | AutonomysNovaTestnet | BaseGoerli | Canto | CantoTestnet | CronosTestnet | Dev
1793 | Evmos | EvmosTestnet | Fantom | FantomTestnet | FilecoinMainnet | Goerli | Iotex
1794 | KaruraTestnet | Koi | Kovan | LineaGoerli | MoonbeamDev | Morden | Oasis
1795 | OptimismGoerli | OptimismKovan | Pgn | PgnSepolia | Poa | Rinkeby | Ropsten
1796 | Sokol | Treasure | TreasureTopaz | Cannon | PolkadotTestnet => {
1797 return None;
1798 }
1799 })
1800 }
1801
1802 pub const fn etherscan_api_key_name(self) -> Option<&'static str> {
1813 use NamedChain::*;
1814
1815 let api_key_name = match self {
1816 Abstract
1817 | AbstractTestnet
1818 | ApeChain
1819 | Arbitrum
1820 | ArbitrumGoerli
1821 | ArbitrumNova
1822 | ArbitrumSepolia
1823 | ArbitrumTestnet
1824 | Aurora
1825 | AuroraTestnet
1826 | Avalanche
1827 | AvalancheFuji
1828 | Base
1829 | BaseGoerli
1830 | BaseSepolia
1831 | BinanceSmartChain
1832 | BinanceSmartChainTestnet
1833 | Blast
1834 | BlastSepolia
1835 | Celo
1836 | Cronos
1837 | CronosTestnet
1838 | Fraxtal
1839 | FraxtalTestnet
1840 | Gnosis
1841 | Goerli
1842 | Holesky
1843 | Hoodi
1844 | Hyperliquid
1845 | Katana
1846 | Kovan
1847 | Linea
1848 | LineaSepolia
1849 | Mainnet
1850 | Mantle
1851 | MantleSepolia
1852 | Monad
1853 | MonadTestnet
1854 | Morden
1855 | OpBNBMainnet
1856 | OpBNBTestnet
1857 | Optimism
1858 | OptimismGoerli
1859 | OptimismKovan
1860 | OptimismSepolia
1861 | Polygon
1862 | PolygonAmoy
1863 | Rinkeby
1864 | Ropsten
1865 | Scroll
1866 | ScrollSepolia
1867 | Sei
1868 | SeiTestnet
1869 | StableMainnet
1870 | StableTestnet
1871 | XdcMainnet
1872 | XdcTestnet
1873 | Sonic
1874 | SonicTestnet
1875 | Sophon
1876 | SophonTestnet
1877 | Syndr
1878 | SyndrSepolia
1879 | Taiko
1880 | TaikoHekla
1881 | Unichain
1882 | UnichainSepolia
1883 | Xai
1884 | XaiSepolia
1885 | ZkSync
1886 | ZkSyncTestnet
1887 | MemeCore
1888 | Formicarium => "ETHERSCAN_API_KEY",
1889
1890 Fantom | FantomTestnet => "FTMSCAN_API_KEY",
1891
1892 Moonbeam | Moonbase | MoonbeamDev | Moonriver => "MOONSCAN_API_KEY",
1893
1894 Acala
1895 | AcalaMandalaTestnet
1896 | AcalaTestnet
1897 | Canto
1898 | CantoTestnet
1899 | CeloSepolia
1900 | Etherlink
1901 | EtherlinkTestnet
1902 | Flare
1903 | FlareCoston2
1904 | Karura
1905 | KaruraTestnet
1906 | Mode
1907 | ModeSepolia
1908 | Pgn
1909 | PgnSepolia
1910 | Shimmer
1911 | Zora
1912 | ZoraSepolia
1913 | Darwinia
1914 | Crab
1915 | Koi
1916 | Immutable
1917 | ImmutableTestnet
1918 | Soneium
1919 | SoneiumMinatoTestnet
1920 | World
1921 | WorldSepolia
1922 | Curtis
1923 | Ink
1924 | InkSepolia
1925 | SuperpositionTestnet
1926 | Superposition
1927 | Vana
1928 | Story
1929 | Lisk
1930 | Fuse
1931 | Injective
1932 | InjectiveTestnet
1933 | SignetPecorino
1934 | SkaleBase
1935 | SkaleBaseSepoliaTestnet
1936 | TempoTestnet => "BLOCKSCOUT_API_KEY",
1937
1938 Boba => "BOBASCAN_API_KEY",
1939
1940 Core => "CORESCAN_API_KEY",
1941 Merlin => "MERLINSCAN_API_KEY",
1942 Bitlayer => "BITLAYERSCAN_API_KEY",
1943 Zeta => "ZETASCAN_API_KEY",
1944 Kaia => "KAIASCAN_API_KEY",
1945 Berachain | BerachainBepolia => "BERASCAN_API_KEY",
1946 Corn | CornTestnet | Plasma => "ROUTESCAN_API_KEY",
1947 Metis
1949 | Chiado
1950 | Odyssey
1951 | Sepolia
1952 | Rsk
1953 | RskTestnet
1954 | Sokol
1955 | Poa
1956 | Oasis
1957 | Emerald
1958 | EmeraldTestnet
1959 | Evmos
1960 | EvmosTestnet
1961 | AnvilHardhat
1962 | Dev
1963 | GravityAlphaMainnet
1964 | GravityAlphaTestnetSepolia
1965 | Bob
1966 | BobSepolia
1967 | FilecoinMainnet
1968 | LineaGoerli
1969 | FilecoinCalibrationTestnet
1970 | Viction
1971 | Elastos
1972 | Degen
1973 | Ronin
1974 | RoninTestnet
1975 | Cfx
1976 | CfxTestnet
1977 | Pulsechain
1978 | PulsechainTestnet
1979 | AutonomysNovaTestnet
1980 | Iotex
1981 | HappychainTestnet
1982 | Treasure
1983 | TreasureTopaz
1984 | TelosEvm
1985 | TelosEvmTestnet
1986 | Lens
1987 | LensTestnet
1988 | FluentDevnet
1989 | FluentTestnet
1990 | Cannon
1991 | Insectarium
1992 | PolkadotTestnet => return None,
1993 };
1994
1995 Some(api_key_name)
1996 }
1997
1998 #[cfg(feature = "std")]
2013 pub fn etherscan_api_key(self) -> Option<String> {
2014 self.etherscan_api_key_name().and_then(|name| std::env::var(name).ok())
2015 }
2016
2017 pub fn public_dns_network_protocol(self) -> Option<String> {
2021 use NamedChain::*;
2022
2023 const DNS_PREFIX: &str = "enrtree://AKA3AM6LPBYEUDMVNU3BSVQJ5AD45Y7YPOHJLEF6W26QOE4VTUDPE@";
2024 if let Mainnet | Goerli | Sepolia | Ropsten | Rinkeby | Holesky | Hoodi = self {
2025 let mut s = String::with_capacity(DNS_PREFIX.len() + 32);
2027 s.push_str(DNS_PREFIX);
2028 s.push_str("all.");
2029 let chain_str = self.as_ref();
2030 s.push_str(chain_str);
2031 let l = s.len();
2032 s[l - chain_str.len()..].make_ascii_lowercase();
2033 s.push_str(".ethdisco.net");
2034
2035 Some(s)
2036 } else {
2037 None
2038 }
2039 }
2040
2041 pub const fn wrapped_native_token(self) -> Option<Address> {
2057 use NamedChain::*;
2058
2059 let addr = match self {
2060 Mainnet => address!("C02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"),
2061 Optimism => address!("4200000000000000000000000000000000000006"),
2062 BinanceSmartChain => address!("bb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c"),
2063 OpBNBMainnet => address!("4200000000000000000000000000000000000006"),
2064 Arbitrum => address!("82af49447d8a07e3bd95bd0d56f35241523fbab1"),
2065 Base => address!("4200000000000000000000000000000000000006"),
2066 Linea => address!("e5d7c2a44ffddf6b295a15c148167daaaf5cf34f"),
2067 Mantle => address!("deaddeaddeaddeaddeaddeaddeaddeaddead1111"),
2068 Blast => address!("4300000000000000000000000000000000000004"),
2069 Gnosis => address!("e91d153e0b41518a2ce8dd3d7944fa863463a97d"),
2070 Scroll => address!("5300000000000000000000000000000000000004"),
2071 Taiko => address!("a51894664a773981c6c112c43ce576f315d5b1b6"),
2072 Avalanche => address!("b31f66aa3c1e785363f0875a1b74e27b85fd66c7"),
2073 Polygon => address!("0d500b1d8e8ef31e21c99d1db9a6444d3adf1270"),
2074 Fantom => address!("21be370d5312f44cb42ce377bc9b8a0cef1a4c83"),
2075 Iotex => address!("a00744882684c3e4747faefd68d283ea44099d03"),
2076 Core => address!("40375C92d9FAf44d2f9db9Bd9ba41a3317a2404f"),
2077 Merlin => address!("F6D226f9Dc15d9bB51182815b320D3fBE324e1bA"),
2078 Bitlayer => address!("ff204e2681a6fa0e2c3fade68a1b28fb90e4fc5f"),
2079 ApeChain => address!("48b62137EdfA95a428D35C09E44256a739F6B557"),
2080 Vana => address!("00EDdD9621Fb08436d0331c149D1690909a5906d"),
2081 Zeta => address!("5F0b1a82749cb4E2278EC87F8BF6B618dC71a8bf"),
2082 Kaia => address!("19aac5f612f524b754ca7e7c41cbfa2e981a4432"),
2083 Story => address!("1514000000000000000000000000000000000000"),
2084 Treasure => address!("263d8f36bb8d0d9526255e205868c26690b04b88"),
2085 Superposition => address!("1fB719f10b56d7a85DCD32f27f897375fB21cfdd"),
2086 Sonic => address!("039e2fB66102314Ce7b64Ce5Ce3E5183bc94aD38"),
2087 Berachain => address!("6969696969696969696969696969696969696969"),
2088 Hyperliquid => address!("5555555555555555555555555555555555555555"),
2089 Abstract => address!("3439153EB7AF838Ad19d56E1571FBD09333C2809"),
2090 Sei => address!("E30feDd158A2e3b13e9badaeABaFc5516e95e8C7"),
2091 ZkSync => address!("5aea5775959fbc2557cc8789bc1bf90a239d9a91"),
2092 Sophon => address!("f1f9e08a0818594fde4713ae0db1e46672ca960e"),
2093 Rsk => address!("967f8799af07df1534d48a95a5c9febe92c53ae0"),
2094 MemeCore | Formicarium | Insectarium => {
2095 address!("0x653e645e3d81a72e71328Bc01A04002945E3ef7A")
2096 }
2097 _ => return None,
2098 };
2099
2100 Some(addr)
2101 }
2102}
2103
2104#[cfg(test)]
2105mod tests {
2106 use super::*;
2107 use strum::{EnumCount, IntoEnumIterator};
2108
2109 #[allow(unused_imports)]
2110 use alloc::string::ToString;
2111
2112 #[test]
2113 #[cfg(feature = "serde")]
2114 fn default() {
2115 assert_eq!(serde_json::to_string(&NamedChain::default()).unwrap(), "\"mainnet\"");
2116 }
2117
2118 #[test]
2119 fn enum_iter() {
2120 assert_eq!(NamedChain::COUNT, NamedChain::iter().size_hint().0);
2121 }
2122
2123 #[test]
2124 fn roundtrip_string() {
2125 for chain in NamedChain::iter() {
2126 let chain_string = chain.to_string();
2127 assert_eq!(chain_string, format!("{chain}"));
2128 assert_eq!(chain_string.as_str(), chain.as_ref());
2129 #[cfg(feature = "serde")]
2130 assert_eq!(serde_json::to_string(&chain).unwrap(), format!("\"{chain_string}\""));
2131
2132 assert_eq!(chain_string.parse::<NamedChain>().unwrap(), chain);
2133 }
2134 }
2135
2136 #[test]
2137 #[cfg(feature = "serde")]
2138 fn roundtrip_serde() {
2139 for chain in NamedChain::iter() {
2140 let chain_string = serde_json::to_string(&chain).unwrap();
2141 let chain_string = chain_string.replace('-', "_");
2142 assert_eq!(serde_json::from_str::<'_, NamedChain>(&chain_string).unwrap(), chain);
2143 }
2144 }
2145
2146 #[test]
2147 #[cfg(feature = "arbitrary")]
2148 fn test_arbitrary_named_chain() {
2149 use arbitrary::{Arbitrary, Unstructured};
2150 let data = vec![0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 255];
2151 let mut unstructured = Unstructured::new(&data);
2152
2153 for _ in 0..10 {
2154 let _chain = NamedChain::arbitrary(&mut unstructured).unwrap();
2155 }
2156 }
2157
2158 #[test]
2159 fn aliases() {
2160 use NamedChain::*;
2161
2162 const ALIASES: &[(NamedChain, &[&str])] = &[
2164 (Mainnet, &["ethlive"]),
2165 (BinanceSmartChain, &["bsc", "bnb-smart-chain", "binance-smart-chain"]),
2166 (
2167 BinanceSmartChainTestnet,
2168 &["bsc-testnet", "bnb-smart-chain-testnet", "binance-smart-chain-testnet"],
2169 ),
2170 (Gnosis, &["gnosis", "gnosis-chain"]),
2171 (AnvilHardhat, &["anvil", "hardhat"]),
2172 (AvalancheFuji, &["fuji"]),
2173 (ZkSync, &["zksync"]),
2174 (ZkSyncTestnet, &["zksync-testnet"]),
2175 (Mantle, &["mantle"]),
2176 (MantleSepolia, &["mantle-sepolia"]),
2177 (GravityAlphaMainnet, &["gravity-alpha-mainnet"]),
2178 (GravityAlphaTestnetSepolia, &["gravity-alpha-testnet-sepolia"]),
2179 (Bob, &["bob"]),
2180 (BobSepolia, &["bob-sepolia"]),
2181 (HappychainTestnet, &["happychain-testnet"]),
2182 (Xai, &["xai"]),
2183 (XaiSepolia, &["xai-sepolia"]),
2184 (Base, &["base"]),
2185 (BaseGoerli, &["base-goerli"]),
2186 (BaseSepolia, &["base-sepolia"]),
2187 (Fraxtal, &["fraxtal"]),
2188 (FraxtalTestnet, &["fraxtal-testnet"]),
2189 (Ink, &["ink"]),
2190 (InkSepolia, &["ink-sepolia"]),
2191 (BlastSepolia, &["blast-sepolia"]),
2192 (Syndr, &["syndr"]),
2193 (SyndrSepolia, &["syndr-sepolia"]),
2194 (LineaGoerli, &["linea-goerli"]),
2195 (LineaSepolia, &["linea-sepolia"]),
2196 (AutonomysNovaTestnet, &["autonomys-nova-testnet"]),
2197 (Immutable, &["immutable"]),
2198 (ImmutableTestnet, &["immutable-testnet"]),
2199 (Soneium, &["soneium"]),
2200 (SoneiumMinatoTestnet, &["soneium-minato-testnet"]),
2201 (ApeChain, &["apechain"]),
2202 (Curtis, &["apechain-testnet", "curtis"]),
2203 (Treasure, &["treasure"]),
2204 (TreasureTopaz, &["treasure-topaz-testnet", "treasure-topaz"]),
2205 (BerachainBepolia, &["berachain-bepolia-testnet", "berachain-bepolia"]),
2206 (SuperpositionTestnet, &["superposition-testnet"]),
2207 (Superposition, &["superposition"]),
2208 (Hyperliquid, &["hyperliquid"]),
2209 (Abstract, &["abstract"]),
2210 (AbstractTestnet, &["abstract-testnet"]),
2211 (Sophon, &["sophon"]),
2212 (SophonTestnet, &["sophon-testnet"]),
2213 (Lens, &["lens"]),
2214 (LensTestnet, &["lens-testnet"]),
2215 (Katana, &["katana"]),
2216 (Lisk, &["lisk"]),
2217 (Fuse, &["fuse"]),
2218 (FluentDevnet, &["fluent-devnet"]),
2219 (FluentTestnet, &["fluent-testnet"]),
2220 (Injective, &["injective"]),
2221 (InjectiveTestnet, &["injective-testnet"]),
2222 (StableMainnet, &["stable-mainnet"]),
2223 (XdcMainnet, &["xdc-mainnet"]),
2224 (XdcTestnet, &["xdc-testnet"]),
2225 (SeiTestnet, &["sei-testnet"]),
2226 (StableTestnet, &["stable-testnet"]),
2227 (Cannon, &["cannon"]),
2228 (MemeCore, &["memecore"]),
2229 (Formicarium, &["formicarium", "memecore-formicarium"]),
2230 (Insectarium, &["insectarium", "memecore-insectarium"]),
2231 ];
2232
2233 for &(chain, aliases) in ALIASES {
2234 for &alias in aliases {
2235 let named = alias.parse::<NamedChain>().expect(alias);
2236 assert_eq!(named, chain);
2237
2238 #[cfg(feature = "serde")]
2239 {
2240 assert_eq!(
2241 serde_json::from_str::<NamedChain>(&format!("\"{alias}\"")).unwrap(),
2242 chain
2243 );
2244
2245 assert_eq!(
2246 serde_json::from_str::<NamedChain>(&format!("\"{named}\"")).unwrap(),
2247 chain
2248 );
2249 }
2250 }
2251 }
2252 }
2253
2254 #[test]
2255 #[cfg(feature = "serde")]
2256 fn serde_to_string_match() {
2257 for chain in NamedChain::iter() {
2258 let chain_serde = serde_json::to_string(&chain).unwrap();
2259 let chain_string = format!("\"{chain}\"");
2260 assert_eq!(chain_serde, chain_string);
2261 }
2262 }
2263
2264 #[test]
2265 fn test_dns_network() {
2266 let s = "enrtree://AKA3AM6LPBYEUDMVNU3BSVQJ5AD45Y7YPOHJLEF6W26QOE4VTUDPE@all.mainnet.ethdisco.net";
2267 assert_eq!(NamedChain::Mainnet.public_dns_network_protocol().unwrap(), s);
2268 }
2269
2270 #[test]
2271 fn ensure_no_trailing_etherscan_url_separator() {
2272 for chain in NamedChain::iter() {
2273 if let Some((api, base)) = chain.etherscan_urls() {
2274 assert!(!api.ends_with('/'), "{chain:?} api url has trailing /");
2275 assert!(!base.ends_with('/'), "{chain:?} base url has trailing /");
2276 }
2277 }
2278 }
2279}