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 = "mumbai", serialize = "polygon-mumbai")]
159 #[cfg_attr(feature = "serde", serde(alias = "mumbai", alias = "polygon-mumbai"))]
160 PolygonMumbai = 80001,
161 #[strum(to_string = "amoy", serialize = "polygon-amoy")]
162 #[cfg_attr(feature = "serde", serde(alias = "amoy", alias = "polygon-amoy"))]
163 PolygonAmoy = 80002,
164 #[strum(serialize = "polygon-zkevm", serialize = "zkevm")]
165 #[cfg_attr(
166 feature = "serde",
167 serde(alias = "zkevm", alias = "polygon_zkevm", alias = "polygon-zkevm")
168 )]
169 PolygonZkEvm = 1101,
170 #[strum(serialize = "polygon-zkevm-testnet", serialize = "zkevm-testnet")]
171 #[cfg_attr(
172 feature = "serde",
173 serde(
174 alias = "zkevm-testnet",
175 alias = "polygon_zkevm_testnet",
176 alias = "polygon-zkevm-testnet"
177 )
178 )]
179 PolygonZkEvmTestnet = 1442,
180
181 Fantom = 250,
182 FantomTestnet = 4002,
183
184 Moonbeam = 1284,
185 MoonbeamDev = 1281,
186
187 Moonriver = 1285,
188
189 Moonbase = 1287,
190
191 Dev = 1337,
192 #[strum(to_string = "anvil-hardhat", serialize = "anvil", serialize = "hardhat")]
193 #[cfg_attr(
194 feature = "serde",
195 serde(alias = "anvil", alias = "hardhat", alias = "anvil-hardhat")
196 )]
197 AnvilHardhat = 31337,
198
199 #[strum(to_string = "gravity-alpha-mainnet")]
200 #[cfg_attr(feature = "serde", serde(alias = "gravity-alpha-mainnet"))]
201 GravityAlphaMainnet = 1625,
202 #[strum(to_string = "gravity-alpha-testnet-sepolia")]
203 #[cfg_attr(feature = "serde", serde(alias = "gravity-alpha-testnet-sepolia"))]
204 GravityAlphaTestnetSepolia = 13505,
205
206 Evmos = 9001,
207 EvmosTestnet = 9000,
208
209 Chiado = 10200,
210
211 Oasis = 26863,
212
213 Emerald = 42262,
214 EmeraldTestnet = 42261,
215
216 FilecoinMainnet = 314,
217 FilecoinCalibrationTestnet = 314159,
218
219 Avalanche = 43114,
220 #[strum(to_string = "fuji", serialize = "avalanche-fuji")]
221 #[cfg_attr(feature = "serde", serde(alias = "fuji"))]
222 AvalancheFuji = 43113,
223
224 Celo = 42220,
225 CeloAlfajores = 44787,
226 CeloBaklava = 62320,
227
228 Aurora = 1313161554,
229 AuroraTestnet = 1313161555,
230
231 Canto = 7700,
232 CantoTestnet = 740,
233
234 Boba = 288,
235
236 Base = 8453,
237 #[cfg_attr(feature = "serde", serde(alias = "base-goerli"))]
238 BaseGoerli = 84531,
239 #[cfg_attr(feature = "serde", serde(alias = "base-sepolia"))]
240 BaseSepolia = 84532,
241 #[cfg_attr(feature = "serde", serde(alias = "syndr"))]
242 Syndr = 404,
243 #[cfg_attr(feature = "serde", serde(alias = "syndr-sepolia"))]
244 SyndrSepolia = 444444,
245
246 Shimmer = 148,
247
248 Ink = 57073,
249 #[cfg_attr(feature = "serde", serde(alias = "ink_sepolia_testnet", alias = "ink-sepolia"))]
250 InkSepolia = 763373,
251
252 #[strum(to_string = "fraxtal")]
253 #[cfg_attr(feature = "serde", serde(alias = "fraxtal"))]
254 Fraxtal = 252,
255 #[strum(to_string = "fraxtal-testnet")]
256 #[cfg_attr(feature = "serde", serde(alias = "fraxtal-testnet"))]
257 FraxtalTestnet = 2522,
258
259 Blast = 81457,
260 #[cfg_attr(feature = "serde", serde(alias = "blast-sepolia"))]
261 BlastSepolia = 168587773,
262
263 Linea = 59144,
264 #[cfg_attr(feature = "serde", serde(alias = "linea-goerli"))]
265 LineaGoerli = 59140,
266 #[cfg_attr(feature = "serde", serde(alias = "linea-sepolia"))]
267 LineaSepolia = 59141,
268
269 #[strum(to_string = "zksync")]
270 #[cfg_attr(feature = "serde", serde(alias = "zksync"))]
271 ZkSync = 324,
272 #[strum(to_string = "zksync-testnet")]
273 #[cfg_attr(feature = "serde", serde(alias = "zksync_testnet", alias = "zksync-testnet"))]
274 ZkSyncTestnet = 300,
275
276 #[strum(to_string = "mantle")]
277 #[cfg_attr(feature = "serde", serde(alias = "mantle"))]
278 Mantle = 5000,
279 #[strum(to_string = "mantle-testnet")]
280 #[cfg_attr(feature = "serde", serde(alias = "mantle-testnet"))]
281 MantleTestnet = 5001,
282 #[strum(to_string = "mantle-sepolia")]
283 #[cfg_attr(feature = "serde", serde(alias = "mantle-sepolia"))]
284 MantleSepolia = 5003,
285
286 #[strum(to_string = "xai")]
287 #[cfg_attr(feature = "serde", serde(alias = "xai"))]
288 Xai = 660279,
289 #[strum(to_string = "xai-sepolia")]
290 #[cfg_attr(feature = "serde", serde(alias = "xai-sepolia"))]
291 XaiSepolia = 37714555429,
292
293 #[strum(to_string = "happychain-testnet")]
294 #[cfg_attr(feature = "serde", serde(alias = "happychain-testnet"))]
295 HappychainTestnet = 216,
296
297 Viction = 88,
298
299 Zora = 7777777,
300 #[cfg_attr(feature = "serde", serde(alias = "zora-sepolia"))]
301 ZoraSepolia = 999999999,
302
303 Pgn = 424,
304 #[cfg_attr(feature = "serde", serde(alias = "pgn-sepolia"))]
305 PgnSepolia = 58008,
306
307 Mode = 34443,
308 #[cfg_attr(feature = "serde", serde(alias = "mode-sepolia"))]
309 ModeSepolia = 919,
310
311 Elastos = 20,
312
313 #[cfg_attr(
314 feature = "serde",
315 serde(alias = "kakarot-sepolia", alias = "kakarot-starknet-sepolia")
316 )]
317 KakarotSepolia = 920637907288165,
318
319 #[cfg_attr(feature = "serde", serde(alias = "etherlink"))]
320 Etherlink = 42793,
321
322 #[cfg_attr(feature = "serde", serde(alias = "etherlink-testnet"))]
323 EtherlinkTestnet = 128123,
324
325 Degen = 666666666,
326
327 #[strum(to_string = "opbnb-mainnet")]
328 #[cfg_attr(
329 feature = "serde",
330 serde(rename = "opbnb_mainnet", alias = "opbnb-mainnet", alias = "op-bnb-mainnet")
331 )]
332 OpBNBMainnet = 204,
333 #[strum(to_string = "opbnb-testnet")]
334 #[cfg_attr(
335 feature = "serde",
336 serde(rename = "opbnb_testnet", alias = "opbnb-testnet", alias = "op-bnb-testnet")
337 )]
338 OpBNBTestnet = 5611,
339
340 Ronin = 2020,
341
342 #[cfg_attr(feature = "serde", serde(alias = "ronin-testnet"))]
343 RoninTestnet = 2021,
344
345 Taiko = 167000,
346 #[cfg_attr(feature = "serde", serde(alias = "taiko-hekla"))]
347 TaikoHekla = 167009,
348
349 #[strum(to_string = "autonomys-nova-testnet")]
350 #[cfg_attr(
351 feature = "serde",
352 serde(rename = "autonomys_nova_testnet", alias = "autonomys-nova-testnet")
353 )]
354 AutonomysNovaTestnet = 490000,
355
356 Flare = 14,
357 #[cfg_attr(feature = "serde", serde(alias = "flare-coston2"))]
358 FlareCoston2 = 114,
359
360 #[strum(to_string = "acala")]
361 #[cfg_attr(feature = "serde", serde(alias = "acala"))]
362 Acala = 787,
363 #[strum(to_string = "acala-mandala-testnet")]
364 #[cfg_attr(feature = "serde", serde(alias = "acala-mandala-testnet"))]
365 AcalaMandalaTestnet = 595,
366 #[strum(to_string = "acala-testnet")]
367 #[cfg_attr(feature = "serde", serde(alias = "acala-testnet"))]
368 AcalaTestnet = 597,
369
370 #[strum(to_string = "karura")]
371 #[cfg_attr(feature = "serde", serde(alias = "karura"))]
372 Karura = 686,
373 #[strum(to_string = "karura-testnet")]
374 #[cfg_attr(feature = "serde", serde(alias = "karura-testnet"))]
375 KaruraTestnet = 596,
376 #[strum(to_string = "pulsechain")]
377 #[cfg_attr(feature = "serde", serde(alias = "pulsechain"))]
378 Pulsechain = 369,
379 #[strum(to_string = "pulsechain-testnet")]
380 #[cfg_attr(feature = "serde", serde(alias = "pulsechain-testnet"))]
381 PulsechainTestnet = 943,
382
383 #[strum(to_string = "immutable")]
384 #[cfg_attr(feature = "serde", serde(alias = "immutable"))]
385 Immutable = 13371,
386 #[strum(to_string = "immutable-testnet")]
387 #[cfg_attr(feature = "serde", serde(alias = "immutable-testnet"))]
388 ImmutableTestnet = 13473,
389
390 #[strum(to_string = "soneium")]
391 #[cfg_attr(feature = "serde", serde(alias = "soneium"))]
392 Soneium = 1868,
393
394 #[strum(to_string = "soneium-minato-testnet")]
395 #[cfg_attr(feature = "serde", serde(alias = "soneium-minato-testnet"))]
396 SoneiumMinatoTestnet = 1946,
397
398 #[cfg_attr(feature = "serde", serde(alias = "worldchain"))]
399 World = 480,
400 #[strum(to_string = "world-sepolia")]
401 #[cfg_attr(feature = "serde", serde(alias = "worldchain-sepolia", alias = "world-sepolia"))]
402 WorldSepolia = 4801,
403 Iotex = 4689,
404 Core = 1116,
405 Merlin = 4200,
406 Bitlayer = 200901,
407 Vana = 1480,
408 Zeta = 7000,
409 Kaia = 8217,
410 Story = 1514,
411 Sei = 1329,
412
413 Unichain = 130,
414 #[strum(to_string = "unichain-sepolia")]
415 #[cfg_attr(feature = "serde", serde(alias = "unichain-sepolia"))]
416 UnichainSepolia = 1301,
417
418 #[strum(to_string = "apechain")]
419 #[cfg_attr(feature = "serde", serde(alias = "apechain"))]
420 ApeChain = 33139,
421 #[strum(to_string = "curtis", serialize = "apechain-testnet")]
422 #[cfg_attr(feature = "serde", serde(alias = "apechain-testnet", alias = "curtis"))]
423 Curtis = 33111,
424
425 #[strum(to_string = "sonic-blaze")]
426 #[cfg_attr(feature = "serde", serde(alias = "sonic-blaze"))]
427 SonicBlaze = 57054,
428 #[strum(to_string = "sonic-testnet")]
429 #[cfg_attr(feature = "serde", serde(alias = "sonic-testnet"))]
430 SonicTestnet = 64165,
431 #[strum(to_string = "sonic")]
432 #[cfg_attr(feature = "serde", serde(alias = "sonic"))]
433 Sonic = 146,
434
435 #[strum(to_string = "treasure")]
436 #[cfg_attr(feature = "serde", serde(alias = "treasure"))]
437 Treasure = 61166,
438
439 #[strum(to_string = "treasure-topaz", serialize = "treasure-topaz-testnet")]
440 #[cfg_attr(
441 feature = "serde",
442 serde(alias = "treasure-topaz-testnet", alias = "treasure-topaz")
443 )]
444 TreasureTopaz = 978658,
445
446 #[strum(to_string = "berachain-bepolia", serialize = "berachain-bepolia-testnet")]
447 #[cfg_attr(
448 feature = "serde",
449 serde(alias = "berachain-bepolia-testnet", alias = "berachain-bepolia")
450 )]
451 BerachainBepolia = 80069,
452
453 Berachain = 80094,
454
455 #[strum(to_string = "superposition-testnet")]
456 #[cfg_attr(feature = "serde", serde(alias = "superposition-testnet"))]
457 SuperpositionTestnet = 98985,
458
459 #[strum(to_string = "superposition")]
460 #[cfg_attr(feature = "serde", serde(alias = "superposition"))]
461 Superposition = 55244,
462
463 #[strum(serialize = "monad-testnet")]
464 #[cfg_attr(feature = "serde", serde(alias = "monad-testnet"))]
465 MonadTestnet = 10143,
466
467 #[strum(to_string = "hyperliquid")]
468 #[cfg_attr(feature = "serde", serde(alias = "hyperliquid"))]
469 Hyperliquid = 999,
470
471 #[strum(to_string = "abstract")]
472 #[cfg_attr(feature = "serde", serde(alias = "abstract"))]
473 Abstract = 2741,
474
475 #[strum(to_string = "abstract-testnet")]
476 #[cfg_attr(feature = "serde", serde(alias = "abstract-testnet"))]
477 AbstractTestnet = 11124,
478
479 #[strum(to_string = "corn")]
480 #[cfg_attr(feature = "serde", serde(alias = "corn"))]
481 Corn = 21000000,
482
483 #[strum(to_string = "corn-testnet")]
484 #[cfg_attr(feature = "serde", serde(alias = "corn-testnet"))]
485 CornTestnet = 21000001,
486
487 #[strum(to_string = "sophon")]
488 #[cfg_attr(feature = "serde", serde(alias = "sophon"))]
489 Sophon = 50104,
490
491 #[strum(to_string = "sophon-testnet")]
492 #[cfg_attr(feature = "serde", serde(alias = "sophon-testnet"))]
493 SophonTestnet = 531050104,
494
495 #[strum(to_string = "lens")]
496 #[cfg_attr(feature = "serde", serde(alias = "lens"))]
497 Lens = 232,
498
499 #[strum(to_string = "lens-testnet")]
500 #[cfg_attr(feature = "serde", serde(alias = "lens-testnet"))]
501 LensTestnet = 37111,
502
503 #[strum(to_string = "injective-testnet")]
504 #[cfg_attr(feature = "serde", serde(alias = "injective-testnet"))]
505 InjectiveTestnet = 1439,
506
507 #[strum(to_string = "katana")]
508 #[cfg_attr(feature = "serde", serde(alias = "katana"))]
509 Katana = 747474,
510
511 #[strum(to_string = "lisk")]
512 #[cfg_attr(feature = "serde", serde(alias = "lisk"))]
513 Lisk = 1135,
514}
515
516impl Default for NamedChain {
519 #[inline]
520 fn default() -> Self {
521 Self::Mainnet
522 }
523}
524
525macro_rules! impl_into_numeric {
526 ($($t:ty)+) => {$(
527 impl From<NamedChain> for $t {
528 #[inline]
529 fn from(chain: NamedChain) -> Self {
530 chain as $t
531 }
532 }
533 )+};
534}
535
536impl_into_numeric!(u64 i64 u128 i128);
537#[cfg(target_pointer_width = "64")]
538impl_into_numeric!(usize isize);
539
540macro_rules! impl_try_from_numeric {
541 ($($native:ty)+) => {
542 $(
543 impl TryFrom<$native> for NamedChain {
544 type Error = TryFromPrimitiveError<NamedChain>;
545
546 #[inline]
547 fn try_from(value: $native) -> Result<Self, Self::Error> {
548 (value as u64).try_into()
549 }
550 }
551 )+
552 };
553}
554
555impl_try_from_numeric!(u8 i8 u16 i16 u32 i32 usize isize);
556
557impl fmt::Display for NamedChain {
558 #[inline]
559 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
560 self.as_str().fmt(f)
561 }
562}
563
564impl AsRef<str> for NamedChain {
565 #[inline]
566 fn as_ref(&self) -> &str {
567 self.as_str()
568 }
569}
570
571impl PartialEq<u64> for NamedChain {
572 #[inline]
573 fn eq(&self, other: &u64) -> bool {
574 (*self as u64) == *other
575 }
576}
577
578impl PartialOrd<u64> for NamedChain {
579 #[inline]
580 fn partial_cmp(&self, other: &u64) -> Option<Ordering> {
581 (*self as u64).partial_cmp(other)
582 }
583}
584
585#[cfg(feature = "serde")]
586impl serde::Serialize for NamedChain {
587 #[inline]
588 fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
589 s.serialize_str(self.as_ref())
590 }
591}
592
593#[cfg(feature = "rlp")]
594impl alloy_rlp::Encodable for NamedChain {
595 #[inline]
596 fn encode(&self, out: &mut dyn alloy_rlp::BufMut) {
597 (*self as u64).encode(out)
598 }
599
600 #[inline]
601 fn length(&self) -> usize {
602 (*self as u64).length()
603 }
604}
605
606#[cfg(feature = "rlp")]
607impl alloy_rlp::Decodable for NamedChain {
608 #[inline]
609 fn decode(buf: &mut &[u8]) -> alloy_rlp::Result<Self> {
610 let n = u64::decode(buf)?;
611 Self::try_from(n).map_err(|_| alloy_rlp::Error::Overflow)
612 }
613}
614
615#[cfg(feature = "arbitrary")]
616impl<'a> arbitrary::Arbitrary<'a> for NamedChain {
617 fn arbitrary(u: &mut arbitrary::Unstructured<'a>) -> arbitrary::Result<Self> {
618 use strum::{EnumCount, VariantArray};
619 let idx = u.choose_index(NamedChain::COUNT)?;
620 Ok(NamedChain::VARIANTS[idx])
621 }
622}
623
624#[allow(clippy::match_like_matches_macro)]
627#[deny(unreachable_patterns, unused_variables)]
628impl NamedChain {
629 #[inline]
631 pub fn as_str(&self) -> &'static str {
632 self.into()
633 }
634
635 pub const fn is_ethereum(&self) -> bool {
637 use NamedChain::*;
638
639 matches!(self, Mainnet | Morden | Ropsten | Rinkeby | Goerli | Kovan | Holesky | Sepolia)
640 }
641
642 pub const fn is_optimism(self) -> bool {
644 use NamedChain::*;
645
646 matches!(
647 self,
648 Optimism
649 | OptimismGoerli
650 | OptimismKovan
651 | OptimismSepolia
652 | Base
653 | BaseGoerli
654 | BaseSepolia
655 | Fraxtal
656 | FraxtalTestnet
657 | Ink
658 | InkSepolia
659 | Mode
660 | ModeSepolia
661 | Pgn
662 | PgnSepolia
663 | Zora
664 | ZoraSepolia
665 | BlastSepolia
666 | OpBNBMainnet
667 | OpBNBTestnet
668 | Soneium
669 | SoneiumMinatoTestnet
670 | Odyssey
671 | World
672 | WorldSepolia
673 | Unichain
674 | UnichainSepolia
675 | HappychainTestnet
676 | Lisk
677 )
678 }
679
680 pub const fn is_arbitrum(self) -> bool {
682 use NamedChain::*;
683
684 matches!(self, Arbitrum | ArbitrumTestnet | ArbitrumGoerli | ArbitrumSepolia | ArbitrumNova)
685 }
686
687 pub const fn is_elastic(self) -> bool {
689 use NamedChain::*;
690
691 matches!(
692 self,
693 ZkSync
694 | ZkSyncTestnet
695 | Abstract
696 | AbstractTestnet
697 | Sophon
698 | SophonTestnet
699 | Lens
700 | LensTestnet
701 )
702 }
703
704 pub const fn average_blocktime_hint(self) -> Option<Duration> {
723 use NamedChain::*;
724
725 Some(Duration::from_millis(match self {
726 Mainnet | Taiko | TaikoHekla => 12_000,
727
728 Arbitrum
729 | ArbitrumTestnet
730 | ArbitrumGoerli
731 | ArbitrumSepolia
732 | GravityAlphaMainnet
733 | GravityAlphaTestnetSepolia
734 | Xai
735 | XaiSepolia
736 | Syndr
737 | SyndrSepolia
738 | ArbitrumNova
739 | ApeChain
740 | Curtis
741 | SuperpositionTestnet
742 | Superposition => 260,
743
744 Optimism | OptimismGoerli | OptimismSepolia | Base | BaseGoerli | BaseSepolia
745 | Blast | BlastSepolia | Fraxtal | FraxtalTestnet | Zora | ZoraSepolia | Mantle
746 | MantleSepolia | Mode | ModeSepolia | Pgn | PgnSepolia | HappychainTestnet
747 | Soneium | SoneiumMinatoTestnet | Bob | BobSepolia => 2_000,
748
749 Ink | InkSepolia | Odyssey => 1_000,
750
751 Viction => 2_000,
752
753 Polygon | PolygonMumbai | PolygonAmoy => 2_100,
754
755 Acala | AcalaMandalaTestnet | AcalaTestnet | Karura | KaruraTestnet | Moonbeam
756 | Moonriver => 12_500,
757
758 BinanceSmartChain | BinanceSmartChainTestnet => 3_000,
759
760 Avalanche | AvalancheFuji => 2_000,
761
762 Fantom | FantomTestnet => 1_200,
763
764 Cronos | CronosTestnet | Canto | CantoTestnet => 5_700,
765
766 Evmos | EvmosTestnet => 1_900,
767
768 Aurora | AuroraTestnet => 1_100,
769
770 Oasis => 5_500,
771
772 Emerald | Darwinia | Crab | Koi => 6_000,
773
774 Dev | AnvilHardhat => 200,
775
776 Celo | CeloAlfajores | CeloBaklava => 5_000,
777
778 FilecoinCalibrationTestnet | FilecoinMainnet => 30_000,
779
780 Scroll | ScrollSepolia => 3_000,
781
782 Shimmer => 5_000,
783
784 Gnosis | Chiado => 5_000,
785
786 Elastos => 5_000,
787
788 Etherlink => 5_000,
789
790 EtherlinkTestnet => 5_000,
791
792 Degen => 600,
793
794 Cfx | CfxTestnet => 500,
795
796 OpBNBMainnet | OpBNBTestnet | AutonomysNovaTestnet => 1_000,
797
798 Ronin | RoninTestnet => 3_000,
799
800 Flare => 1_800,
801
802 FlareCoston2 => 2_500,
803
804 Pulsechain => 10000,
805 PulsechainTestnet => 10101,
806
807 Immutable | ImmutableTestnet => 2_000,
808
809 World | WorldSepolia => 2_000,
810
811 Iotex => 5_000,
812 Core => 3_000,
813 Merlin => 3_000,
814 Bitlayer => 3_000,
815 Vana => 6_000,
816 Zeta => 6_000,
817 Kaia => 1_000,
818 Story => 2_500,
819 Sei => 500,
820
821 Sonic => 1_000,
822
823 TelosEvm | TelosEvmTestnet => 500,
824
825 UnichainSepolia | Unichain => 1_000,
826
827 BerachainBepolia | Berachain => 2_000,
828
829 MonadTestnet => 500,
830
831 Hyperliquid => 2_000,
832
833 Abstract | AbstractTestnet => 1_000,
834 ZkSync | ZkSyncTestnet => 1_000,
835 Sophon | SophonTestnet => 1_000,
836 Lens | LensTestnet => 1_000,
837 Rsk | RskTestnet => 25_000,
838 InjectiveTestnet => 700,
839 Katana => 1_000,
840 Lisk => 2_000,
841
842 Morden | Ropsten | Rinkeby | Goerli | Kovan | Sepolia | Holesky | Hoodi
843 | MantleTestnet | Moonbase | MoonbeamDev | OptimismKovan | Poa | Sokol
844 | EmeraldTestnet | Boba | PolygonZkEvm | PolygonZkEvmTestnet | Metis | Linea
845 | LineaGoerli | LineaSepolia | KakarotSepolia | SonicBlaze | SonicTestnet
846 | Treasure | TreasureTopaz | Corn | CornTestnet => return None,
847 }))
848 }
849
850 pub const fn is_legacy(self) -> bool {
861 use NamedChain::*;
862
863 match self {
864 CeloAlfajores | CeloBaklava | Elastos | Emerald | EmeraldTestnet | Fantom
866 | FantomTestnet | MantleTestnet | OptimismKovan | PolygonZkEvm
867 | PolygonZkEvmTestnet | Ronin | RoninTestnet | Rsk | RskTestnet | Shimmer
868 | Treasure | TreasureTopaz | Viction | Sophon | SophonTestnet => true,
869
870 Mainnet
872 | Goerli
873 | Sepolia
874 | Holesky
875 | Hoodi
876 | Odyssey
877 | Acala
878 | AcalaMandalaTestnet
879 | AcalaTestnet
880 | ArbitrumTestnet
881 | Base
882 | BaseGoerli
883 | BaseSepolia
884 | Boba
885 | Metis
886 | Oasis
887 | Blast
888 | BlastSepolia
889 | Celo
890 | Fraxtal
891 | FraxtalTestnet
892 | Optimism
893 | OptimismGoerli
894 | OptimismSepolia
895 | Bob
896 | BobSepolia
897 | Polygon
898 | PolygonMumbai
899 | PolygonAmoy
900 | Avalanche
901 | AvalancheFuji
902 | Arbitrum
903 | ArbitrumGoerli
904 | ArbitrumSepolia
905 | ArbitrumNova
906 | GravityAlphaMainnet
907 | GravityAlphaTestnetSepolia
908 | Xai
909 | XaiSepolia
910 | HappychainTestnet
911 | Syndr
912 | SyndrSepolia
913 | FilecoinMainnet
914 | Linea
915 | LineaGoerli
916 | LineaSepolia
917 | FilecoinCalibrationTestnet
918 | Gnosis
919 | Chiado
920 | Zora
921 | ZoraSepolia
922 | Ink
923 | InkSepolia
924 | Mantle
925 | MantleSepolia
926 | Mode
927 | ModeSepolia
928 | Pgn
929 | PgnSepolia
930 | KakarotSepolia
931 | Etherlink
932 | EtherlinkTestnet
933 | Degen
934 | OpBNBMainnet
935 | OpBNBTestnet
936 | Taiko
937 | TaikoHekla
938 | AutonomysNovaTestnet
939 | Flare
940 | FlareCoston2
941 | Scroll
942 | ScrollSepolia
943 | Darwinia
944 | Cfx
945 | CfxTestnet
946 | Crab
947 | Pulsechain
948 | PulsechainTestnet
949 | Koi
950 | Immutable
951 | ImmutableTestnet
952 | Soneium
953 | SoneiumMinatoTestnet
954 | Sonic
955 | World
956 | WorldSepolia
957 | Unichain
958 | UnichainSepolia
959 | ApeChain
960 | BerachainBepolia
961 | Berachain
962 | Curtis
963 | SuperpositionTestnet
964 | Superposition
965 | MonadTestnet
966 | Hyperliquid
967 | Corn
968 | CornTestnet
969 | ZkSync
970 | ZkSyncTestnet
971 | AbstractTestnet
972 | Abstract
973 | Lens
974 | LensTestnet
975 | BinanceSmartChain
976 | BinanceSmartChainTestnet
977 | Karura
978 | KaruraTestnet
979 | TelosEvm
980 | TelosEvmTestnet => false,
981
982 Dev | AnvilHardhat | Morden | Ropsten | Rinkeby | Cronos | CronosTestnet | Kovan
984 | Sokol | Poa | Moonbeam | MoonbeamDev | Moonriver | Moonbase | Evmos
985 | EvmosTestnet | Aurora | AuroraTestnet | Canto | CantoTestnet | Iotex | Core
986 | Merlin | Bitlayer | SonicBlaze | SonicTestnet | Vana | Zeta | Kaia | Story | Sei
987 | InjectiveTestnet | Katana | Lisk => false,
988 }
989 }
990
991 pub const fn supports_shanghai(self) -> bool {
995 use NamedChain::*;
996
997 matches!(
998 self,
999 Mainnet
1000 | Goerli
1001 | Sepolia
1002 | Holesky
1003 | Hoodi
1004 | AnvilHardhat
1005 | Optimism
1006 | OptimismGoerli
1007 | OptimismSepolia
1008 | Bob
1009 | BobSepolia
1010 | Odyssey
1011 | Base
1012 | BaseGoerli
1013 | BaseSepolia
1014 | Blast
1015 | BlastSepolia
1016 | Fraxtal
1017 | FraxtalTestnet
1018 | Ink
1019 | InkSepolia
1020 | Gnosis
1021 | Chiado
1022 | ZoraSepolia
1023 | Mantle
1024 | MantleSepolia
1025 | Mode
1026 | ModeSepolia
1027 | PolygonMumbai
1028 | Polygon
1029 | Arbitrum
1030 | ArbitrumNova
1031 | ArbitrumSepolia
1032 | GravityAlphaMainnet
1033 | GravityAlphaTestnetSepolia
1034 | Xai
1035 | XaiSepolia
1036 | Syndr
1037 | SyndrSepolia
1038 | Etherlink
1039 | EtherlinkTestnet
1040 | Scroll
1041 | ScrollSepolia
1042 | HappychainTestnet
1043 | Shimmer
1044 | BinanceSmartChain
1045 | BinanceSmartChainTestnet
1046 | OpBNBMainnet
1047 | OpBNBTestnet
1048 | KakarotSepolia
1049 | Taiko
1050 | TaikoHekla
1051 | Avalanche
1052 | AvalancheFuji
1053 | AutonomysNovaTestnet
1054 | Acala
1055 | AcalaMandalaTestnet
1056 | AcalaTestnet
1057 | Karura
1058 | KaruraTestnet
1059 | Darwinia
1060 | Crab
1061 | Cfx
1062 | CfxTestnet
1063 | Pulsechain
1064 | PulsechainTestnet
1065 | Koi
1066 | Immutable
1067 | ImmutableTestnet
1068 | Soneium
1069 | SoneiumMinatoTestnet
1070 | World
1071 | WorldSepolia
1072 | Iotex
1073 | Unichain
1074 | UnichainSepolia
1075 | ApeChain
1076 | Curtis
1077 | SuperpositionTestnet
1078 | Superposition
1079 | MonadTestnet
1080 | Corn
1081 | CornTestnet
1082 | Rsk
1083 | RskTestnet
1084 | Berachain
1085 | BerachainBepolia
1086 | InjectiveTestnet
1087 )
1088 }
1089
1090 #[doc(hidden)]
1091 #[deprecated(since = "0.1.3", note = "use `supports_shanghai` instead")]
1092 pub const fn supports_push0(self) -> bool {
1093 self.supports_shanghai()
1094 }
1095
1096 pub const fn is_testnet(self) -> bool {
1098 use NamedChain::*;
1099
1100 match self {
1101 Goerli | Holesky | Kovan | Sepolia | Morden | Ropsten | Rinkeby | Hoodi => true,
1103
1104 ArbitrumGoerli
1106 | ArbitrumSepolia
1107 | ArbitrumTestnet
1108 | SyndrSepolia
1109 | AuroraTestnet
1110 | AvalancheFuji
1111 | Odyssey
1112 | BaseGoerli
1113 | BaseSepolia
1114 | BlastSepolia
1115 | BinanceSmartChainTestnet
1116 | CantoTestnet
1117 | CronosTestnet
1118 | CeloAlfajores
1119 | CeloBaklava
1120 | EmeraldTestnet
1121 | EvmosTestnet
1122 | FantomTestnet
1123 | FilecoinCalibrationTestnet
1124 | FraxtalTestnet
1125 | HappychainTestnet
1126 | LineaGoerli
1127 | LineaSepolia
1128 | InkSepolia
1129 | MantleTestnet
1130 | MantleSepolia
1131 | MoonbeamDev
1132 | OptimismGoerli
1133 | OptimismKovan
1134 | OptimismSepolia
1135 | BobSepolia
1136 | PolygonMumbai
1137 | PolygonAmoy
1138 | PolygonZkEvmTestnet
1139 | ScrollSepolia
1140 | Shimmer
1141 | ZkSyncTestnet
1142 | ZoraSepolia
1143 | ModeSepolia
1144 | PgnSepolia
1145 | KakarotSepolia
1146 | EtherlinkTestnet
1147 | OpBNBTestnet
1148 | RoninTestnet
1149 | TaikoHekla
1150 | AutonomysNovaTestnet
1151 | FlareCoston2
1152 | AcalaMandalaTestnet
1153 | AcalaTestnet
1154 | KaruraTestnet
1155 | CfxTestnet
1156 | PulsechainTestnet
1157 | GravityAlphaTestnetSepolia
1158 | XaiSepolia
1159 | Koi
1160 | ImmutableTestnet
1161 | SoneiumMinatoTestnet
1162 | WorldSepolia
1163 | UnichainSepolia
1164 | Curtis
1165 | TreasureTopaz
1166 | SonicBlaze
1167 | SonicTestnet
1168 | BerachainBepolia
1169 | SuperpositionTestnet
1170 | MonadTestnet
1171 | RskTestnet
1172 | TelosEvmTestnet
1173 | AbstractTestnet
1174 | LensTestnet
1175 | SophonTestnet
1176 | InjectiveTestnet
1177 | CornTestnet => true,
1178
1179 Dev | AnvilHardhat => true,
1181
1182 Mainnet | Optimism | Arbitrum | ArbitrumNova | Blast | Syndr | Cronos | Rsk
1184 | BinanceSmartChain | Poa | Sokol | Scroll | Metis | Gnosis | Polygon
1185 | PolygonZkEvm | Fantom | Moonbeam | Moonriver | Moonbase | Evmos | Chiado | Oasis
1186 | Emerald | FilecoinMainnet | Avalanche | Celo | Aurora | Canto | Boba | Base
1187 | Fraxtal | Ink | Linea | ZkSync | Mantle | GravityAlphaMainnet | Xai | Zora | Pgn
1188 | Mode | Viction | Elastos | Degen | OpBNBMainnet | Ronin | Taiko | Flare | Acala
1189 | Karura | Darwinia | Cfx | Crab | Pulsechain | Etherlink | Immutable | World
1190 | Iotex | Core | Merlin | Bitlayer | ApeChain | Vana | Zeta | Kaia | Treasure | Bob
1191 | Soneium | Sonic | Superposition | Berachain | Unichain | TelosEvm | Story | Sei
1192 | Hyperliquid | Abstract | Sophon | Lens | Corn | Katana | Lisk => false,
1193 }
1194 }
1195
1196 pub const fn native_currency_symbol(self) -> Option<&'static str> {
1198 use NamedChain::*;
1199
1200 Some(match self {
1201 Mainnet | Goerli | Holesky | Kovan | Sepolia | Morden | Ropsten | Rinkeby | Scroll
1202 | ScrollSepolia | Taiko | TaikoHekla | Unichain | UnichainSepolia
1203 | SuperpositionTestnet | Superposition | Abstract | ZkSync | ZkSyncTestnet | Katana
1204 | Lisk => "ETH",
1205
1206 Mantle | MantleSepolia => "MNT",
1207
1208 GravityAlphaMainnet | GravityAlphaTestnetSepolia => "G",
1209
1210 Xai | XaiSepolia => "XAI",
1211
1212 HappychainTestnet => "HAPPY",
1213
1214 BinanceSmartChain | BinanceSmartChainTestnet | OpBNBMainnet | OpBNBTestnet => "BNB",
1215
1216 Etherlink | EtherlinkTestnet => "XTZ",
1217
1218 Degen => "DEGEN",
1219
1220 Ronin | RoninTestnet => "RON",
1221
1222 Shimmer => "SMR",
1223
1224 Flare => "FLR",
1225
1226 FlareCoston2 => "C2FLR",
1227
1228 Darwinia => "RING",
1229
1230 Crab => "CRAB",
1231
1232 Koi => "KRING",
1233
1234 Cfx | CfxTestnet => "CFX",
1235 Pulsechain | PulsechainTestnet => "PLS",
1236
1237 Immutable => "IMX",
1238 ImmutableTestnet => "tIMX",
1239
1240 World | WorldSepolia => "WRLD",
1241
1242 Iotex => "IOTX",
1243 Core => "CORE",
1244 Merlin => "BTC",
1245 Bitlayer => "BTC",
1246 Vana => "VANA",
1247 Zeta => "ZETA",
1248 Kaia => "KAIA",
1249 Story => "IP",
1250 Sei => "SEI",
1251 ApeChain | Curtis => "APE",
1252
1253 Treasure | TreasureTopaz => "MAGIC",
1254
1255 BerachainBepolia | Berachain => "BERA",
1256
1257 Sonic | SonicBlaze => "S",
1258
1259 TelosEvm | TelosEvmTestnet => "TLOS",
1260
1261 Hyperliquid => "HYPE",
1262
1263 Polygon | PolygonMumbai | PolygonZkEvm | PolygonZkEvmTestnet | PolygonAmoy => "POL",
1264
1265 Corn | CornTestnet => "BTCN",
1266
1267 Sophon | SophonTestnet => "SOPH",
1268
1269 LensTestnet => "GRASS",
1270 Lens => "GHO",
1271
1272 Rsk => "RBTC",
1273 RskTestnet => "tRBTC",
1274
1275 InjectiveTestnet => "INJ",
1276
1277 _ => return None,
1278 })
1279 }
1280
1281 pub const fn etherscan_urls(self) -> Option<(&'static str, &'static str)> {
1303 use NamedChain::*;
1304
1305 Some(match self {
1306 Mainnet => ("https://api.etherscan.io/v2/api?chainid=1", "https://etherscan.io"),
1307 Ropsten => ("https://api-ropsten.etherscan.io/api", "https://ropsten.etherscan.io"),
1308 Kovan => ("https://api-kovan.etherscan.io/api", "https://kovan.etherscan.io"),
1309 Rinkeby => ("https://api-rinkeby.etherscan.io/api", "https://rinkeby.etherscan.io"),
1310 Goerli => ("https://api-goerli.etherscan.io/api", "https://goerli.etherscan.io"),
1311 Sepolia => {
1312 ("https://api.etherscan.io/v2/api?chainid=11155111", "https://sepolia.etherscan.io")
1313 }
1314 Holesky => {
1315 ("https://api.etherscan.io/v2/api?chainid=17000", "https://holesky.etherscan.io")
1316 }
1317 Hoodi => {
1318 ("https://api.etherscan.io/v2/api?chainid=560048", "https://hoodi.etherscan.io")
1319 }
1320
1321 Polygon => ("https://api.etherscan.io/v2/api?chainid=137", "https://polygonscan.com"),
1322 PolygonMumbai => {
1323 ("https://api-testnet.polygonscan.com/api", "https://mumbai.polygonscan.com")
1324 }
1325 PolygonAmoy => {
1326 ("https://api.etherscan.io/v2/api?chainid=80002", "https://amoy.polygonscan.com")
1327 }
1328
1329 PolygonZkEvm => {
1330 ("https://api.etherscan.io/v2/api?chainid=1101", "https://zkevm.polygonscan.com")
1331 }
1332 PolygonZkEvmTestnet => (
1333 "https://api-testnet-zkevm.polygonscan.com/api",
1334 "https://testnet-zkevm.polygonscan.com",
1335 ),
1336
1337 Avalanche => ("https://api.etherscan.io/v2/api?chainid=43114", "https://snowtrace.io"),
1338 AvalancheFuji => {
1339 ("https://api.etherscan.io/v2/api?chainid=43113", "https://testnet.snowtrace.io")
1340 }
1341
1342 Optimism => {
1343 ("https://api.etherscan.io/v2/api?chainid=10", "https://optimistic.etherscan.io")
1344 }
1345 OptimismGoerli => (
1346 "https://api-goerli-optimistic.etherscan.io/api",
1347 "https://goerli-optimism.etherscan.io",
1348 ),
1349 OptimismKovan => (
1350 "https://api-kovan-optimistic.etherscan.io/api",
1351 "https://kovan-optimistic.etherscan.io",
1352 ),
1353 OptimismSepolia => (
1354 "https://api.etherscan.io/v2/api?chainid=11155420",
1355 "https://sepolia-optimism.etherscan.io",
1356 ),
1357
1358 Bob => ("https://explorer.gobob.xyz/api", "https://explorer.gobob.xyz"),
1359 BobSepolia => (
1360 "https://bob-sepolia.explorer.gobob.xyz/api",
1361 "https://bob-sepolia.explorer.gobob.xyz",
1362 ),
1363
1364 Fantom => ("https://api.ftmscan.com/api", "https://ftmscan.com"),
1365 FantomTestnet => ("https://api-testnet.ftmscan.com/api", "https://testnet.ftmscan.com"),
1366
1367 BinanceSmartChain => {
1368 ("https://api.etherscan.io/v2/api?chainid=52", "https://bscscan.com")
1369 }
1370 BinanceSmartChainTestnet => {
1371 ("https://api.etherscan.io/v2/api?chainid=97", "https://testnet.bscscan.com")
1372 }
1373
1374 OpBNBMainnet => {
1375 ("https://api.etherscan.io/v2/api?chainid=204", "https://opbnb.bscscan.com")
1376 }
1377 OpBNBTestnet => (
1378 "https://api.etherscan.io/v2/api?chainid=5611",
1379 "https://opbnb-testnet.bscscan.com",
1380 ),
1381
1382 Arbitrum => ("https://api.etherscan.io/v2/api?chainid=42161", "https://arbiscan.io"),
1383 ArbitrumTestnet => {
1384 ("https://api-testnet.arbiscan.io/api", "https://testnet.arbiscan.io")
1385 }
1386 ArbitrumGoerli => ("https://api-goerli.arbiscan.io/api", "https://goerli.arbiscan.io"),
1387 ArbitrumSepolia => {
1388 ("https://api.etherscan.io/v2/api?chainid=421614", "https://sepolia.arbiscan.io")
1389 }
1390 ArbitrumNova => {
1391 ("https://api.etherscan.io/v2/api?chainid=42170", "https://nova.arbiscan.io")
1392 }
1393
1394 GravityAlphaMainnet => {
1395 ("https://explorer.gravity.xyz/api", "https://explorer.gravity.xyz")
1396 }
1397 GravityAlphaTestnetSepolia => {
1398 ("https://explorer-sepolia.gravity.xyz/api", "https://explorer-sepolia.gravity.xyz")
1399 }
1400 HappychainTestnet => {
1401 ("https://explorer.testnet.happy.tech/api", "https://explorer.testnet.happy.tech")
1402 }
1403
1404 XaiSepolia => (
1405 "https://api.etherscan.io/v2/api?chainid=37714555429",
1406 "https://sepolia.xaiscan.io",
1407 ),
1408 Xai => ("https://api.etherscan.io/v2/api?chainid=660279", "https://xaiscan.io"),
1409
1410 Syndr => ("https://explorer.syndr.com/api", "https://explorer.syndr.com"),
1411 SyndrSepolia => {
1412 ("https://sepolia-explorer.syndr.com/api", "https://sepolia-explorer.syndr.com")
1413 }
1414
1415 Cronos => ("https://api.etherscan.io/v2/api?chainid=25", "https://cronoscan.com"),
1416 CronosTestnet => {
1417 ("https://api-testnet.cronoscan.com/api", "https://testnet.cronoscan.com")
1418 }
1419
1420 Moonbeam => {
1421 ("https://api.etherscan.io/v2/api?chainid=1284", "https://moonbeam.moonscan.io")
1422 }
1423 Moonbase => {
1424 ("https://api.etherscan.io/v2/api?chainid=1287", "https://moonbase.moonscan.io")
1425 }
1426 Moonriver => {
1427 ("https://api.etherscan.io/v2/api?chainid=1285", "https://moonriver.moonscan.io")
1428 }
1429
1430 Gnosis => ("https://api.etherscan.io/v2/api?chainid=100", "https://gnosisscan.io"),
1431
1432 Scroll => ("https://api.etherscan.io/v2/api?chainid=534352", "https://scrollscan.com"),
1433 ScrollSepolia => {
1434 ("https://api.etherscan.io/v2/api?chainid=534351", "https://sepolia.scrollscan.com")
1435 }
1436
1437 Ink => ("https://explorer.inkonchain.com/api/v2", "https://explorer.inkonchain.com"),
1438 InkSepolia => (
1439 "https://explorer-sepolia.inkonchain.com/api/v2",
1440 "https://explorer-sepolia.inkonchain.com",
1441 ),
1442
1443 Shimmer => {
1444 ("https://explorer.evm.shimmer.network/api", "https://explorer.evm.shimmer.network")
1445 }
1446
1447 Metis => (
1448 "https://api.routescan.io/v2/network/mainnet/evm/1088/etherscan",
1449 "https://explorer.metis.io",
1450 ),
1451
1452 Chiado => {
1453 ("https://blockscout.chiadochain.net/api", "https://blockscout.chiadochain.net")
1454 }
1455
1456 FilecoinCalibrationTestnet => (
1457 "https://api.calibration.node.glif.io/rpc/v1",
1458 "https://calibration.filfox.info/en",
1459 ),
1460
1461 Sokol => ("https://blockscout.com/poa/sokol/api", "https://blockscout.com/poa/sokol"),
1462
1463 Poa => ("https://blockscout.com/poa/core/api", "https://blockscout.com/poa/core"),
1464
1465 Rsk => ("https://blockscout.com/rsk/mainnet/api", "https://blockscout.com/rsk/mainnet"),
1466 RskTestnet => (
1467 "https://rootstock-testnet.blockscout.com/api",
1468 "https://rootstock-testnet.blockscout.com",
1469 ),
1470
1471 Oasis => ("https://scan.oasischain.io/api", "https://scan.oasischain.io"),
1472
1473 Emerald => {
1474 ("https://explorer.emerald.oasis.dev/api", "https://explorer.emerald.oasis.dev")
1475 }
1476 EmeraldTestnet => (
1477 "https://testnet.explorer.emerald.oasis.dev/api",
1478 "https://testnet.explorer.emerald.oasis.dev",
1479 ),
1480
1481 Aurora => ("https://api.aurorascan.dev/api", "https://aurorascan.dev"),
1482 AuroraTestnet => {
1483 ("https://testnet.aurorascan.dev/api", "https://testnet.aurorascan.dev")
1484 }
1485
1486 Evmos => ("https://evm.evmos.org/api", "https://evm.evmos.org"),
1487 EvmosTestnet => ("https://evm.evmos.dev/api", "https://evm.evmos.dev"),
1488
1489 Celo => ("https://api.etherscan.io/v2/api?chainid=42220", "https://celoscan.io"),
1490 CeloAlfajores => {
1491 ("https://api.etherscan.io/v2/api?chainid=44787", "https://alfajores.celoscan.io")
1492 }
1493 CeloBaklava => {
1494 ("https://explorer.celo.org/baklava/api", "https://explorer.celo.org/baklava")
1495 }
1496
1497 Canto => ("https://evm.explorer.canto.io/api", "https://evm.explorer.canto.io"),
1498 CantoTestnet => (
1499 "https://testnet-explorer.canto.neobase.one/api",
1500 "https://testnet-explorer.canto.neobase.one",
1501 ),
1502
1503 Boba => ("https://api.bobascan.com/api", "https://bobascan.com"),
1504
1505 Base => ("https://api.etherscan.io/v2/api?chainid=8453", "https://basescan.org"),
1506 BaseGoerli => ("https://api-goerli.basescan.org/api", "https://goerli.basescan.org"),
1507 BaseSepolia => {
1508 ("https://api.etherscan.io/v2/api?chainid=84532", "https://sepolia.basescan.org")
1509 }
1510
1511 Fraxtal => ("https://api.etherscan.io/v2/api?chainid=252", "https://fraxscan.com"),
1512 FraxtalTestnet => {
1513 ("https://api.etherscan.io/v2/api?chainid=2522", "https://holesky.fraxscan.com")
1514 }
1515
1516 Blast => ("https://api.etherscan.io/v2/api?chainid=81457", "https://blastscan.io"),
1517 BlastSepolia => (
1518 "https://api.etherscan.io/v2/api?chainid=168587773",
1519 "https://sepolia.blastscan.io",
1520 ),
1521
1522 ZkSync => ("https://api.etherscan.io/v2/api?chainid=324", "https://era.zksync.network"),
1523 ZkSyncTestnet => (
1524 "https://api.etherscan.io/v2/api?chainid=300",
1525 "https://sepolia-era.zksync.network",
1526 ),
1527
1528 Linea => ("https://api.etherscan.io/v2/api?chainid=59144", "https://lineascan.build"),
1529 LineaGoerli => {
1530 ("https://explorer.goerli.linea.build/api", "https://explorer.goerli.linea.build")
1531 }
1532 LineaSepolia => {
1533 ("https://api.etherscan.io/v2/api?chainid=59141", "https://sepolia.lineascan.build")
1534 }
1535
1536 Mantle => {
1537 ("https://api.etherscan.io/v2/api?chainid=5000", "https://explorer.mantle.xyz")
1538 }
1539 MantleTestnet => {
1540 ("https://explorer.testnet.mantle.xyz/api", "https://explorer.testnet.mantle.xyz")
1541 }
1542 MantleSepolia => (
1543 "https://api.etherscan.io/v2/api?chainid=5003",
1544 "https://explorer.sepolia.mantle.xyz",
1545 ),
1546
1547 Viction => ("https://www.vicscan.xyz/api", "https://www.vicscan.xyz"),
1548
1549 Zora => ("https://explorer.zora.energy/api", "https://explorer.zora.energy"),
1550 ZoraSepolia => {
1551 ("https://sepolia.explorer.zora.energy/api", "https://sepolia.explorer.zora.energy")
1552 }
1553
1554 Pgn => {
1555 ("https://explorer.publicgoods.network/api", "https://explorer.publicgoods.network")
1556 }
1557
1558 PgnSepolia => (
1559 "https://explorer.sepolia.publicgoods.network/api",
1560 "https://explorer.sepolia.publicgoods.network",
1561 ),
1562
1563 Mode => ("https://explorer.mode.network/api", "https://explorer.mode.network"),
1564 ModeSepolia => (
1565 "https://sepolia.explorer.mode.network/api",
1566 "https://sepolia.explorer.mode.network",
1567 ),
1568
1569 Elastos => ("https://esc.elastos.io/api", "https://esc.elastos.io"),
1570 KakarotSepolia => {
1571 ("https://sepolia.kakarotscan.org/api", "https://sepolia.kakarotscan.org")
1572 }
1573 Etherlink => ("https://explorer.etherlink.com/api", "https://explorer.etherlink.com"),
1574 EtherlinkTestnet => (
1575 "https://testnet-explorer.etherlink.com/api",
1576 "https://testnet-explorer.etherlink.com",
1577 ),
1578 Degen => ("https://explorer.degen.tips/api", "https://explorer.degen.tips"),
1579 Ronin => ("https://skynet-api.roninchain.com/ronin", "https://app.roninchain.com"),
1580 RoninTestnet => (
1581 "https://api-gateway.skymavis.com/rpc/testnet",
1582 "https://saigon-app.roninchain.com",
1583 ),
1584 Taiko => ("https://api.etherscan.io/v2/api?chainid=167000", "https://taikoscan.io"),
1585 TaikoHekla => {
1586 ("https://api.etherscan.io/v2/api?chainid=167009", "https://hekla.taikoscan.io")
1587 }
1588 Flare => {
1589 ("https://flare-explorer.flare.network/api", "https://flare-explorer.flare.network")
1590 }
1591 FlareCoston2 => (
1592 "https://coston2-explorer.flare.network/api",
1593 "https://coston2-explorer.flare.network",
1594 ),
1595 Acala => ("https://blockscout.acala.network/api", "https://blockscout.acala.network"),
1596 AcalaMandalaTestnet => (
1597 "https://blockscout.mandala.aca-staging.network/api",
1598 "https://blockscout.mandala.aca-staging.network",
1599 ),
1600 AcalaTestnet => (
1601 "https://blockscout.acala-testnet.aca-staging.network/api",
1602 "https://blockscout.acala-testnet.aca-staging.network",
1603 ),
1604 Karura => {
1605 ("https://blockscout.karura.network/api", "https://blockscout.karura.network")
1606 }
1607 KaruraTestnet => (
1608 "https://blockscout.karura-testnet.aca-staging.network/api",
1609 "https://blockscout.karura-testnet.aca-staging.network",
1610 ),
1611
1612 Darwinia => {
1613 ("https://explorer.darwinia.network/api", "https://explorer.darwinia.network")
1614 }
1615 Crab => {
1616 ("https://crab-scan.darwinia.network/api", "https://crab-scan.darwinia.network")
1617 }
1618 Koi => ("https://koi-scan.darwinia.network/api", "https://koi-scan.darwinia.network"),
1619 Cfx => ("https://evmapi.confluxscan.net/api", "https://evm.confluxscan.io"),
1620 CfxTestnet => {
1621 ("https://evmapi-testnet.confluxscan.net/api", "https://evmtestnet.confluxscan.io")
1622 }
1623 Pulsechain => ("https://api.scan.pulsechain.com", "https://scan.pulsechain.com"),
1624 PulsechainTestnet => (
1625 "https://api.scan.v4.testnet.pulsechain.com",
1626 "https://scan.v4.testnet.pulsechain.com",
1627 ),
1628
1629 Immutable => ("https://explorer.immutable.com/api", "https://explorer.immutable.com"),
1630 ImmutableTestnet => (
1631 "https://explorer.testnet.immutable.com/api",
1632 "https://explorer.testnet.immutable.com",
1633 ),
1634 Soneium => ("https://soneium.blockscout.com/api", "https://soneium.blockscout.com"),
1635 SoneiumMinatoTestnet => (
1636 "https://soneium-minato.blockscout.com/api",
1637 "https://soneium-minato.blockscout.com",
1638 ),
1639 Odyssey => {
1640 ("https://odyssey-explorer.ithaca.xyz/api", "https://odyssey-explorer.ithaca.xyz")
1641 }
1642 World => ("https://api.etherscan.io/v2/api?chainid=480", "https://worldscan.org"),
1643 WorldSepolia => {
1644 ("https://api.etherscan.io/v2/api?chainid=4801", "https://sepolia.worldscan.org")
1645 }
1646 Unichain => ("https://api.etherscan.io/v2/api?chainid=130", "https://uniscan.xyz"),
1647 UnichainSepolia => {
1648 ("https://api.etherscan.io/v2/api?chainid=1301", "https://sepolia.uniscan.xyz")
1649 }
1650 Core => ("https://openapi.coredao.org/api", "https://scan.coredao.org"),
1651 Merlin => ("https://scan.merlinchain.io/api", "https://scan.merlinchain.io"),
1652 Bitlayer => ("https://api.btrscan.com/scan/api", "https://www.btrscan.com"),
1653 Vana => ("https://api.vanascan.io/api", "https://vanascan.io"),
1654 Zeta => ("https://zetachain.blockscout.com/api", "https://zetachain.blockscout.com"),
1655 Kaia => ("https://mainnet-oapi.kaiascan.io/api", "https://kaiascan.io"),
1656 Story => ("https://www.storyscan.xyz/api/v2", "https://www.storyscan.xyz"),
1657
1658 ApeChain => ("https://api.etherscan.io/v2/api?chainid=33139", "https://apescan.io"),
1659 Curtis => {
1660 ("https://api.etherscan.io/v2/api?chainid=33111", "https://curtis.apescan.io")
1661 }
1662 SonicBlaze => {
1663 ("https://api.etherscan.io/v2/api?chainid=57054", "https://testnet.sonicscan.org")
1664 }
1665 SonicTestnet => (
1666 "https://api.routescan.io/v2/network/testnet/evm/64165/etherscan/api",
1667 "https://scan.soniclabs.com",
1668 ),
1669 Sonic => ("https://api.etherscan.io/v2/api?chainid=146", "https://sonicscan.org"),
1670 Treasure => ("https://block-explorer.treasurescan.io/api", "https://treasurescan.io"),
1671 TreasureTopaz => (
1672 "https://block-explorer.topaz.treasurescan.io/api",
1673 "https://topaz.treasurescan.io",
1674 ),
1675 BerachainBepolia => {
1676 ("https://api.etherscan.io/v2/api?chainid=80069", "https://testnet.berascan.com")
1677 }
1678 Berachain => ("https://api.etherscan.io/v2/api?chainid=80094", "https://berascan.com"),
1679 SuperpositionTestnet => (
1680 "https://testnet-explorer.superposition.so/api",
1681 "https://testnet-explorer.superposition.so",
1682 ),
1683 Superposition => {
1684 ("https://explorer.superposition.so/api", "https://explorer.superposition.so")
1685 }
1686 MonadTestnet => {
1687 ("https://api.etherscan.io/v2/api?chainid=10143", "https://testnet.monadscan.com")
1688 }
1689 TelosEvm => ("https://api.teloscan.io/api", "https://teloscan.io"),
1690 TelosEvmTestnet => {
1691 ("https://api.testnet.teloscan.io/api", "https://testnet.teloscan.io")
1692 }
1693 Hyperliquid => {
1694 ("https://api.etherscan.io/v2/api?chainid=999", "https://hyperevmscan.io")
1695 }
1696 Abstract => ("https://api.etherscan.io/v2/api?chainid=2741", "https://abscan.org"),
1697 AbstractTestnet => {
1698 ("https://api.etherscan.io/v2/api?chainid=11124", "https://sepolia.abscan.org")
1699 }
1700 Corn => (
1701 "https://api.routescan.io/v2/network/mainnet/evm/21000000/etherscan/api",
1702 "https://cornscan.io",
1703 ),
1704 CornTestnet => (
1705 "https://api.routescan.io/v2/network/testnet/evm/21000001/etherscan/api",
1706 "https://testnet.cornscan.io",
1707 ),
1708 AnvilHardhat | Dev | Morden | MoonbeamDev | FilecoinMainnet | AutonomysNovaTestnet
1710 | Iotex | Sei | InjectiveTestnet => {
1711 return None;
1712 }
1713 Sophon => ("https://api.etherscan.io/v2/api?chainid=50104", "https://sophscan.xyz"),
1714 SophonTestnet => (
1715 "https://api.etherscan.io/v2/api?chainid=531050104",
1716 "https://testnet.sophscan.xyz",
1717 ),
1718 Lens => ("https://explorer-api.lens.xyz", "https://explorer.lens.xyz"),
1719 LensTestnet => (
1720 "https://block-explorer-api.staging.lens.zksync.dev",
1721 "https://explorer.testnet.lens.xyz",
1722 ),
1723 Katana => ("https://explorer.katanarpc.com/api", "https://explorer.katanarpc.com"),
1724 Lisk => ("https://blockscout.lisk.com/api", "https://blockscout.lisk.com"),
1725 })
1726 }
1727
1728 pub const fn etherscan_api_key_name(self) -> Option<&'static str> {
1739 use NamedChain::*;
1740
1741 let api_key_name = match self {
1742 Mainnet
1743 | Morden
1744 | Ropsten
1745 | Kovan
1746 | Rinkeby
1747 | Goerli
1748 | Holesky
1749 | Hoodi
1750 | Optimism
1751 | OptimismGoerli
1752 | OptimismKovan
1753 | OptimismSepolia
1754 | BinanceSmartChain
1755 | BinanceSmartChainTestnet
1756 | OpBNBMainnet
1757 | OpBNBTestnet
1758 | Arbitrum
1759 | ArbitrumTestnet
1760 | ArbitrumGoerli
1761 | ArbitrumSepolia
1762 | ArbitrumNova
1763 | Syndr
1764 | SyndrSepolia
1765 | Cronos
1766 | CronosTestnet
1767 | Aurora
1768 | AuroraTestnet
1769 | Celo
1770 | CeloAlfajores
1771 | Base
1772 | Linea
1773 | LineaSepolia
1774 | Mantle
1775 | MantleTestnet
1776 | MantleSepolia
1777 | Xai
1778 | XaiSepolia
1779 | BaseGoerli
1780 | BaseSepolia
1781 | Fraxtal
1782 | FraxtalTestnet
1783 | Blast
1784 | BlastSepolia
1785 | Gnosis
1786 | Scroll
1787 | ScrollSepolia
1788 | Taiko
1789 | TaikoHekla
1790 | Unichain
1791 | UnichainSepolia
1792 | MonadTestnet
1793 | ApeChain
1794 | Abstract
1795 | AbstractTestnet
1796 | ZkSyncTestnet
1797 | ZkSync
1798 | Hyperliquid
1799 | Sophon
1800 | SophonTestnet => "ETHERSCAN_API_KEY",
1801
1802 Avalanche | AvalancheFuji => "SNOWTRACE_API_KEY",
1803
1804 Polygon | PolygonMumbai | PolygonAmoy | PolygonZkEvm | PolygonZkEvmTestnet => {
1805 "POLYGONSCAN_API_KEY"
1806 }
1807
1808 Fantom | FantomTestnet => "FTMSCAN_API_KEY",
1809
1810 Moonbeam | Moonbase | MoonbeamDev | Moonriver => "MOONSCAN_API_KEY",
1811
1812 Acala | AcalaMandalaTestnet | AcalaTestnet | Canto | CantoTestnet | CeloBaklava
1813 | Etherlink | EtherlinkTestnet | Flare | FlareCoston2 | KakarotSepolia | Karura
1814 | KaruraTestnet | Mode | ModeSepolia | Pgn | PgnSepolia | Shimmer | Zora
1815 | ZoraSepolia | Darwinia | Crab | Koi | Immutable | ImmutableTestnet | Soneium
1816 | SoneiumMinatoTestnet | World | WorldSepolia | Curtis | Ink | InkSepolia
1817 | SuperpositionTestnet | Superposition | Vana | Story | Katana | Lisk => {
1818 "BLOCKSCOUT_API_KEY"
1819 }
1820
1821 Boba => "BOBASCAN_API_KEY",
1822
1823 Core => "CORESCAN_API_KEY",
1824 Merlin => "MERLINSCAN_API_KEY",
1825 Bitlayer => "BITLAYERSCAN_API_KEY",
1826 Zeta => "ZETASCAN_API_KEY",
1827 Kaia => "KAIASCAN_API_KEY",
1828 Sonic => "SONICSCAN_API_KEY",
1829 Berachain | BerachainBepolia => "BERASCAN_API_KEY",
1830 Corn | CornTestnet => "ROUTESCAN_API_KEY",
1831 Metis
1833 | Chiado
1834 | Odyssey
1835 | Sepolia
1836 | Rsk
1837 | RskTestnet
1838 | Sokol
1839 | Poa
1840 | Oasis
1841 | Emerald
1842 | EmeraldTestnet
1843 | Evmos
1844 | EvmosTestnet
1845 | AnvilHardhat
1846 | Dev
1847 | GravityAlphaMainnet
1848 | GravityAlphaTestnetSepolia
1849 | Bob
1850 | BobSepolia
1851 | FilecoinMainnet
1852 | LineaGoerli
1853 | FilecoinCalibrationTestnet
1854 | Viction
1855 | Elastos
1856 | Degen
1857 | Ronin
1858 | RoninTestnet
1859 | Cfx
1860 | CfxTestnet
1861 | Pulsechain
1862 | PulsechainTestnet
1863 | AutonomysNovaTestnet
1864 | Iotex
1865 | HappychainTestnet
1866 | SonicBlaze
1867 | SonicTestnet
1868 | Treasure
1869 | TreasureTopaz
1870 | TelosEvm
1871 | TelosEvmTestnet
1872 | Lens
1873 | LensTestnet
1874 | Sei
1875 | InjectiveTestnet => return None,
1876 };
1877
1878 Some(api_key_name)
1879 }
1880
1881 #[cfg(feature = "std")]
1896 pub fn etherscan_api_key(self) -> Option<String> {
1897 self.etherscan_api_key_name().and_then(|name| std::env::var(name).ok())
1898 }
1899
1900 pub fn public_dns_network_protocol(self) -> Option<String> {
1904 use NamedChain::*;
1905
1906 const DNS_PREFIX: &str = "enrtree://AKA3AM6LPBYEUDMVNU3BSVQJ5AD45Y7YPOHJLEF6W26QOE4VTUDPE@";
1907 if let Mainnet | Goerli | Sepolia | Ropsten | Rinkeby | Holesky | Hoodi = self {
1908 let mut s = String::with_capacity(DNS_PREFIX.len() + 32);
1910 s.push_str(DNS_PREFIX);
1911 s.push_str("all.");
1912 let chain_str = self.as_ref();
1913 s.push_str(chain_str);
1914 let l = s.len();
1915 s[l - chain_str.len()..].make_ascii_lowercase();
1916 s.push_str(".ethdisco.net");
1917
1918 Some(s)
1919 } else {
1920 None
1921 }
1922 }
1923
1924 pub const fn wrapped_native_token(self) -> Option<Address> {
1940 use NamedChain::*;
1941
1942 let addr = match self {
1943 Mainnet => address!("C02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"),
1944 Optimism => address!("4200000000000000000000000000000000000006"),
1945 BinanceSmartChain => address!("bb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c"),
1946 OpBNBMainnet => address!("4200000000000000000000000000000000000006"),
1947 Arbitrum => address!("82af49447d8a07e3bd95bd0d56f35241523fbab1"),
1948 Base => address!("4200000000000000000000000000000000000006"),
1949 Linea => address!("e5d7c2a44ffddf6b295a15c148167daaaf5cf34f"),
1950 Mantle => address!("deaddeaddeaddeaddeaddeaddeaddeaddead1111"),
1951 Blast => address!("4300000000000000000000000000000000000004"),
1952 Gnosis => address!("e91d153e0b41518a2ce8dd3d7944fa863463a97d"),
1953 Scroll => address!("5300000000000000000000000000000000000004"),
1954 Taiko => address!("a51894664a773981c6c112c43ce576f315d5b1b6"),
1955 Avalanche => address!("b31f66aa3c1e785363f0875a1b74e27b85fd66c7"),
1956 Polygon => address!("0d500b1d8e8ef31e21c99d1db9a6444d3adf1270"),
1957 Fantom => address!("21be370d5312f44cb42ce377bc9b8a0cef1a4c83"),
1958 Iotex => address!("a00744882684c3e4747faefd68d283ea44099d03"),
1959 Core => address!("40375C92d9FAf44d2f9db9Bd9ba41a3317a2404f"),
1960 Merlin => address!("F6D226f9Dc15d9bB51182815b320D3fBE324e1bA"),
1961 Bitlayer => address!("ff204e2681a6fa0e2c3fade68a1b28fb90e4fc5f"),
1962 ApeChain => address!("48b62137EdfA95a428D35C09E44256a739F6B557"),
1963 Vana => address!("00EDdD9621Fb08436d0331c149D1690909a5906d"),
1964 Zeta => address!("5F0b1a82749cb4E2278EC87F8BF6B618dC71a8bf"),
1965 Kaia => address!("19aac5f612f524b754ca7e7c41cbfa2e981a4432"),
1966 Story => address!("1514000000000000000000000000000000000000"),
1967 Treasure => address!("263d8f36bb8d0d9526255e205868c26690b04b88"),
1968 Superposition => address!("1fB719f10b56d7a85DCD32f27f897375fB21cfdd"),
1969 Sonic => address!("039e2fB66102314Ce7b64Ce5Ce3E5183bc94aD38"),
1970 Berachain => address!("6969696969696969696969696969696969696969"),
1971 Hyperliquid => address!("5555555555555555555555555555555555555555"),
1972 Abstract => address!("3439153EB7AF838Ad19d56E1571FBD09333C2809"),
1973 Sei => address!("E30feDd158A2e3b13e9badaeABaFc5516e95e8C7"),
1974 ZkSync => address!("5aea5775959fbc2557cc8789bc1bf90a239d9a91"),
1975 Sophon => address!("f1f9e08a0818594fde4713ae0db1e46672ca960e"),
1976 Rsk => address!("967f8799af07df1534d48a95a5c9febe92c53ae0"),
1977 _ => return None,
1978 };
1979
1980 Some(addr)
1981 }
1982}
1983
1984#[cfg(test)]
1985mod tests {
1986 use super::*;
1987 use strum::{EnumCount, IntoEnumIterator};
1988
1989 #[allow(unused_imports)]
1990 use alloc::string::ToString;
1991
1992 #[test]
1993 #[cfg(feature = "serde")]
1994 fn default() {
1995 assert_eq!(serde_json::to_string(&NamedChain::default()).unwrap(), "\"mainnet\"");
1996 }
1997
1998 #[test]
1999 fn enum_iter() {
2000 assert_eq!(NamedChain::COUNT, NamedChain::iter().size_hint().0);
2001 }
2002
2003 #[test]
2004 fn roundtrip_string() {
2005 for chain in NamedChain::iter() {
2006 let chain_string = chain.to_string();
2007 assert_eq!(chain_string, format!("{chain}"));
2008 assert_eq!(chain_string.as_str(), chain.as_ref());
2009 #[cfg(feature = "serde")]
2010 assert_eq!(serde_json::to_string(&chain).unwrap(), format!("\"{chain_string}\""));
2011
2012 assert_eq!(chain_string.parse::<NamedChain>().unwrap(), chain);
2013 }
2014 }
2015
2016 #[test]
2017 #[cfg(feature = "serde")]
2018 fn roundtrip_serde() {
2019 for chain in NamedChain::iter() {
2020 let chain_string = serde_json::to_string(&chain).unwrap();
2021 let chain_string = chain_string.replace('-', "_");
2022 assert_eq!(serde_json::from_str::<'_, NamedChain>(&chain_string).unwrap(), chain);
2023 }
2024 }
2025
2026 #[test]
2027 #[cfg(feature = "arbitrary")]
2028 fn test_arbitrary_named_chain() {
2029 use arbitrary::{Arbitrary, Unstructured};
2030 let data = vec![0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 255];
2031 let mut unstructured = Unstructured::new(&data);
2032
2033 for _ in 0..10 {
2034 let _chain = NamedChain::arbitrary(&mut unstructured).unwrap();
2035 }
2036 }
2037
2038 #[test]
2039 fn aliases() {
2040 use NamedChain::*;
2041
2042 const ALIASES: &[(NamedChain, &[&str])] = &[
2044 (Mainnet, &["ethlive"]),
2045 (BinanceSmartChain, &["bsc", "bnb-smart-chain", "binance-smart-chain"]),
2046 (
2047 BinanceSmartChainTestnet,
2048 &["bsc-testnet", "bnb-smart-chain-testnet", "binance-smart-chain-testnet"],
2049 ),
2050 (Gnosis, &["gnosis", "gnosis-chain"]),
2051 (PolygonMumbai, &["mumbai"]),
2052 (PolygonZkEvm, &["zkevm", "polygon-zkevm"]),
2053 (PolygonZkEvmTestnet, &["zkevm-testnet", "polygon-zkevm-testnet"]),
2054 (AnvilHardhat, &["anvil", "hardhat"]),
2055 (AvalancheFuji, &["fuji"]),
2056 (ZkSync, &["zksync"]),
2057 (ZkSyncTestnet, &["zksync-testnet"]),
2058 (Mantle, &["mantle"]),
2059 (MantleTestnet, &["mantle-testnet"]),
2060 (MantleSepolia, &["mantle-sepolia"]),
2061 (GravityAlphaMainnet, &["gravity-alpha-mainnet"]),
2062 (GravityAlphaTestnetSepolia, &["gravity-alpha-testnet-sepolia"]),
2063 (Bob, &["bob"]),
2064 (BobSepolia, &["bob-sepolia"]),
2065 (HappychainTestnet, &["happychain-testnet"]),
2066 (Xai, &["xai"]),
2067 (XaiSepolia, &["xai-sepolia"]),
2068 (Base, &["base"]),
2069 (BaseGoerli, &["base-goerli"]),
2070 (BaseSepolia, &["base-sepolia"]),
2071 (Fraxtal, &["fraxtal"]),
2072 (FraxtalTestnet, &["fraxtal-testnet"]),
2073 (Ink, &["ink"]),
2074 (InkSepolia, &["ink-sepolia"]),
2075 (BlastSepolia, &["blast-sepolia"]),
2076 (Syndr, &["syndr"]),
2077 (SyndrSepolia, &["syndr-sepolia"]),
2078 (LineaGoerli, &["linea-goerli"]),
2079 (LineaSepolia, &["linea-sepolia"]),
2080 (AutonomysNovaTestnet, &["autonomys-nova-testnet"]),
2081 (Immutable, &["immutable"]),
2082 (ImmutableTestnet, &["immutable-testnet"]),
2083 (Soneium, &["soneium"]),
2084 (SoneiumMinatoTestnet, &["soneium-minato-testnet"]),
2085 (ApeChain, &["apechain"]),
2086 (Curtis, &["apechain-testnet", "curtis"]),
2087 (Treasure, &["treasure"]),
2088 (TreasureTopaz, &["treasure-topaz-testnet", "treasure-topaz"]),
2089 (BerachainBepolia, &["berachain-bepolia-testnet", "berachain-bepolia"]),
2090 (SuperpositionTestnet, &["superposition-testnet"]),
2091 (Superposition, &["superposition"]),
2092 (Hyperliquid, &["hyperliquid"]),
2093 (Abstract, &["abstract"]),
2094 (AbstractTestnet, &["abstract-testnet"]),
2095 (Sophon, &["sophon"]),
2096 (SophonTestnet, &["sophon-testnet"]),
2097 (Lens, &["lens"]),
2098 (LensTestnet, &["lens-testnet"]),
2099 (Katana, &["katana"]),
2100 (Lisk, &["lisk"]),
2101 ];
2102
2103 for &(chain, aliases) in ALIASES {
2104 for &alias in aliases {
2105 let named = alias.parse::<NamedChain>().expect(alias);
2106 assert_eq!(named, chain);
2107
2108 #[cfg(feature = "serde")]
2109 {
2110 assert_eq!(
2111 serde_json::from_str::<NamedChain>(&format!("\"{alias}\"")).unwrap(),
2112 chain
2113 );
2114
2115 assert_eq!(
2116 serde_json::from_str::<NamedChain>(&format!("\"{named}\"")).unwrap(),
2117 chain
2118 );
2119 }
2120 }
2121 }
2122 }
2123
2124 #[test]
2125 #[cfg(feature = "serde")]
2126 fn serde_to_string_match() {
2127 for chain in NamedChain::iter() {
2128 let chain_serde = serde_json::to_string(&chain).unwrap();
2129 let chain_string = format!("\"{chain}\"");
2130 assert_eq!(chain_serde, chain_string);
2131 }
2132 }
2133
2134 #[test]
2135 fn test_dns_network() {
2136 let s = "enrtree://AKA3AM6LPBYEUDMVNU3BSVQJ5AD45Y7YPOHJLEF6W26QOE4VTUDPE@all.mainnet.ethdisco.net";
2137 assert_eq!(NamedChain::Mainnet.public_dns_network_protocol().unwrap(), s);
2138 }
2139
2140 #[test]
2141 fn ensure_no_trailing_etherscan_url_separator() {
2142 for chain in NamedChain::iter() {
2143 if let Some((api, base)) = chain.etherscan_urls() {
2144 assert!(!api.ends_with('/'), "{chain:?} api url has trailing /");
2145 assert!(!base.ends_with('/'), "{chain:?} base url has trailing /");
2146 }
2147 }
2148 }
2149}