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#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
28#[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))]
36#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
37#[strum(serialize_all = "kebab-case")]
38#[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))]
39#[repr(u64)]
40#[allow(missing_docs)]
41#[non_exhaustive]
42pub enum NamedChain {
43 #[strum(to_string = "mainnet", serialize = "ethlive")]
44 #[cfg_attr(feature = "serde", serde(alias = "ethlive"))]
45 Mainnet = 1,
46 Morden = 2,
47 Ropsten = 3,
48 Rinkeby = 4,
49 Goerli = 5,
50 Kovan = 42,
51 Holesky = 17000,
52 Hoodi = 560048,
53 Sepolia = 11155111,
54
55 #[cfg_attr(feature = "serde", serde(alias = "odyssey"))]
56 Odyssey = 911867,
57
58 Optimism = 10,
59 #[cfg_attr(feature = "serde", serde(alias = "optimism-kovan"))]
60 OptimismKovan = 69,
61 #[cfg_attr(feature = "serde", serde(alias = "optimism-goerli"))]
62 OptimismGoerli = 420,
63 #[cfg_attr(feature = "serde", serde(alias = "optimism-sepolia"))]
64 OptimismSepolia = 11155420,
65
66 #[strum(to_string = "bob")]
67 #[cfg_attr(feature = "serde", serde(alias = "bob"))]
68 Bob = 60808,
69 #[strum(to_string = "bob-sepolia")]
70 #[cfg_attr(feature = "serde", serde(alias = "bob-sepolia"))]
71 BobSepolia = 808813,
72
73 #[cfg_attr(feature = "serde", serde(alias = "arbitrum_one", alias = "arbitrum-one"))]
74 Arbitrum = 42161,
75 ArbitrumTestnet = 421611,
76 #[cfg_attr(feature = "serde", serde(alias = "arbitrum-goerli"))]
77 ArbitrumGoerli = 421613,
78 #[cfg_attr(feature = "serde", serde(alias = "arbitrum-sepolia"))]
79 ArbitrumSepolia = 421614,
80 #[cfg_attr(feature = "serde", serde(alias = "arbitrum-nova"))]
81 ArbitrumNova = 42170,
82
83 Cronos = 25,
84 CronosTestnet = 338,
85
86 Rsk = 30,
87
88 #[strum(to_string = "telos")]
89 #[cfg_attr(feature = "serde", serde(alias = "telos", alias = "telos_evm"))]
90 TelosEvm = 40,
91 #[strum(to_string = "telos-testnet")]
92 #[cfg_attr(
93 feature = "serde",
94 serde(alias = "telos_testnet", alias = "telos-evm-testnet", alias = "telos_evm_testnet")
95 )]
96 TelosEvmTestnet = 41,
97
98 #[strum(to_string = "crab")]
99 #[cfg_attr(feature = "serde", serde(alias = "crab"))]
100 Crab = 44,
101 #[strum(to_string = "darwinia")]
102 #[cfg_attr(feature = "serde", serde(alias = "darwinia"))]
103 Darwinia = 46,
104 #[strum(to_string = "koi")]
105 #[cfg_attr(feature = "serde", serde(alias = "koi"))]
106 Koi = 701,
107
108 #[strum(to_string = "bsc", serialize = "binance-smart-chain", serialize = "bnb-smart-chain")]
112 #[cfg_attr(
113 feature = "serde",
114 serde(alias = "bsc", alias = "bnb-smart-chain", alias = "binance-smart-chain")
115 )]
116 BinanceSmartChain = 56,
117 #[strum(
118 to_string = "bsc-testnet",
119 serialize = "binance-smart-chain-testnet",
120 serialize = "bnb-smart-chain-testnet"
121 )]
122 #[cfg_attr(
123 feature = "serde",
124 serde(
125 alias = "bsc_testnet",
126 alias = "bsc-testnet",
127 alias = "bnb-smart-chain-testnet",
128 alias = "binance-smart-chain-testnet"
129 )
130 )]
131 BinanceSmartChainTestnet = 97,
132
133 Poa = 99,
134 Sokol = 77,
135
136 Scroll = 534352,
137 #[cfg_attr(
138 feature = "serde",
139 serde(alias = "scroll_sepolia_testnet", alias = "scroll-sepolia")
140 )]
141 ScrollSepolia = 534351,
142
143 Metis = 1088,
144
145 #[cfg_attr(feature = "serde", serde(alias = "conflux-espace-testnet"))]
146 CfxTestnet = 71,
147 #[cfg_attr(feature = "serde", serde(alias = "conflux-espace"))]
148 Cfx = 1030,
149
150 #[strum(to_string = "xdai", serialize = "gnosis", serialize = "gnosis-chain")]
151 #[cfg_attr(feature = "serde", serde(alias = "xdai", alias = "gnosis", alias = "gnosis-chain"))]
152 Gnosis = 100,
153
154 Polygon = 137,
155 #[strum(to_string = "mumbai", serialize = "polygon-mumbai")]
156 #[cfg_attr(feature = "serde", serde(alias = "mumbai", alias = "polygon-mumbai"))]
157 PolygonMumbai = 80001,
158 #[strum(to_string = "amoy", serialize = "polygon-amoy")]
159 #[cfg_attr(feature = "serde", serde(alias = "amoy", alias = "polygon-amoy"))]
160 PolygonAmoy = 80002,
161 #[strum(serialize = "polygon-zkevm", serialize = "zkevm")]
162 #[cfg_attr(
163 feature = "serde",
164 serde(alias = "zkevm", alias = "polygon_zkevm", alias = "polygon-zkevm")
165 )]
166 PolygonZkEvm = 1101,
167 #[strum(serialize = "polygon-zkevm-testnet", serialize = "zkevm-testnet")]
168 #[cfg_attr(
169 feature = "serde",
170 serde(
171 alias = "zkevm-testnet",
172 alias = "polygon_zkevm_testnet",
173 alias = "polygon-zkevm-testnet"
174 )
175 )]
176 PolygonZkEvmTestnet = 1442,
177
178 Fantom = 250,
179 FantomTestnet = 4002,
180
181 Moonbeam = 1284,
182 MoonbeamDev = 1281,
183
184 Moonriver = 1285,
185
186 Moonbase = 1287,
187
188 Dev = 1337,
189 #[strum(to_string = "anvil-hardhat", serialize = "anvil", serialize = "hardhat")]
190 #[cfg_attr(
191 feature = "serde",
192 serde(alias = "anvil", alias = "hardhat", alias = "anvil-hardhat")
193 )]
194 AnvilHardhat = 31337,
195
196 #[strum(to_string = "gravity-alpha-mainnet")]
197 #[cfg_attr(feature = "serde", serde(alias = "gravity-alpha-mainnet"))]
198 GravityAlphaMainnet = 1625,
199 #[strum(to_string = "gravity-alpha-testnet-sepolia")]
200 #[cfg_attr(feature = "serde", serde(alias = "gravity-alpha-testnet-sepolia"))]
201 GravityAlphaTestnetSepolia = 13505,
202
203 Evmos = 9001,
204 EvmosTestnet = 9000,
205
206 Chiado = 10200,
207
208 Oasis = 26863,
209
210 Emerald = 42262,
211 EmeraldTestnet = 42261,
212
213 FilecoinMainnet = 314,
214 FilecoinCalibrationTestnet = 314159,
215
216 Avalanche = 43114,
217 #[strum(to_string = "fuji", serialize = "avalanche-fuji")]
218 #[cfg_attr(feature = "serde", serde(alias = "fuji"))]
219 AvalancheFuji = 43113,
220
221 Celo = 42220,
222 CeloAlfajores = 44787,
223 CeloBaklava = 62320,
224
225 Aurora = 1313161554,
226 AuroraTestnet = 1313161555,
227
228 Canto = 7700,
229 CantoTestnet = 740,
230
231 Boba = 288,
232
233 Base = 8453,
234 #[cfg_attr(feature = "serde", serde(alias = "base-goerli"))]
235 BaseGoerli = 84531,
236 #[cfg_attr(feature = "serde", serde(alias = "base-sepolia"))]
237 BaseSepolia = 84532,
238 #[cfg_attr(feature = "serde", serde(alias = "syndr"))]
239 Syndr = 404,
240 #[cfg_attr(feature = "serde", serde(alias = "syndr-sepolia"))]
241 SyndrSepolia = 444444,
242
243 Shimmer = 148,
244
245 Ink = 57073,
246 #[cfg_attr(feature = "serde", serde(alias = "ink_sepolia_testnet", alias = "ink-sepolia"))]
247 InkSepolia = 763373,
248
249 #[strum(to_string = "fraxtal")]
250 #[cfg_attr(feature = "serde", serde(alias = "fraxtal"))]
251 Fraxtal = 252,
252 #[strum(to_string = "fraxtal-testnet")]
253 #[cfg_attr(feature = "serde", serde(alias = "fraxtal-testnet"))]
254 FraxtalTestnet = 2522,
255
256 Blast = 81457,
257 #[cfg_attr(feature = "serde", serde(alias = "blast-sepolia"))]
258 BlastSepolia = 168587773,
259
260 Linea = 59144,
261 #[cfg_attr(feature = "serde", serde(alias = "linea-goerli"))]
262 LineaGoerli = 59140,
263 #[cfg_attr(feature = "serde", serde(alias = "linea-sepolia"))]
264 LineaSepolia = 59141,
265
266 #[strum(to_string = "zksync")]
267 #[cfg_attr(feature = "serde", serde(alias = "zksync"))]
268 ZkSync = 324,
269 #[strum(to_string = "zksync-testnet")]
270 #[cfg_attr(feature = "serde", serde(alias = "zksync_testnet", alias = "zksync-testnet"))]
271 ZkSyncTestnet = 300,
272
273 #[strum(to_string = "mantle")]
274 #[cfg_attr(feature = "serde", serde(alias = "mantle"))]
275 Mantle = 5000,
276 #[strum(to_string = "mantle-testnet")]
277 #[cfg_attr(feature = "serde", serde(alias = "mantle-testnet"))]
278 MantleTestnet = 5001,
279 #[strum(to_string = "mantle-sepolia")]
280 #[cfg_attr(feature = "serde", serde(alias = "mantle-sepolia"))]
281 MantleSepolia = 5003,
282
283 #[strum(to_string = "xai")]
284 #[cfg_attr(feature = "serde", serde(alias = "xai"))]
285 Xai = 660279,
286 #[strum(to_string = "xai-sepolia")]
287 #[cfg_attr(feature = "serde", serde(alias = "xai-sepolia"))]
288 XaiSepolia = 37714555429,
289
290 #[strum(to_string = "happychain-testnet")]
291 #[cfg_attr(feature = "serde", serde(alias = "happychain-testnet"))]
292 HappychainTestnet = 216,
293
294 Viction = 88,
295
296 Zora = 7777777,
297 #[cfg_attr(feature = "serde", serde(alias = "zora-sepolia"))]
298 ZoraSepolia = 999999999,
299
300 Pgn = 424,
301 #[cfg_attr(feature = "serde", serde(alias = "pgn-sepolia"))]
302 PgnSepolia = 58008,
303
304 Mode = 34443,
305 #[cfg_attr(feature = "serde", serde(alias = "mode-sepolia"))]
306 ModeSepolia = 919,
307
308 Elastos = 20,
309
310 #[cfg_attr(
311 feature = "serde",
312 serde(alias = "kakarot-sepolia", alias = "kakarot-starknet-sepolia")
313 )]
314 KakarotSepolia = 920637907288165,
315
316 #[cfg_attr(feature = "serde", serde(alias = "etherlink"))]
317 Etherlink = 42793,
318
319 #[cfg_attr(feature = "serde", serde(alias = "etherlink-testnet"))]
320 EtherlinkTestnet = 128123,
321
322 Degen = 666666666,
323
324 #[strum(to_string = "opbnb-mainnet")]
325 #[cfg_attr(
326 feature = "serde",
327 serde(rename = "opbnb_mainnet", alias = "opbnb-mainnet", alias = "op-bnb-mainnet")
328 )]
329 OpBNBMainnet = 204,
330 #[strum(to_string = "opbnb-testnet")]
331 #[cfg_attr(
332 feature = "serde",
333 serde(rename = "opbnb_testnet", alias = "opbnb-testnet", alias = "op-bnb-testnet")
334 )]
335 OpBNBTestnet = 5611,
336
337 Ronin = 2020,
338
339 #[cfg_attr(feature = "serde", serde(alias = "ronin-testnet"))]
340 RoninTestnet = 2021,
341
342 Taiko = 167000,
343 #[cfg_attr(feature = "serde", serde(alias = "taiko-hekla"))]
344 TaikoHekla = 167009,
345
346 #[strum(to_string = "autonomys-nova-testnet")]
347 #[cfg_attr(
348 feature = "serde",
349 serde(rename = "autonomys_nova_testnet", alias = "autonomys-nova-testnet")
350 )]
351 AutonomysNovaTestnet = 490000,
352
353 Flare = 14,
354 #[cfg_attr(feature = "serde", serde(alias = "flare-coston2"))]
355 FlareCoston2 = 114,
356
357 #[strum(to_string = "acala")]
358 #[cfg_attr(feature = "serde", serde(alias = "acala"))]
359 Acala = 787,
360 #[strum(to_string = "acala-mandala-testnet")]
361 #[cfg_attr(feature = "serde", serde(alias = "acala-mandala-testnet"))]
362 AcalaMandalaTestnet = 595,
363 #[strum(to_string = "acala-testnet")]
364 #[cfg_attr(feature = "serde", serde(alias = "acala-testnet"))]
365 AcalaTestnet = 597,
366
367 #[strum(to_string = "karura")]
368 #[cfg_attr(feature = "serde", serde(alias = "karura"))]
369 Karura = 686,
370 #[strum(to_string = "karura-testnet")]
371 #[cfg_attr(feature = "serde", serde(alias = "karura-testnet"))]
372 KaruraTestnet = 596,
373 #[strum(to_string = "pulsechain")]
374 #[cfg_attr(feature = "serde", serde(alias = "pulsechain"))]
375 Pulsechain = 369,
376 #[strum(to_string = "pulsechain-testnet")]
377 #[cfg_attr(feature = "serde", serde(alias = "pulsechain-testnet"))]
378 PulsechainTestnet = 943,
379
380 #[strum(to_string = "immutable")]
381 #[cfg_attr(feature = "serde", serde(alias = "immutable"))]
382 Immutable = 13371,
383 #[strum(to_string = "immutable-testnet")]
384 #[cfg_attr(feature = "serde", serde(alias = "immutable-testnet"))]
385 ImmutableTestnet = 13473,
386
387 #[strum(to_string = "soneium")]
388 #[cfg_attr(feature = "serde", serde(alias = "soneium"))]
389 Soneium = 1868,
390
391 #[strum(to_string = "soneium-minato-testnet")]
392 #[cfg_attr(feature = "serde", serde(alias = "soneium-minato-testnet"))]
393 SoneiumMinatoTestnet = 1946,
394
395 #[cfg_attr(feature = "serde", serde(alias = "worldchain"))]
396 World = 480,
397 #[strum(to_string = "world-sepolia")]
398 #[cfg_attr(feature = "serde", serde(alias = "worldchain-sepolia", alias = "world-sepolia"))]
399 WorldSepolia = 4801,
400 Iotex = 4689,
401 Core = 1116,
402 Merlin = 4200,
403 Bitlayer = 200901,
404 Vana = 1480,
405 Zeta = 7000,
406 Kaia = 8217,
407 Story = 1514,
408
409 Unichain = 130,
410 #[strum(to_string = "unichain-sepolia")]
411 #[cfg_attr(feature = "serde", serde(alias = "unichain-sepolia"))]
412 UnichainSepolia = 1301,
413
414 #[strum(to_string = "apechain")]
415 #[cfg_attr(feature = "serde", serde(alias = "apechain"))]
416 ApeChain = 33139,
417 #[strum(to_string = "curtis", serialize = "apechain-testnet")]
418 #[cfg_attr(feature = "serde", serde(alias = "apechain-testnet", alias = "curtis"))]
419 Curtis = 33111,
420
421 #[strum(to_string = "sonic-testnet")]
422 #[cfg_attr(feature = "serde", serde(alias = "sonic-testnet"))]
423 SonicTestnet = 64165,
424 #[strum(to_string = "sonic")]
425 #[cfg_attr(feature = "serde", serde(alias = "sonic"))]
426 Sonic = 146,
427
428 #[strum(to_string = "treasure")]
429 #[cfg_attr(feature = "serde", serde(alias = "treasure"))]
430 Treasure = 61166,
431
432 #[strum(to_string = "treasure-topaz", serialize = "treasure-topaz-testnet")]
433 #[cfg_attr(
434 feature = "serde",
435 serde(alias = "treasure-topaz-testnet", alias = "treasure-topaz")
436 )]
437 TreasureTopaz = 978658,
438
439 #[strum(to_string = "berachain-bartio", serialize = "berachain-bartio-testnet")]
440 #[cfg_attr(
441 feature = "serde",
442 serde(alias = "berachain-bartio-testnet", alias = "berachain-bartio")
443 )]
444 BerachainBartio = 80084,
445
446 #[strum(to_string = "berachain-artio", serialize = "berachain-artio-testnet")]
447 #[cfg_attr(
448 feature = "serde",
449 serde(alias = "berachain-artio-testnet", alias = "berachain-artio")
450 )]
451 BerachainArtio = 80085,
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
476impl Default for NamedChain {
479 #[inline]
480 fn default() -> Self {
481 Self::Mainnet
482 }
483}
484
485macro_rules! impl_into_numeric {
486 ($($t:ty)+) => {$(
487 impl From<NamedChain> for $t {
488 #[inline]
489 fn from(chain: NamedChain) -> Self {
490 chain as $t
491 }
492 }
493 )+};
494}
495
496impl_into_numeric!(u64 i64 u128 i128);
497#[cfg(target_pointer_width = "64")]
498impl_into_numeric!(usize isize);
499
500macro_rules! impl_try_from_numeric {
501 ($($native:ty)+) => {
502 $(
503 impl TryFrom<$native> for NamedChain {
504 type Error = TryFromPrimitiveError<NamedChain>;
505
506 #[inline]
507 fn try_from(value: $native) -> Result<Self, Self::Error> {
508 (value as u64).try_into()
509 }
510 }
511 )+
512 };
513}
514
515impl_try_from_numeric!(u8 i8 u16 i16 u32 i32 usize isize);
516
517impl fmt::Display for NamedChain {
518 #[inline]
519 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
520 self.as_str().fmt(f)
521 }
522}
523
524impl AsRef<str> for NamedChain {
525 #[inline]
526 fn as_ref(&self) -> &str {
527 self.as_str()
528 }
529}
530
531impl PartialEq<u64> for NamedChain {
532 #[inline]
533 fn eq(&self, other: &u64) -> bool {
534 (*self as u64) == *other
535 }
536}
537
538impl PartialOrd<u64> for NamedChain {
539 #[inline]
540 fn partial_cmp(&self, other: &u64) -> Option<Ordering> {
541 (*self as u64).partial_cmp(other)
542 }
543}
544
545#[cfg(feature = "serde")]
546impl serde::Serialize for NamedChain {
547 #[inline]
548 fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
549 s.serialize_str(self.as_ref())
550 }
551}
552
553#[cfg(feature = "rlp")]
554impl alloy_rlp::Encodable for NamedChain {
555 #[inline]
556 fn encode(&self, out: &mut dyn alloy_rlp::BufMut) {
557 (*self as u64).encode(out)
558 }
559
560 #[inline]
561 fn length(&self) -> usize {
562 (*self as u64).length()
563 }
564}
565
566#[cfg(feature = "rlp")]
567impl alloy_rlp::Decodable for NamedChain {
568 #[inline]
569 fn decode(buf: &mut &[u8]) -> alloy_rlp::Result<Self> {
570 let n = u64::decode(buf)?;
571 Self::try_from(n).map_err(|_| alloy_rlp::Error::Overflow)
572 }
573}
574
575#[allow(clippy::match_like_matches_macro)]
578#[deny(unreachable_patterns, unused_variables)]
579impl NamedChain {
580 #[inline]
582 pub fn as_str(&self) -> &'static str {
583 self.into()
584 }
585
586 pub const fn is_ethereum(&self) -> bool {
588 use NamedChain::*;
589
590 matches!(self, Mainnet | Morden | Ropsten | Rinkeby | Goerli | Kovan | Holesky | Sepolia)
591 }
592
593 pub const fn is_optimism(self) -> bool {
595 use NamedChain::*;
596
597 matches!(
598 self,
599 Optimism
600 | OptimismGoerli
601 | OptimismKovan
602 | OptimismSepolia
603 | Base
604 | BaseGoerli
605 | BaseSepolia
606 | Fraxtal
607 | FraxtalTestnet
608 | Ink
609 | InkSepolia
610 | Mode
611 | ModeSepolia
612 | Pgn
613 | PgnSepolia
614 | Zora
615 | ZoraSepolia
616 | BlastSepolia
617 | OpBNBMainnet
618 | OpBNBTestnet
619 | Soneium
620 | SoneiumMinatoTestnet
621 | Odyssey
622 | World
623 | WorldSepolia
624 | Unichain
625 | UnichainSepolia
626 | HappychainTestnet
627 )
628 }
629
630 pub const fn is_arbitrum(self) -> bool {
632 use NamedChain::*;
633
634 matches!(self, Arbitrum | ArbitrumTestnet | ArbitrumGoerli | ArbitrumSepolia | ArbitrumNova)
635 }
636
637 pub const fn average_blocktime_hint(self) -> Option<Duration> {
656 use NamedChain::*;
657
658 Some(Duration::from_millis(match self {
659 Mainnet | Taiko | TaikoHekla => 12_000,
660
661 Arbitrum
662 | ArbitrumTestnet
663 | ArbitrumGoerli
664 | ArbitrumSepolia
665 | GravityAlphaMainnet
666 | GravityAlphaTestnetSepolia
667 | Xai
668 | XaiSepolia
669 | Syndr
670 | SyndrSepolia
671 | ArbitrumNova
672 | ApeChain
673 | Curtis
674 | SuperpositionTestnet
675 | Superposition => 260,
676
677 Optimism | OptimismGoerli | OptimismSepolia | Base | BaseGoerli | BaseSepolia
678 | Blast | BlastSepolia | Fraxtal | FraxtalTestnet | Zora | ZoraSepolia | Mantle
679 | MantleSepolia | Mode | ModeSepolia | Pgn | PgnSepolia | HappychainTestnet
680 | Soneium | SoneiumMinatoTestnet | Bob | BobSepolia => 2_000,
681
682 Ink | InkSepolia | Odyssey => 1_000,
683
684 Viction => 2_000,
685
686 Polygon | PolygonMumbai | PolygonAmoy => 2_100,
687
688 Acala | AcalaMandalaTestnet | AcalaTestnet | Karura | KaruraTestnet | Moonbeam
689 | Moonriver => 12_500,
690
691 BinanceSmartChain | BinanceSmartChainTestnet => 3_000,
692
693 Avalanche | AvalancheFuji => 2_000,
694
695 Fantom | FantomTestnet => 1_200,
696
697 Cronos | CronosTestnet | Canto | CantoTestnet => 5_700,
698
699 Evmos | EvmosTestnet => 1_900,
700
701 Aurora | AuroraTestnet => 1_100,
702
703 Oasis => 5_500,
704
705 Emerald | Darwinia | Crab | Koi => 6_000,
706
707 Dev | AnvilHardhat => 200,
708
709 Celo | CeloAlfajores | CeloBaklava => 5_000,
710
711 FilecoinCalibrationTestnet | FilecoinMainnet => 30_000,
712
713 Scroll | ScrollSepolia => 3_000,
714
715 Shimmer => 5_000,
716
717 Gnosis | Chiado => 5_000,
718
719 Elastos => 5_000,
720
721 Etherlink => 5_000,
722
723 EtherlinkTestnet => 5_000,
724
725 Degen => 600,
726
727 Cfx | CfxTestnet => 500,
728
729 OpBNBMainnet | OpBNBTestnet | AutonomysNovaTestnet => 1_000,
730
731 Ronin | RoninTestnet => 3_000,
732
733 Flare => 1_800,
734
735 FlareCoston2 => 2_500,
736
737 Pulsechain => 10000,
738 PulsechainTestnet => 10101,
739
740 Immutable | ImmutableTestnet => 2_000,
741
742 World | WorldSepolia => 2_000,
743
744 Iotex => 5_000,
745 Core => 3_000,
746 Merlin => 3_000,
747 Bitlayer => 3_000,
748 Vana => 6_000,
749 Zeta => 6_000,
750 Kaia => 1_000,
751 Story => 2_500,
752
753 Sonic => 1_000,
754
755 TelosEvm | TelosEvmTestnet => 500,
756
757 UnichainSepolia | Unichain => 1_000,
758
759 BerachainBartio | BerachainArtio | Berachain => 2_000,
760
761 MonadTestnet => 500,
762
763 Hyperliquid => 2_000,
764
765 Abstract => 1_000,
766
767 Morden | Ropsten | Rinkeby | Goerli | Kovan | Sepolia | Holesky | Hoodi
768 | MantleTestnet | Moonbase | MoonbeamDev | OptimismKovan | Poa | Sokol | Rsk
769 | EmeraldTestnet | Boba | ZkSync | ZkSyncTestnet | PolygonZkEvm
770 | PolygonZkEvmTestnet | Metis | Linea | LineaGoerli | LineaSepolia | KakarotSepolia
771 | SonicTestnet | Treasure | TreasureTopaz => return None,
772 }))
773 }
774
775 pub const fn is_legacy(self) -> bool {
786 use NamedChain::*;
787
788 match self {
789 Acala
791 | AcalaMandalaTestnet
792 | AcalaTestnet
793 | ArbitrumTestnet
794 | BinanceSmartChain
795 | BinanceSmartChainTestnet
796 | Boba
797 | Celo
798 | CeloAlfajores
799 | CeloBaklava
800 | Elastos
801 | Emerald
802 | EmeraldTestnet
803 | Fantom
804 | FantomTestnet
805 | Karura
806 | KaruraTestnet
807 | MantleTestnet
808 | Metis
809 | Oasis
810 | OptimismKovan
811 | PolygonZkEvm
812 | PolygonZkEvmTestnet
813 | Ronin
814 | RoninTestnet
815 | Rsk
816 | Shimmer
817 | TelosEvm
818 | TelosEvmTestnet
819 | Treasure
820 | TreasureTopaz
821 | Viction
822 | ZkSync
823 | ZkSyncTestnet => true,
824
825 Mainnet
827 | Goerli
828 | Sepolia
829 | Holesky
830 | Hoodi
831 | Odyssey
832 | Base
833 | BaseGoerli
834 | BaseSepolia
835 | Blast
836 | BlastSepolia
837 | Fraxtal
838 | FraxtalTestnet
839 | Optimism
840 | OptimismGoerli
841 | OptimismSepolia
842 | Bob
843 | BobSepolia
844 | Polygon
845 | PolygonMumbai
846 | PolygonAmoy
847 | Avalanche
848 | AvalancheFuji
849 | Arbitrum
850 | ArbitrumGoerli
851 | ArbitrumSepolia
852 | ArbitrumNova
853 | GravityAlphaMainnet
854 | GravityAlphaTestnetSepolia
855 | Xai
856 | XaiSepolia
857 | HappychainTestnet
858 | Syndr
859 | SyndrSepolia
860 | FilecoinMainnet
861 | Linea
862 | LineaGoerli
863 | LineaSepolia
864 | FilecoinCalibrationTestnet
865 | Gnosis
866 | Chiado
867 | Zora
868 | ZoraSepolia
869 | Ink
870 | InkSepolia
871 | Mantle
872 | MantleSepolia
873 | Mode
874 | ModeSepolia
875 | Pgn
876 | PgnSepolia
877 | KakarotSepolia
878 | Etherlink
879 | EtherlinkTestnet
880 | Degen
881 | OpBNBMainnet
882 | OpBNBTestnet
883 | Taiko
884 | TaikoHekla
885 | AutonomysNovaTestnet
886 | Flare
887 | FlareCoston2
888 | Scroll
889 | ScrollSepolia
890 | Darwinia
891 | Cfx
892 | CfxTestnet
893 | Crab
894 | Pulsechain
895 | PulsechainTestnet
896 | Koi
897 | Immutable
898 | ImmutableTestnet
899 | Soneium
900 | SoneiumMinatoTestnet
901 | Sonic
902 | World
903 | WorldSepolia
904 | Unichain
905 | UnichainSepolia
906 | ApeChain
907 | BerachainBartio
908 | BerachainArtio
909 | Berachain
910 | Curtis
911 | SuperpositionTestnet
912 | Superposition
913 | MonadTestnet
914 | Hyperliquid
915 | Abstract => false,
916
917 Dev | AnvilHardhat | Morden | Ropsten | Rinkeby | Cronos | CronosTestnet | Kovan
919 | Sokol | Poa | Moonbeam | MoonbeamDev | Moonriver | Moonbase | Evmos
920 | EvmosTestnet | Aurora | AuroraTestnet | Canto | CantoTestnet | Iotex | Core
921 | Merlin | Bitlayer | SonicTestnet | Vana | Zeta | Kaia | Story => false,
922 }
923 }
924
925 pub const fn supports_shanghai(self) -> bool {
929 use NamedChain::*;
930
931 matches!(
932 self,
933 Mainnet
934 | Goerli
935 | Sepolia
936 | Holesky
937 | Hoodi
938 | AnvilHardhat
939 | Optimism
940 | OptimismGoerli
941 | OptimismSepolia
942 | Bob
943 | BobSepolia
944 | Odyssey
945 | Base
946 | BaseGoerli
947 | BaseSepolia
948 | Blast
949 | BlastSepolia
950 | Fraxtal
951 | FraxtalTestnet
952 | Ink
953 | InkSepolia
954 | Gnosis
955 | Chiado
956 | ZoraSepolia
957 | Mantle
958 | MantleSepolia
959 | Mode
960 | ModeSepolia
961 | PolygonMumbai
962 | Polygon
963 | Arbitrum
964 | ArbitrumNova
965 | ArbitrumSepolia
966 | GravityAlphaMainnet
967 | GravityAlphaTestnetSepolia
968 | Xai
969 | XaiSepolia
970 | Syndr
971 | SyndrSepolia
972 | Etherlink
973 | EtherlinkTestnet
974 | Scroll
975 | ScrollSepolia
976 | HappychainTestnet
977 | Shimmer
978 | BinanceSmartChain
979 | BinanceSmartChainTestnet
980 | OpBNBMainnet
981 | OpBNBTestnet
982 | KakarotSepolia
983 | Taiko
984 | TaikoHekla
985 | Avalanche
986 | AvalancheFuji
987 | AutonomysNovaTestnet
988 | Acala
989 | AcalaMandalaTestnet
990 | AcalaTestnet
991 | Karura
992 | KaruraTestnet
993 | Darwinia
994 | Crab
995 | Cfx
996 | CfxTestnet
997 | Pulsechain
998 | PulsechainTestnet
999 | Koi
1000 | Immutable
1001 | ImmutableTestnet
1002 | Soneium
1003 | SoneiumMinatoTestnet
1004 | World
1005 | WorldSepolia
1006 | Iotex
1007 | Unichain
1008 | UnichainSepolia
1009 | ApeChain
1010 | Curtis
1011 | SuperpositionTestnet
1012 | Superposition
1013 | MonadTestnet
1014 )
1015 }
1016
1017 #[doc(hidden)]
1018 #[deprecated(since = "0.1.3", note = "use `supports_shanghai` instead")]
1019 pub const fn supports_push0(self) -> bool {
1020 self.supports_shanghai()
1021 }
1022
1023 pub const fn is_testnet(self) -> bool {
1025 use NamedChain::*;
1026
1027 match self {
1028 Goerli | Holesky | Kovan | Sepolia | Morden | Ropsten | Rinkeby | Hoodi => true,
1030
1031 ArbitrumGoerli
1033 | ArbitrumSepolia
1034 | ArbitrumTestnet
1035 | SyndrSepolia
1036 | AuroraTestnet
1037 | AvalancheFuji
1038 | Odyssey
1039 | BaseGoerli
1040 | BaseSepolia
1041 | BlastSepolia
1042 | BinanceSmartChainTestnet
1043 | CantoTestnet
1044 | CronosTestnet
1045 | CeloAlfajores
1046 | CeloBaklava
1047 | EmeraldTestnet
1048 | EvmosTestnet
1049 | FantomTestnet
1050 | FilecoinCalibrationTestnet
1051 | FraxtalTestnet
1052 | HappychainTestnet
1053 | LineaGoerli
1054 | LineaSepolia
1055 | InkSepolia
1056 | MantleTestnet
1057 | MantleSepolia
1058 | MoonbeamDev
1059 | OptimismGoerli
1060 | OptimismKovan
1061 | OptimismSepolia
1062 | BobSepolia
1063 | PolygonMumbai
1064 | PolygonAmoy
1065 | PolygonZkEvmTestnet
1066 | ScrollSepolia
1067 | Shimmer
1068 | ZkSyncTestnet
1069 | ZoraSepolia
1070 | ModeSepolia
1071 | PgnSepolia
1072 | KakarotSepolia
1073 | EtherlinkTestnet
1074 | OpBNBTestnet
1075 | RoninTestnet
1076 | TaikoHekla
1077 | AutonomysNovaTestnet
1078 | FlareCoston2
1079 | AcalaMandalaTestnet
1080 | AcalaTestnet
1081 | KaruraTestnet
1082 | CfxTestnet
1083 | PulsechainTestnet
1084 | GravityAlphaTestnetSepolia
1085 | XaiSepolia
1086 | Koi
1087 | ImmutableTestnet
1088 | SoneiumMinatoTestnet
1089 | WorldSepolia
1090 | UnichainSepolia
1091 | Curtis
1092 | TreasureTopaz
1093 | SonicTestnet
1094 | BerachainBartio
1095 | BerachainArtio
1096 | SuperpositionTestnet
1097 | MonadTestnet
1098 | TelosEvmTestnet => true,
1099
1100 Dev | AnvilHardhat => true,
1102
1103 Mainnet | Optimism | Arbitrum | ArbitrumNova | Blast | Syndr | Cronos | Rsk
1105 | BinanceSmartChain | Poa | Sokol | Scroll | Metis | Gnosis | Polygon
1106 | PolygonZkEvm | Fantom | Moonbeam | Moonriver | Moonbase | Evmos | Chiado | Oasis
1107 | Emerald | FilecoinMainnet | Avalanche | Celo | Aurora | Canto | Boba | Base
1108 | Fraxtal | Ink | Linea | ZkSync | Mantle | GravityAlphaMainnet | Xai | Zora | Pgn
1109 | Mode | Viction | Elastos | Degen | OpBNBMainnet | Ronin | Taiko | Flare | Acala
1110 | Karura | Darwinia | Cfx | Crab | Pulsechain | Etherlink | Immutable | World
1111 | Iotex | Core | Merlin | Bitlayer | ApeChain | Vana | Zeta | Kaia | Treasure | Bob
1112 | Soneium | Sonic | Superposition | Berachain | Unichain | TelosEvm | Story
1113 | Hyperliquid | Abstract => false,
1114 }
1115 }
1116
1117 pub const fn native_currency_symbol(self) -> Option<&'static str> {
1119 use NamedChain::*;
1120
1121 Some(match self {
1122 Mainnet | Goerli | Holesky | Kovan | Sepolia | Morden | Ropsten | Rinkeby | Scroll
1123 | ScrollSepolia | Taiko | TaikoHekla | Unichain | UnichainSepolia
1124 | SuperpositionTestnet | Superposition | Abstract => "ETH",
1125
1126 Mantle | MantleSepolia => "MNT",
1127
1128 GravityAlphaMainnet | GravityAlphaTestnetSepolia => "G",
1129
1130 Xai | XaiSepolia => "XAI",
1131
1132 HappychainTestnet => "HAPPY",
1133
1134 BinanceSmartChain | BinanceSmartChainTestnet | OpBNBMainnet | OpBNBTestnet => "BNB",
1135
1136 Etherlink | EtherlinkTestnet => "XTZ",
1137
1138 Degen => "DEGEN",
1139
1140 Ronin | RoninTestnet => "RON",
1141
1142 Shimmer => "SMR",
1143
1144 Flare => "FLR",
1145
1146 FlareCoston2 => "C2FLR",
1147
1148 Darwinia => "RING",
1149
1150 Crab => "CRAB",
1151
1152 Koi => "KRING",
1153
1154 Cfx | CfxTestnet => "CFX",
1155 Pulsechain | PulsechainTestnet => "PLS",
1156
1157 Immutable => "IMX",
1158 ImmutableTestnet => "tIMX",
1159
1160 World | WorldSepolia => "WRLD",
1161
1162 Iotex => "IOTX",
1163 Core => "CORE",
1164 Merlin => "BTC",
1165 Bitlayer => "BTC",
1166 Vana => "VANA",
1167 Zeta => "ZETA",
1168 Kaia => "KAIA",
1169 Story => "IP",
1170 ApeChain | Curtis => "APE",
1171
1172 Treasure | TreasureTopaz => "MAGIC",
1173
1174 BerachainBartio | BerachainArtio | Berachain => "BERA",
1175
1176 Sonic => "S",
1177
1178 TelosEvm | TelosEvmTestnet => "TLOS",
1179
1180 Hyperliquid => "HYPE",
1181
1182 Polygon | PolygonMumbai | PolygonZkEvm | PolygonZkEvmTestnet | PolygonAmoy => "POL",
1183
1184 _ => return None,
1185 })
1186 }
1187
1188 pub const fn etherscan_urls(self) -> Option<(&'static str, &'static str)> {
1210 use NamedChain::*;
1211
1212 Some(match self {
1213 Mainnet => ("https://api.etherscan.io/api", "https://etherscan.io"),
1214 Ropsten => ("https://api-ropsten.etherscan.io/api", "https://ropsten.etherscan.io"),
1215 Kovan => ("https://api-kovan.etherscan.io/api", "https://kovan.etherscan.io"),
1216 Rinkeby => ("https://api-rinkeby.etherscan.io/api", "https://rinkeby.etherscan.io"),
1217 Goerli => ("https://api-goerli.etherscan.io/api", "https://goerli.etherscan.io"),
1218 Sepolia => ("https://api-sepolia.etherscan.io/api", "https://sepolia.etherscan.io"),
1219 Holesky => ("https://api-holesky.etherscan.io/api", "https://holesky.etherscan.io"),
1220
1221 Polygon => ("https://api.polygonscan.com/api", "https://polygonscan.com"),
1222 PolygonMumbai => {
1223 ("https://api-testnet.polygonscan.com/api", "https://mumbai.polygonscan.com")
1224 }
1225 PolygonAmoy => ("https://api-amoy.polygonscan.com/api", "https://amoy.polygonscan.com"),
1226
1227 PolygonZkEvm => {
1228 ("https://api-zkevm.polygonscan.com/api", "https://zkevm.polygonscan.com")
1229 }
1230 PolygonZkEvmTestnet => (
1231 "https://api-testnet-zkevm.polygonscan.com/api",
1232 "https://testnet-zkevm.polygonscan.com",
1233 ),
1234
1235 Avalanche => ("https://api.snowtrace.io/api", "https://snowtrace.io"),
1236 AvalancheFuji => {
1237 ("https://api-testnet.snowtrace.io/api", "https://testnet.snowtrace.io")
1238 }
1239
1240 Optimism => {
1241 ("https://api-optimistic.etherscan.io/api", "https://optimistic.etherscan.io")
1242 }
1243 OptimismGoerli => (
1244 "https://api-goerli-optimistic.etherscan.io/api",
1245 "https://goerli-optimism.etherscan.io",
1246 ),
1247 OptimismKovan => (
1248 "https://api-kovan-optimistic.etherscan.io/api",
1249 "https://kovan-optimistic.etherscan.io",
1250 ),
1251 OptimismSepolia => (
1252 "https://api-sepolia-optimistic.etherscan.io/api",
1253 "https://sepolia-optimism.etherscan.io",
1254 ),
1255
1256 Bob => ("https://explorer.gobob.xyz/api", "https://explorer.gobob.xyz"),
1257 BobSepolia => (
1258 "https://bob-sepolia.explorer.gobob.xyz/api",
1259 "https://bob-sepolia.explorer.gobob.xyz",
1260 ),
1261
1262 Fantom => ("https://api.ftmscan.com/api", "https://ftmscan.com"),
1263 FantomTestnet => ("https://api-testnet.ftmscan.com/api", "https://testnet.ftmscan.com"),
1264
1265 BinanceSmartChain => ("https://api.bscscan.com/api", "https://bscscan.com"),
1266 BinanceSmartChainTestnet => {
1267 ("https://api-testnet.bscscan.com/api", "https://testnet.bscscan.com")
1268 }
1269
1270 OpBNBMainnet => ("https://opbnb.bscscan.com/api", "https://opbnb.bscscan.com"),
1271 OpBNBTestnet => {
1272 ("https://opbnb-testnet.bscscan.com/api", "https://opbnb-testnet.bscscan.com")
1273 }
1274
1275 Arbitrum => ("https://api.arbiscan.io/api", "https://arbiscan.io"),
1276 ArbitrumTestnet => {
1277 ("https://api-testnet.arbiscan.io/api", "https://testnet.arbiscan.io")
1278 }
1279 ArbitrumGoerli => ("https://api-goerli.arbiscan.io/api", "https://goerli.arbiscan.io"),
1280 ArbitrumSepolia => {
1281 ("https://api-sepolia.arbiscan.io/api", "https://sepolia.arbiscan.io")
1282 }
1283 ArbitrumNova => ("https://api-nova.arbiscan.io/api", "https://nova.arbiscan.io"),
1284
1285 GravityAlphaMainnet => {
1286 ("https://explorer.gravity.xyz/api", "https://explorer.gravity.xyz")
1287 }
1288 GravityAlphaTestnetSepolia => {
1289 ("https://explorer-sepolia.gravity.xyz/api", "https://explorer-sepolia.gravity.xyz")
1290 }
1291 HappychainTestnet => (
1292 "https://happy-testnet-sepolia.explorer.caldera.xyz/api",
1293 "https://happy-testnet-sepolia.explorer.caldera.xyz",
1294 ),
1295
1296 XaiSepolia => ("https://sepolia.xaiscan.io/api", "https://sepolia.xaiscan.io"),
1297 Xai => ("https://xaiscan.io/api", "https://xaiscan.io"),
1298
1299 Syndr => ("https://explorer.syndr.com/api", "https://explorer.syndr.com"),
1300 SyndrSepolia => {
1301 ("https://sepolia-explorer.syndr.com/api", "https://sepolia-explorer.syndr.com")
1302 }
1303
1304 Cronos => ("https://api.cronoscan.com/api", "https://cronoscan.com"),
1305 CronosTestnet => {
1306 ("https://api-testnet.cronoscan.com/api", "https://testnet.cronoscan.com")
1307 }
1308
1309 Moonbeam => ("https://api-moonbeam.moonscan.io/api", "https://moonbeam.moonscan.io"),
1310 Moonbase => ("https://api-moonbase.moonscan.io/api", "https://moonbase.moonscan.io"),
1311 Moonriver => ("https://api-moonriver.moonscan.io/api", "https://moonriver.moonscan.io"),
1312
1313 Gnosis => ("https://api.gnosisscan.io/api", "https://gnosisscan.io"),
1314
1315 Scroll => ("https://api.scrollscan.com/api", "https://scrollscan.com"),
1316 ScrollSepolia => {
1317 ("https://api-sepolia.scrollscan.com/api", "https://sepolia.scrollscan.com")
1318 }
1319
1320 Ink => ("https://explorer.inkonchain.com/api/v2", "https://explorer.inkonchain.com"),
1321 InkSepolia => (
1322 "https://explorer-sepolia.inkonchain.com/api/v2",
1323 "https://explorer-sepolia.inkonchain.com",
1324 ),
1325
1326 Shimmer => {
1327 ("https://explorer.evm.shimmer.network/api", "https://explorer.evm.shimmer.network")
1328 }
1329
1330 Metis => (
1331 "https://api.routescan.io/v2/network/mainnet/evm/1088/etherscan",
1332 "https://explorer.metis.io",
1333 ),
1334
1335 Chiado => {
1336 ("https://blockscout.chiadochain.net/api", "https://blockscout.chiadochain.net")
1337 }
1338
1339 FilecoinCalibrationTestnet => (
1340 "https://api.calibration.node.glif.io/rpc/v1",
1341 "https://calibration.filfox.info/en",
1342 ),
1343
1344 Sokol => ("https://blockscout.com/poa/sokol/api", "https://blockscout.com/poa/sokol"),
1345
1346 Poa => ("https://blockscout.com/poa/core/api", "https://blockscout.com/poa/core"),
1347
1348 Rsk => ("https://blockscout.com/rsk/mainnet/api", "https://blockscout.com/rsk/mainnet"),
1349
1350 Oasis => ("https://scan.oasischain.io/api", "https://scan.oasischain.io"),
1351
1352 Emerald => {
1353 ("https://explorer.emerald.oasis.dev/api", "https://explorer.emerald.oasis.dev")
1354 }
1355 EmeraldTestnet => (
1356 "https://testnet.explorer.emerald.oasis.dev/api",
1357 "https://testnet.explorer.emerald.oasis.dev",
1358 ),
1359
1360 Aurora => ("https://api.aurorascan.dev/api", "https://aurorascan.dev"),
1361 AuroraTestnet => {
1362 ("https://testnet.aurorascan.dev/api", "https://testnet.aurorascan.dev")
1363 }
1364
1365 Evmos => ("https://evm.evmos.org/api", "https://evm.evmos.org"),
1366 EvmosTestnet => ("https://evm.evmos.dev/api", "https://evm.evmos.dev"),
1367
1368 Celo => ("https://api.celoscan.io/api", "https://celoscan.io"),
1369 CeloAlfajores => {
1370 ("https://api-alfajores.celoscan.io/api", "https://alfajores.celoscan.io")
1371 }
1372 CeloBaklava => {
1373 ("https://explorer.celo.org/baklava/api", "https://explorer.celo.org/baklava")
1374 }
1375
1376 Canto => ("https://evm.explorer.canto.io/api", "https://evm.explorer.canto.io"),
1377 CantoTestnet => (
1378 "https://testnet-explorer.canto.neobase.one/api",
1379 "https://testnet-explorer.canto.neobase.one",
1380 ),
1381
1382 Boba => ("https://api.bobascan.com/api", "https://bobascan.com"),
1383
1384 Base => ("https://api.basescan.org/api", "https://basescan.org"),
1385 BaseGoerli => ("https://api-goerli.basescan.org/api", "https://goerli.basescan.org"),
1386 BaseSepolia => ("https://api-sepolia.basescan.org/api", "https://sepolia.basescan.org"),
1387
1388 Fraxtal => ("https://api.fraxscan.com/api", "https://fraxscan.com"),
1389 FraxtalTestnet => {
1390 ("https://api-holesky.fraxscan.com/api", "https://holesky.fraxscan.com")
1391 }
1392
1393 Blast => ("https://api.blastscan.io/api", "https://blastscan.io"),
1394 BlastSepolia => {
1395 ("https://api-sepolia.blastscan.io/api", "https://sepolia.blastscan.io")
1396 }
1397
1398 ZkSync => ("https://api-era.zksync.network/api", "https://era.zksync.network"),
1399 ZkSyncTestnet => {
1400 ("https://api-sepolia-era.zksync.network/api", "https://sepolia-era.zksync.network")
1401 }
1402
1403 Linea => ("https://api.lineascan.build/api", "https://lineascan.build"),
1404 LineaGoerli => {
1405 ("https://explorer.goerli.linea.build/api", "https://explorer.goerli.linea.build")
1406 }
1407 LineaSepolia => {
1408 ("https://api-sepolia.lineascan.build/api", "https://sepolia.lineascan.build")
1409 }
1410
1411 Mantle => ("https://explorer.mantle.xyz/api", "https://explorer.mantle.xyz"),
1412 MantleTestnet => {
1413 ("https://explorer.testnet.mantle.xyz/api", "https://explorer.testnet.mantle.xyz")
1414 }
1415 MantleSepolia => {
1416 ("https://explorer.sepolia.mantle.xyz/api", "https://explorer.sepolia.mantle.xyz")
1417 }
1418
1419 Viction => ("https://www.vicscan.xyz/api", "https://www.vicscan.xyz"),
1420
1421 Zora => ("https://explorer.zora.energy/api", "https://explorer.zora.energy"),
1422 ZoraSepolia => {
1423 ("https://sepolia.explorer.zora.energy/api", "https://sepolia.explorer.zora.energy")
1424 }
1425
1426 Pgn => {
1427 ("https://explorer.publicgoods.network/api", "https://explorer.publicgoods.network")
1428 }
1429
1430 PgnSepolia => (
1431 "https://explorer.sepolia.publicgoods.network/api",
1432 "https://explorer.sepolia.publicgoods.network",
1433 ),
1434
1435 Mode => ("https://explorer.mode.network/api", "https://explorer.mode.network"),
1436 ModeSepolia => (
1437 "https://sepolia.explorer.mode.network/api",
1438 "https://sepolia.explorer.mode.network",
1439 ),
1440
1441 Elastos => ("https://esc.elastos.io/api", "https://esc.elastos.io"),
1442 KakarotSepolia => {
1443 ("https://sepolia.kakarotscan.org/api", "https://sepolia.kakarotscan.org")
1444 }
1445 Etherlink => ("https://explorer.etherlink.com/api", "https://explorer.etherlink.com"),
1446 EtherlinkTestnet => (
1447 "https://testnet-explorer.etherlink.com/api",
1448 "https://testnet-explorer.etherlink.com",
1449 ),
1450 Degen => ("https://explorer.degen.tips/api", "https://explorer.degen.tips"),
1451 Ronin => ("https://skynet-api.roninchain.com/ronin", "https://app.roninchain.com"),
1452 RoninTestnet => (
1453 "https://api-gateway.skymavis.com/rpc/testnet",
1454 "https://saigon-app.roninchain.com",
1455 ),
1456 Taiko => ("https://api.taikoscan.io/api", "https://taikoscan.io"),
1457 TaikoHekla => ("https://api-testnet.taikoscan.io/api", "https://hekla.taikoscan.io"),
1458 Flare => {
1459 ("https://flare-explorer.flare.network/api", "https://flare-explorer.flare.network")
1460 }
1461 FlareCoston2 => (
1462 "https://coston2-explorer.flare.network/api",
1463 "https://coston2-explorer.flare.network",
1464 ),
1465 Acala => ("https://blockscout.acala.network/api", "https://blockscout.acala.network"),
1466 AcalaMandalaTestnet => (
1467 "https://blockscout.mandala.aca-staging.network/api",
1468 "https://blockscout.mandala.aca-staging.network",
1469 ),
1470 AcalaTestnet => (
1471 "https://blockscout.acala-testnet.aca-staging.network/api",
1472 "https://blockscout.acala-testnet.aca-staging.network",
1473 ),
1474 Karura => {
1475 ("https://blockscout.karura.network/api", "https://blockscout.karura.network")
1476 }
1477 KaruraTestnet => (
1478 "https://blockscout.karura-testnet.aca-staging.network/api",
1479 "https://blockscout.karura-testnet.aca-staging.network",
1480 ),
1481
1482 Darwinia => {
1483 ("https://explorer.darwinia.network/api", "https://explorer.darwinia.network")
1484 }
1485 Crab => {
1486 ("https://crab-scan.darwinia.network/api", "https://crab-scan.darwinia.network")
1487 }
1488 Koi => ("https://koi-scan.darwinia.network/api", "https://koi-scan.darwinia.network"),
1489 Cfx => ("https://evmapi.confluxscan.net/api", "https://evm.confluxscan.io"),
1490 CfxTestnet => {
1491 ("https://evmapi-testnet.confluxscan.net/api", "https://evmtestnet.confluxscan.io")
1492 }
1493 Pulsechain => ("https://api.scan.pulsechain.com", "https://scan.pulsechain.com"),
1494 PulsechainTestnet => (
1495 "https://api.scan.v4.testnet.pulsechain.com",
1496 "https://scan.v4.testnet.pulsechain.com",
1497 ),
1498
1499 Immutable => ("https://explorer.immutable.com/api", "https://explorer.immutable.com"),
1500 ImmutableTestnet => (
1501 "https://explorer.testnet.immutable.com/api",
1502 "https://explorer.testnet.immutable.com",
1503 ),
1504 Soneium => ("https://soneium.blockscout.com/api", "https://soneium.blockscout.com"),
1505 SoneiumMinatoTestnet => (
1506 "https://soneium-minato.blockscout.com/api",
1507 "https://soneium-minato.blockscout.com",
1508 ),
1509 Odyssey => {
1510 ("https://odyssey-explorer.ithaca.xyz/api", "https://odyssey-explorer.ithaca.xyz")
1511 }
1512 World => ("https://api.worldscan.org/api", "https://worldscan.org"),
1513 WorldSepolia => {
1514 ("https://api-sepolia.worldscan.org/api", "https://sepolia.worldscan.org")
1515 }
1516 Unichain => ("https://api.uniscan.xyz/api", "https://uniscan.xyz"),
1517 UnichainSepolia => {
1518 ("https://api-sepolia.uniscan.xyz/api", "https://sepolia.uniscan.xyz")
1519 }
1520 Core => ("https://openapi.coredao.org/api", "https://scan.coredao.org"),
1521 Merlin => ("https://scan.merlinchain.io/api", "https://scan.merlinchain.io"),
1522 Bitlayer => ("https://api.btrscan.com/scan/api", "https://www.btrscan.com"),
1523 Vana => ("https://api.vanascan.io/api", "https://vanascan.io"),
1524 Zeta => ("https://zetachain.blockscout.com/api", "https://zetachain.blockscout.com"),
1525 Kaia => ("https://mainnet-oapi.kaiascan.io/api", "https://kaiascan.io"),
1526 Story => ("https://www.storyscan.xyz/api/v2", "https://www.storyscan.xyz"),
1527
1528 ApeChain => ("https://api.apescan.io/api", "https://apescan.io"),
1529 Curtis => ("https://curtis.explorer.caldera.xyz/api/v2", "https://curtis.apescan.io"),
1530 SonicTestnet => (
1531 "https://api.routescan.io/v2/network/testnet/evm/64165/etherscan/api",
1532 "https://scan.soniclabs.com",
1533 ),
1534 Sonic => ("https://api.sonicscan.org/api", "https://sonicscan.org"),
1535 Treasure => ("https://block-explorer.treasurescan.io/api", "https://treasurescan.io"),
1536 TreasureTopaz => (
1537 "https://block-explorer.topaz.treasurescan.io/api",
1538 "https://topaz.treasurescan.io",
1539 ),
1540 BerachainBartio => ("https://bartio.beratrail.io/api", "https://bartio.beratrail.io"),
1541 BerachainArtio => ("https://artio.beratrail.io/api", "https://artio.beratrail.io"),
1542 Berachain => ("https://api.berascan.com/api", "https://berascan.com"),
1543 SuperpositionTestnet => (
1544 "https://testnet-explorer.superposition.so/api",
1545 "https://testnet-explorer.superposition.so",
1546 ),
1547 Superposition => {
1548 ("https://explorer.superposition.so/api", "https://explorer.superposition.so")
1549 }
1550 MonadTestnet => ("https://sourcify.dev/server", "https://testnet.monadexplorer.com"),
1551 TelosEvm => ("https://api.teloscan.io/api", "https://teloscan.io"),
1552 TelosEvmTestnet => {
1553 ("https://api.testnet.teloscan.io/api", "https://testnet.teloscan.io")
1554 }
1555 Hyperliquid => (
1556 "https://hyperliquid.cloud.blockscout.com/api/v2",
1557 "https://hyperliquid.cloud.blockscout.com",
1558 ),
1559 Abstract => ("https://api.abscan.org/api", "https://abscan.org"),
1560 AnvilHardhat | Dev | Morden | MoonbeamDev | FilecoinMainnet | AutonomysNovaTestnet
1562 | Iotex | Hoodi => {
1563 return None;
1564 }
1565 })
1566 }
1567
1568 pub const fn etherscan_api_key_name(self) -> Option<&'static str> {
1579 use NamedChain::*;
1580
1581 let api_key_name = match self {
1582 Mainnet
1583 | Morden
1584 | Ropsten
1585 | Kovan
1586 | Rinkeby
1587 | Goerli
1588 | Holesky
1589 | Hoodi
1590 | Optimism
1591 | OptimismGoerli
1592 | OptimismKovan
1593 | OptimismSepolia
1594 | BinanceSmartChain
1595 | BinanceSmartChainTestnet
1596 | OpBNBMainnet
1597 | OpBNBTestnet
1598 | Arbitrum
1599 | ArbitrumTestnet
1600 | ArbitrumGoerli
1601 | ArbitrumSepolia
1602 | ArbitrumNova
1603 | Syndr
1604 | SyndrSepolia
1605 | Cronos
1606 | CronosTestnet
1607 | Aurora
1608 | AuroraTestnet
1609 | Celo
1610 | CeloAlfajores
1611 | Base
1612 | Linea
1613 | LineaSepolia
1614 | Mantle
1615 | MantleTestnet
1616 | MantleSepolia
1617 | Xai
1618 | XaiSepolia
1619 | BaseGoerli
1620 | BaseSepolia
1621 | Fraxtal
1622 | FraxtalTestnet
1623 | Blast
1624 | BlastSepolia
1625 | Gnosis
1626 | Scroll
1627 | ScrollSepolia
1628 | Taiko
1629 | TaikoHekla
1630 | Unichain
1631 | UnichainSepolia
1632 | MonadTestnet
1633 | ApeChain
1634 | Abstract => "ETHERSCAN_API_KEY",
1635
1636 Avalanche | AvalancheFuji => "SNOWTRACE_API_KEY",
1637
1638 Polygon | PolygonMumbai | PolygonAmoy | PolygonZkEvm | PolygonZkEvmTestnet => {
1639 "POLYGONSCAN_API_KEY"
1640 }
1641
1642 Fantom | FantomTestnet => "FTMSCAN_API_KEY",
1643
1644 Moonbeam | Moonbase | MoonbeamDev | Moonriver => "MOONSCAN_API_KEY",
1645
1646 Acala | AcalaMandalaTestnet | AcalaTestnet | Canto | CantoTestnet | CeloBaklava
1647 | Etherlink | EtherlinkTestnet | Flare | FlareCoston2 | KakarotSepolia | Karura
1648 | KaruraTestnet | Mode | ModeSepolia | Pgn | PgnSepolia | Shimmer | Zora
1649 | ZoraSepolia | Darwinia | Crab | Koi | Immutable | ImmutableTestnet | Soneium
1650 | SoneiumMinatoTestnet | World | WorldSepolia | Curtis | Ink | InkSepolia
1651 | SuperpositionTestnet | Superposition | Vana | Story | Hyperliquid => {
1652 "BLOCKSCOUT_API_KEY"
1653 }
1654
1655 Boba => "BOBASCAN_API_KEY",
1656
1657 Core => "CORESCAN_API_KEY",
1658 Merlin => "MERLINSCAN_API_KEY",
1659 Bitlayer => "BITLAYERSCAN_API_KEY",
1660 Zeta => "ZETASCAN_API_KEY",
1661 Kaia => "KAIASCAN_API_KEY",
1662 Sonic => "SONICSCAN_API_KEY",
1663 Berachain => "BERASCAN_API_KEY",
1664 Metis
1666 | Chiado
1667 | Odyssey
1668 | Sepolia
1669 | Rsk
1670 | Sokol
1671 | Poa
1672 | Oasis
1673 | Emerald
1674 | EmeraldTestnet
1675 | Evmos
1676 | EvmosTestnet
1677 | AnvilHardhat
1678 | Dev
1679 | GravityAlphaMainnet
1680 | GravityAlphaTestnetSepolia
1681 | Bob
1682 | BobSepolia
1683 | ZkSync
1684 | ZkSyncTestnet
1685 | FilecoinMainnet
1686 | LineaGoerli
1687 | FilecoinCalibrationTestnet
1688 | Viction
1689 | Elastos
1690 | Degen
1691 | Ronin
1692 | RoninTestnet
1693 | Cfx
1694 | CfxTestnet
1695 | Pulsechain
1696 | PulsechainTestnet
1697 | AutonomysNovaTestnet
1698 | Iotex
1699 | HappychainTestnet
1700 | SonicTestnet
1701 | Treasure
1702 | TreasureTopaz
1703 | BerachainBartio
1704 | BerachainArtio
1705 | TelosEvm
1706 | TelosEvmTestnet => return None,
1707 };
1708
1709 Some(api_key_name)
1710 }
1711
1712 #[cfg(feature = "std")]
1725 pub fn etherscan_api_key(self) -> Option<String> {
1726 self.etherscan_api_key_name().and_then(|name| std::env::var(name).ok())
1727 }
1728
1729 pub fn public_dns_network_protocol(self) -> Option<String> {
1733 use NamedChain::*;
1734
1735 const DNS_PREFIX: &str = "enrtree://AKA3AM6LPBYEUDMVNU3BSVQJ5AD45Y7YPOHJLEF6W26QOE4VTUDPE@";
1736 if let Mainnet | Goerli | Sepolia | Ropsten | Rinkeby | Holesky | Hoodi = self {
1737 let mut s = String::with_capacity(DNS_PREFIX.len() + 32);
1739 s.push_str(DNS_PREFIX);
1740 s.push_str("all.");
1741 let chain_str = self.as_ref();
1742 s.push_str(chain_str);
1743 let l = s.len();
1744 s[l - chain_str.len()..].make_ascii_lowercase();
1745 s.push_str(".ethdisco.net");
1746
1747 Some(s)
1748 } else {
1749 None
1750 }
1751 }
1752
1753 pub const fn wrapped_native_token(self) -> Option<Address> {
1769 use NamedChain::*;
1770
1771 let addr = match self {
1772 Mainnet => address!("C02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"),
1773 Optimism => address!("4200000000000000000000000000000000000006"),
1774 BinanceSmartChain => address!("bb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c"),
1775 OpBNBMainnet => address!("4200000000000000000000000000000000000006"),
1776 Arbitrum => address!("82af49447d8a07e3bd95bd0d56f35241523fbab1"),
1777 Base => address!("4200000000000000000000000000000000000006"),
1778 Linea => address!("e5d7c2a44ffddf6b295a15c148167daaaf5cf34f"),
1779 Mantle => address!("deaddeaddeaddeaddeaddeaddeaddeaddead1111"),
1780 Blast => address!("4300000000000000000000000000000000000004"),
1781 Gnosis => address!("e91d153e0b41518a2ce8dd3d7944fa863463a97d"),
1782 Scroll => address!("5300000000000000000000000000000000000004"),
1783 Taiko => address!("a51894664a773981c6c112c43ce576f315d5b1b6"),
1784 Avalanche => address!("b31f66aa3c1e785363f0875a1b74e27b85fd66c7"),
1785 Polygon => address!("0d500b1d8e8ef31e21c99d1db9a6444d3adf1270"),
1786 Fantom => address!("21be370d5312f44cb42ce377bc9b8a0cef1a4c83"),
1787 Iotex => address!("a00744882684c3e4747faefd68d283ea44099d03"),
1788 Core => address!("40375C92d9FAf44d2f9db9Bd9ba41a3317a2404f"),
1789 Merlin => address!("F6D226f9Dc15d9bB51182815b320D3fBE324e1bA"),
1790 Bitlayer => address!("ff204e2681a6fa0e2c3fade68a1b28fb90e4fc5f"),
1791 ApeChain => address!("48b62137EdfA95a428D35C09E44256a739F6B557"),
1792 Vana => address!("00EDdD9621Fb08436d0331c149D1690909a5906d"),
1793 Zeta => address!("5F0b1a82749cb4E2278EC87F8BF6B618dC71a8bf"),
1794 Kaia => address!("19aac5f612f524b754ca7e7c41cbfa2e981a4432"),
1795 Story => address!("1514000000000000000000000000000000000000"),
1796 Treasure => address!("263d8f36bb8d0d9526255e205868c26690b04b88"),
1797 Superposition => address!("1fB719f10b56d7a85DCD32f27f897375fB21cfdd"),
1798 Sonic => address!("039e2fB66102314Ce7b64Ce5Ce3E5183bc94aD38"),
1799 Berachain => address!("6969696969696969696969696969696969696969"),
1800 Hyperliquid => address!("5555555555555555555555555555555555555555"),
1801 Abstract => address!("3439153EB7AF838Ad19d56E1571FBD09333C2809"),
1802 _ => return None,
1803 };
1804
1805 Some(addr)
1806 }
1807}
1808
1809#[cfg(test)]
1810mod tests {
1811 use super::*;
1812 use strum::{EnumCount, IntoEnumIterator};
1813
1814 #[allow(unused_imports)]
1815 use alloc::string::ToString;
1816
1817 #[test]
1818 #[cfg(feature = "serde")]
1819 fn default() {
1820 assert_eq!(serde_json::to_string(&NamedChain::default()).unwrap(), "\"mainnet\"");
1821 }
1822
1823 #[test]
1824 fn enum_iter() {
1825 assert_eq!(NamedChain::COUNT, NamedChain::iter().size_hint().0);
1826 }
1827
1828 #[test]
1829 fn roundtrip_string() {
1830 for chain in NamedChain::iter() {
1831 let chain_string = chain.to_string();
1832 assert_eq!(chain_string, format!("{chain}"));
1833 assert_eq!(chain_string.as_str(), chain.as_ref());
1834 #[cfg(feature = "serde")]
1835 assert_eq!(serde_json::to_string(&chain).unwrap(), format!("\"{chain_string}\""));
1836
1837 assert_eq!(chain_string.parse::<NamedChain>().unwrap(), chain);
1838 }
1839 }
1840
1841 #[test]
1842 #[cfg(feature = "serde")]
1843 fn roundtrip_serde() {
1844 for chain in NamedChain::iter() {
1845 let chain_string = serde_json::to_string(&chain).unwrap();
1846 let chain_string = chain_string.replace('-', "_");
1847 assert_eq!(serde_json::from_str::<'_, NamedChain>(&chain_string).unwrap(), chain);
1848 }
1849 }
1850
1851 #[test]
1852 fn aliases() {
1853 use NamedChain::*;
1854
1855 const ALIASES: &[(NamedChain, &[&str])] = &[
1857 (Mainnet, &["ethlive"]),
1858 (BinanceSmartChain, &["bsc", "bnb-smart-chain", "binance-smart-chain"]),
1859 (
1860 BinanceSmartChainTestnet,
1861 &["bsc-testnet", "bnb-smart-chain-testnet", "binance-smart-chain-testnet"],
1862 ),
1863 (Gnosis, &["gnosis", "gnosis-chain"]),
1864 (PolygonMumbai, &["mumbai"]),
1865 (PolygonZkEvm, &["zkevm", "polygon-zkevm"]),
1866 (PolygonZkEvmTestnet, &["zkevm-testnet", "polygon-zkevm-testnet"]),
1867 (AnvilHardhat, &["anvil", "hardhat"]),
1868 (AvalancheFuji, &["fuji"]),
1869 (ZkSync, &["zksync"]),
1870 (Mantle, &["mantle"]),
1871 (MantleTestnet, &["mantle-testnet"]),
1872 (MantleSepolia, &["mantle-sepolia"]),
1873 (GravityAlphaMainnet, &["gravity-alpha-mainnet"]),
1874 (GravityAlphaTestnetSepolia, &["gravity-alpha-testnet-sepolia"]),
1875 (Bob, &["bob"]),
1876 (BobSepolia, &["bob-sepolia"]),
1877 (HappychainTestnet, &["happychain-testnet"]),
1878 (Xai, &["xai"]),
1879 (XaiSepolia, &["xai-sepolia"]),
1880 (Base, &["base"]),
1881 (BaseGoerli, &["base-goerli"]),
1882 (BaseSepolia, &["base-sepolia"]),
1883 (Fraxtal, &["fraxtal"]),
1884 (FraxtalTestnet, &["fraxtal-testnet"]),
1885 (Ink, &["ink"]),
1886 (InkSepolia, &["ink-sepolia"]),
1887 (BlastSepolia, &["blast-sepolia"]),
1888 (Syndr, &["syndr"]),
1889 (SyndrSepolia, &["syndr-sepolia"]),
1890 (LineaGoerli, &["linea-goerli"]),
1891 (LineaSepolia, &["linea-sepolia"]),
1892 (AutonomysNovaTestnet, &["autonomys-nova-testnet"]),
1893 (Immutable, &["immutable"]),
1894 (ImmutableTestnet, &["immutable-testnet"]),
1895 (Soneium, &["soneium"]),
1896 (SoneiumMinatoTestnet, &["soneium-minato-testnet"]),
1897 (ApeChain, &["apechain"]),
1898 (Curtis, &["apechain-testnet", "curtis"]),
1899 (Treasure, &["treasure"]),
1900 (TreasureTopaz, &["treasure-topaz-testnet", "treasure-topaz"]),
1901 (BerachainArtio, &["berachain-artio-testnet", "berachain-artio"]),
1902 (BerachainBartio, &["berachain-bartio-testnet", "berachain-bartio"]),
1903 (SuperpositionTestnet, &["superposition-testnet"]),
1904 (Superposition, &["superposition"]),
1905 (Hyperliquid, &["hyperliquid"]),
1906 (Abstract, &["abstract"]),
1907 ];
1908
1909 for &(chain, aliases) in ALIASES {
1910 for &alias in aliases {
1911 let named = alias.parse::<NamedChain>().expect(alias);
1912 assert_eq!(named, chain);
1913
1914 #[cfg(feature = "serde")]
1915 {
1916 assert_eq!(
1917 serde_json::from_str::<NamedChain>(&format!("\"{alias}\"")).unwrap(),
1918 chain
1919 );
1920
1921 assert_eq!(
1922 serde_json::from_str::<NamedChain>(&format!("\"{named}\"")).unwrap(),
1923 chain
1924 );
1925 }
1926 }
1927 }
1928 }
1929
1930 #[test]
1931 #[cfg(feature = "serde")]
1932 fn serde_to_string_match() {
1933 for chain in NamedChain::iter() {
1934 let chain_serde = serde_json::to_string(&chain).unwrap();
1935 let chain_string = format!("\"{chain}\"");
1936 assert_eq!(chain_serde, chain_string);
1937 }
1938 }
1939
1940 #[test]
1941 fn test_dns_network() {
1942 let s = "enrtree://AKA3AM6LPBYEUDMVNU3BSVQJ5AD45Y7YPOHJLEF6W26QOE4VTUDPE@all.mainnet.ethdisco.net";
1943 assert_eq!(NamedChain::Mainnet.public_dns_network_protocol().unwrap(), s);
1944 }
1945
1946 #[test]
1947 fn ensure_no_trailing_etherscan_url_separator() {
1948 for chain in NamedChain::iter() {
1949 if let Some((api, base)) = chain.etherscan_urls() {
1950 assert!(!api.ends_with('/'), "{:?} api url has trailing /", chain);
1951 assert!(!base.ends_with('/'), "{:?} base url has trailing /", chain);
1952 }
1953 }
1954 }
1955}