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