Eth::Chain
Encapsulates Eth::Chain IDs and utilities for EIP-155 compatibility.
Constants
Chain ID for Arbitrum mainnet.
Chain ID for Ethereum Classic mainnet.
Chain ID for Ethereum mainnet.
Chain ID for Expanse mainnet.
Chain ID for Gnosis mainnet.
Chain ID for Goerli testnet.
Chain ID for Arbitrum Nitro Goerli testnet.
Chain ID for Optimistic Goerli testnet.
Chain ID for Holesovice testnet.
Chain ID for Kotti testnet.
Chain ID for Kovan testnet.
Chain ID for Optimistik Kovan testnet.
Chain ID for Morden (Ethereum) testnet.
Chain ID for Morden (Classic) testnet.
Chain ID for Mordor testnet.
Chain ID for the Polygon Mumbai testnet.
Chain ID for Optimistic Ethereum mainnet.
Chain ID for POA Network mainnet.
Chain ID for the Polygon Matic mainnet.
Chain ID for the geth private network preset.
Chain ID for Rinkeby testnet.
Chain ID for Arbitrum Rinkeby testnet.
Chain ID for Ropsten testnet.
Chain ID for Sepolia testnet.
Chain ID for Arbitrum xDAI testnet.
Instance methods
Checks if a provided v belongs to a Ledger wallet signature without
EIP-155 replay protection.
Parameters:
v(Int32): the signature'svvalue.
Chain.ledger? 0
# => true
Checks if a provided v belongs to a legacy signature without
EIP-155 replay protection.
Parameters:
v(Int32): the signature'svvalue.
Chain.legacy? 27
# => true
Converts a provided v value to an EIP-155 chain ID. This does not
work for legacy signatures with v < 36 and return nil in that
case.
Parameters:
v(Int32): the signature'svvalue.
Chain.to_chain_id 38
# => 1
Converts a provided v value to an ECDSA recovery ID for the
given EIP-155 chain ID.
Parameters:
v(Int32): the signature'svvalue.chain_id(Int32): the chain ID the signatrue was generated on (default:ETHEREUM).
Raises an exception if the v value does not match the chain ID.
Chain.to_recovery_id 38
# => 1
Converts a provided recovery ID to the according v for signatures
with EIP-155 replay protection.
Parameters:
recovery_id(Int32): the recovery ID.chain_id(Int32): the chain ID the signatrue was generated on.
Chain.to_v(1, Chain::ETHEREUM)
# => 38
Converts a provided recovery ID to the according v for legacy
signatures without EIP-155 replay protection.
Parameters:
recovery_id(Int32): the recovery ID.
Chain.to_v 1
# => 28