pub struct Chain(/* private fields */);
Expand description
Either a known NamedChain
or a EIP-155 chain ID.
Implementations§
Source§impl Chain
impl Chain
Sourcepub const fn from_named(named: NamedChain) -> Self
pub const fn from_named(named: NamedChain) -> Self
Creates a new Chain
by wrapping a NamedChain
.
Sourcepub fn from_id(id: u64) -> Self
pub fn from_id(id: u64) -> Self
Creates a new Chain
by wrapping a NamedChain
.
Sourcepub const fn from_id_unchecked(id: u64) -> Self
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.
Sourcepub const fn optimism_mainnet() -> Self
pub const fn optimism_mainnet() -> Self
Returns the optimism mainnet chain.
Sourcepub const fn optimism_goerli() -> Self
pub const fn optimism_goerli() -> Self
Returns the optimism goerli chain.
Sourcepub const fn optimism_sepolia() -> Self
pub const fn optimism_sepolia() -> Self
Returns the optimism sepolia chain.
Sourcepub const fn base_mainnet() -> Self
pub const fn base_mainnet() -> Self
Returns the base mainnet chain.
Sourcepub const fn base_goerli() -> Self
pub const fn base_goerli() -> Self
Returns the base goerli chain.
Sourcepub const fn base_sepolia() -> Self
pub const fn base_sepolia() -> Self
Returns the base sepolia chain.
Sourcepub const fn syndr_sepolia() -> Self
pub const fn syndr_sepolia() -> Self
Returns the syndr sepolia chain.
Sourcepub const fn fraxtal_testnet() -> Self
pub const fn fraxtal_testnet() -> Self
Returns the fraxtal testnet chain.
Sourcepub const fn blast_sepolia() -> Self
pub const fn blast_sepolia() -> Self
Returns the blast sepolia chain.
Sourcepub const fn linea_goerli() -> Self
pub const fn linea_goerli() -> Self
Returns the linea goerli chain.
Sourcepub const fn linea_sepolia() -> Self
pub const fn linea_sepolia() -> Self
Returns the linea sepolia chain.
Sourcepub const fn mode_sepolia() -> Self
pub const fn mode_sepolia() -> Self
Returns the mode sepolia chain.
Sourcepub const fn bsc_mainnet() -> Self
pub const fn bsc_mainnet() -> Self
Returns the bsc mainnet chain.
Sourcepub const fn bsc_testnet() -> Self
pub const fn bsc_testnet() -> Self
Returns the bsc testnet chain.
Sourcepub const fn opbnb_mainnet() -> Self
pub const fn opbnb_mainnet() -> Self
Returns the opbnb mainnet chain.
Sourcepub const fn opbnb_testnet() -> Self
pub const fn opbnb_testnet() -> Self
Returns the opbnb testnet chain.
Sourcepub const fn taiko_hekla() -> Self
pub const fn taiko_hekla() -> Self
Returns the taiko hekla chain.
Sourcepub const fn flare_coston2() -> Self
pub const fn flare_coston2() -> Self
Returns the flare testnet chain.
Sourcepub const fn immutable_testnet() -> Self
pub const fn immutable_testnet() -> Self
Returns the Immutable zkEVM testnet chain.
Sourcepub const fn ink_sepolia() -> Self
pub const fn ink_sepolia() -> Self
Returns the koi testnet chain.
Sourcepub const fn is_ethereum(&self) -> bool
pub const fn is_ethereum(&self) -> bool
Returns true
if this chain is Ethereum or an Ethereum testnet.
Sourcepub const fn is_optimism(self) -> bool
pub const fn is_optimism(self) -> bool
Returns true if the chain contains Optimism configuration.
Sourcepub const fn is_arbitrum(self) -> bool
pub const fn is_arbitrum(self) -> bool
Returns true if the chain contains Arbitrum configuration.
Sourcepub const fn named(self) -> Option<NamedChain>
pub const fn named(self) -> Option<NamedChain>
Attempts to convert the chain into a named chain.
Source§impl Chain
impl Chain
Methods delegated to NamedChain
. Note that ChainKind::Id
won’t be converted because it was
already done at construction.
Sourcepub const fn average_blocktime_hint(self) -> Option<Duration>
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.
Sourcepub const fn is_legacy(self) -> bool
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.
Sourcepub const fn supports_shanghai(self) -> bool
pub const fn supports_shanghai(self) -> bool
Returns whether the chain supports the Shanghai hardfork.
See NamedChain::supports_shanghai
for more info.
Sourcepub const fn etherscan_urls(self) -> Option<(&'static str, &'static str)>
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.
Sourcepub const fn etherscan_api_key_name(self) -> Option<&'static str>
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.
Sourcepub fn etherscan_api_key(self) -> Option<String>
Available on crate feature std
only.
pub fn etherscan_api_key(self) -> Option<String>
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.
Sourcepub fn public_dns_network_protocol(self) -> Option<String>
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 From<NamedChain> for Chain
impl From<NamedChain> for Chain
Source§fn from(id: NamedChain) -> Self
fn from(id: NamedChain) -> Self
Source§impl PartialOrd<u64> for Chain
impl PartialOrd<u64> for Chain
Source§impl TryFrom<Chain> for NamedChain
impl TryFrom<Chain> for NamedChain
impl Copy for Chain
impl Eq for Chain
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)