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