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