Struct alloy_chains::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 sepolia() -> Self

Returns the sepolia chain.

source

pub const fn holesky() -> Self

Returns the holesky chain.

source

pub const fn optimism_goerli() -> Self

Returns the optimism goerli chain.

source

pub const fn optimism_mainnet() -> Self

Returns the optimism mainnet chain.

source

pub const fn base_goerli() -> Self

Returns the base goerli chain.

source

pub const fn base_mainnet() -> Self

Returns the base mainnet chain.

source

pub const fn dev() -> Self

Returns the dev 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_optimism(self) -> bool

Returns true if the chain contains Optimism 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>

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

§

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 for Chain

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl TryFrom<Chain> for NamedChain

§

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 StructuralEq for Chain

source§

impl StructuralPartialEq for Chain

Auto Trait Implementations§

§

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 Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. 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 Twhere 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 Twhere T: Clone,

§

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 Twhere 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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.