alloy_chains

Struct Chain

Source
pub struct Chain(/* private fields */);
Expand description

Either a known NamedChain or a EIP-155 chain ID.

Implementations§

Source§

impl Chain

Source

pub const fn from_named(named: NamedChain) -> Self

Creates a new Chain by wrapping a NamedChain.

Source

pub fn from_id(id: u64) -> Self

Creates a new Chain by wrapping a NamedChain.

Source

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

Creates a new Chain from the given ID, without checking if an associated NamedChain exists.

This is discouraged, as other methods assume that the chain ID is not known, but it is not unsafe.

Source

pub const fn mainnet() -> Self

Returns the mainnet chain.

Source

pub const fn goerli() -> Self

Returns the goerli chain.

Source

pub const fn holesky() -> Self

Returns the holesky chain.

Source

pub const fn sepolia() -> Self

Returns the sepolia chain.

Source

pub const fn optimism_mainnet() -> Self

Returns the optimism mainnet chain.

Source

pub const fn optimism_goerli() -> Self

Returns the optimism goerli chain.

Source

pub const fn optimism_sepolia() -> Self

Returns the optimism sepolia chain.

Source

pub const fn base_mainnet() -> Self

Returns the base mainnet chain.

Source

pub const fn base_goerli() -> Self

Returns the base goerli chain.

Source

pub const fn base_sepolia() -> Self

Returns the base sepolia chain.

Source

pub const fn syndr() -> Self

Returns the syndr l3 mainnet chain.

Source

pub const fn syndr_sepolia() -> Self

Returns the syndr sepolia chain.

Source

pub const fn fraxtal() -> Self

Returns the fraxtal mainnet chain.

Source

pub const fn fraxtal_testnet() -> Self

Returns the fraxtal testnet chain.

Source

pub const fn blast() -> Self

Returns the blast chain.

Source

pub const fn blast_sepolia() -> Self

Returns the blast sepolia chain.

Source

pub const fn linea() -> Self

Returns the linea mainnet chain.

Source

pub const fn linea_goerli() -> Self

Returns the linea goerli chain.

Source

pub const fn linea_sepolia() -> Self

Returns the linea sepolia chain.

Source

pub const fn mode() -> Self

Returns the mode mainnet chain.

Source

pub const fn mode_sepolia() -> Self

Returns the mode sepolia chain.

Source

pub const fn elastos() -> Self

Returns the elastos mainnet chain.

Source

pub const fn degen() -> Self

Returns the degen l3 mainnet chain.

Source

pub const fn dev() -> Self

Returns the dev chain.

Source

pub const fn bsc_mainnet() -> Self

Returns the bsc mainnet chain.

Source

pub const fn bsc_testnet() -> Self

Returns the bsc testnet chain.

Source

pub const fn opbnb_mainnet() -> Self

Returns the opbnb mainnet chain.

Source

pub const fn opbnb_testnet() -> Self

Returns the opbnb testnet chain.

Source

pub const fn ronin() -> Self

Returns the ronin mainnet chain.

Source

pub const fn taiko() -> Self

Returns the taiko mainnet chain.

Source

pub const fn taiko_hekla() -> Self

Returns the taiko hekla chain.

Source

pub const fn shimmer() -> Self

Returns the shimmer testnet chain.

Source

pub const fn flare() -> Self

Returns the flare mainnet chain.

Source

pub const fn flare_coston2() -> Self

Returns the flare testnet chain.

Source

pub const fn darwinia() -> Self

Returns the darwinia mainnet chain.

Source

pub const fn crab() -> Self

Returns the crab mainnet chain.

Source

pub const fn koi() -> Self

Returns the koi testnet chain.

Source

pub const fn immutable() -> Self

Returns the Immutable zkEVM mainnet chain.

Source

pub const fn immutable_testnet() -> Self

Returns the Immutable zkEVM testnet chain.

Source

pub const fn ink_sepolia() -> Self

Returns the koi testnet chain.

Source

pub const fn kind(&self) -> &ChainKind

Returns the kind of this chain.

Source

pub const fn into_kind(self) -> ChainKind

Returns the kind of this chain.

Source

pub const fn is_ethereum(&self) -> bool

Returns true if this chain is Ethereum or an Ethereum testnet.

Source

pub const fn is_optimism(self) -> bool

Returns true if the chain contains Optimism configuration.

Source

pub const fn is_arbitrum(self) -> bool

Returns true if the chain contains Arbitrum configuration.

Source

pub const fn named(self) -> Option<NamedChain>

Attempts to convert the chain into a named chain.

Source

pub const fn id(self) -> u64

The ID of the chain.

Source§

impl Chain

Methods delegated to NamedChain. Note that ChainKind::Id won’t be converted because it was already done at construction.

Source

pub const fn average_blocktime_hint(self) -> Option<Duration>

Returns the chain’s average blocktime, if applicable.

See NamedChain::average_blocktime_hint for more info.

Source

pub const fn is_legacy(self) -> bool

Returns whether the chain implements EIP-1559 (with the type 2 EIP-2718 transaction type).

See NamedChain::is_legacy for more info.

Source

pub const fn supports_shanghai(self) -> bool

Returns whether the chain supports the Shanghai hardfork.

See NamedChain::supports_shanghai for more info.

Source

pub const fn etherscan_urls(self) -> Option<(&'static str, &'static str)>

Returns the chain’s blockchain explorer and its API (Etherscan and Etherscan-like) URLs.

See NamedChain::etherscan_urls for more info.

Source

pub const fn etherscan_api_key_name(self) -> Option<&'static str>

Returns the chain’s blockchain explorer’s API key environment variable’s default name.

See NamedChain::etherscan_api_key_name for more info.

Source

pub fn etherscan_api_key(self) -> Option<String>

Available on crate feature std only.

Returns the chain’s blockchain explorer’s API key, from the environment variable with the name specified in etherscan_api_key_name.

See NamedChain::etherscan_api_key for more info.

Source

pub fn public_dns_network_protocol(self) -> Option<String>

Returns the address of the public DNS node list for the given chain.

See NamedChain::public_dns_network_protocol for more info.

Trait Implementations§

Source§

impl Clone for Chain

Source§

fn clone(&self) -> Chain

Returns a copy 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 Default for Chain

Source§

fn default() -> Self

Returns the “default value” for a type. 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<NamedChain> for Chain

Source§

fn from(id: NamedChain) -> 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 FromStr for Chain

Source§

type Err = ParseIntError

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
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<u64> for Chain

Source§

fn eq(&self, other: &u64) -> 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 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 PartialOrd<u64> for Chain

Source§

fn partial_cmp(&self, other: &u64) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl TryFrom<Chain> for NamedChain

Source§

type Error = <NamedChain as TryFrom<u64>>::Error

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

fn try_from(chain: Chain) -> Result<Self, Self::Error>

Performs the conversion.
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, dst: *mut T)

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

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> 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§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
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.