Skip to main content

Chain

Enum Chain 

Source
#[non_exhaustive]
pub enum Chain {
Show 39 variants Ethereum, Goerli, Sepolia, Holesky, Optimism, OptimismSepolia, Bsc, BscTestnet, Gnosis, Polygon, Mumbai, Amoy, Fantom, FantomTestnet, Moonbeam, Moonriver, Arbitrum, ArbitrumNova, ArbitrumSepolia, Avalanche, AvalancheFuji, Celo, Base, BaseSepolia, Linea, LineaTestnet, ZkSync, ZkSyncSepolia, Scroll, ScrollSepolia, Blast, BlastSepolia, Mantle, Mode, Fraxtal, Klaytn, Aurora, PolygonZkEvm, Other(u64),
}
Expand description

Common EVM chain identifiers

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Ethereum

Ethereum Mainnet (1)

§

Goerli

Goerli Testnet (5) - deprecated

§

Sepolia

Sepolia Testnet (11155111)

§

Holesky

Holesky Testnet (17000)

§

Optimism

Optimism (10)

§

OptimismSepolia

Optimism Sepolia (11155420)

§

Bsc

BNB Smart Chain (56)

§

BscTestnet

BNB Smart Chain Testnet (97)

§

Gnosis

Gnosis/xDai (100)

§

Polygon

Polygon/Matic (137)

§

Mumbai

Polygon Mumbai (80001) - deprecated

§

Amoy

Polygon Amoy (80002)

§

Fantom

Fantom Opera (250)

§

FantomTestnet

Fantom Testnet (4002)

§

Moonbeam

Moonbeam (1284)

§

Moonriver

Moonriver (1285)

§

Arbitrum

Arbitrum One (42161)

§

ArbitrumNova

Arbitrum Nova (42170)

§

ArbitrumSepolia

Arbitrum Sepolia (421614)

§

Avalanche

Avalanche C-Chain (43114)

§

AvalancheFuji

Avalanche Fuji (43113)

§

Celo

Celo (42220)

§

Base

Base (8453)

§

BaseSepolia

Base Sepolia (84532)

§

Linea

Linea (59144)

§

LineaTestnet

Linea Testnet (59140)

§

ZkSync

zkSync Era (324)

§

ZkSyncSepolia

zkSync Sepolia (300)

§

Scroll

Scroll (534352)

§

ScrollSepolia

Scroll Sepolia (534351)

§

Blast

Blast (81457)

§

BlastSepolia

Blast Sepolia (168587773)

§

Mantle

Mantle (5000)

§

Mode

Mode (34443)

§

Fraxtal

Fraxtal (252)

§

Klaytn

Klaytn (8217)

§

Aurora

Aurora (1313161554)

§

PolygonZkEvm

Polygon zkEVM (1101)

§

Other(u64)

Unknown chain with custom ID

Implementations§

Source§

impl Chain

Source

pub const fn id(&self) -> u64

Get the chain ID

Source

pub const fn name(&self) -> &'static str

Get the chain name (lowercase, API-friendly)

Source

pub const fn display_name(&self) -> &'static str

Get the display name (human-readable)

Source

pub const fn native_currency(&self) -> &'static str

Get the native currency symbol

Source

pub const fn is_testnet(&self) -> bool

Check if this is a testnet

Source

pub const fn is_mainnet(&self) -> bool

Check if this is a mainnet

Source

pub const fn from_id(id: u64) -> Self

Get chain from ID

Source

pub fn from_name(name: &str) -> Option<Self>

Get chain from name (case-insensitive)

Source

pub const fn mainnets() -> &'static [Chain]

List all known mainnets

Trait Implementations§

Source§

impl Clone for Chain

Source§

fn clone(&self) -> Chain

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Chain

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Chain

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<Chain> for u64

Source§

fn from(chain: Chain) -> Self

Converts to this type from the input type.
Source§

impl From<u64> for Chain

Source§

fn from(id: u64) -> Self

Converts to this type from the input type.
Source§

impl Hash for Chain

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Chain

Source§

fn eq(&self, other: &Chain) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for Chain

Source§

impl Eq for Chain

Source§

impl StructuralPartialEq for Chain

Auto Trait Implementations§

§

impl Freeze for Chain

§

impl RefUnwindSafe for Chain

§

impl Send for Chain

§

impl Sync for Chain

§

impl Unpin for Chain

§

impl UnwindSafe for Chain

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T> ToStringFallible for T
where T: Display,

Source§

fn try_to_string(&self) -> Result<String, TryReserveError>

ToString::to_string, but without panic on OOM.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more