Skip to content

Types

ether.types.AnyAddress module-attribute

AnyAddress = Union[Address, HexAddress, ChecksumAddress, bytes, str]

ether.types.TokenAmount module-attribute

TokenAmount = Union[Wei, int]

ether.types.Network

Bases: BaseModel

The Network class represents an Ethereum-based network configuration.

ATTRIBUTE DESCRIPTION
name

The name of the network (e.g., "Ethereum", "Arbitrum").

TYPE: str

rpc

The RPC URL for interacting with the network.

TYPE: str

token

The network's native token (e.g., "ETH", "BNB").

TYPE: str

chain_id

The chain ID for the network. If not provided, it will be added automatically, when passing network to wallet.

TYPE: Union[PositiveInt, None]

explorer

The URL for the blockchain explorer.

TYPE: Union[HttpUrl, None]

Example
from ether import Wallet, Network

network = Network(
  name='BOB',
  rpc='https://bob.drpc.org',
  token='ETH',
  explorer='https://explorer.gobob.xyz'
)

custom_wallet = Wallet('0xPrivateKey', network)

ether.types.Token

Bases: BaseModel

The Token class represents an ERC-20 token.

ATTRIBUTE DESCRIPTION
address

The address of the token contract.

TYPE: ChecksumAddress

symbol

The token's symbol (e.g., "ETH", "USDT").

TYPE: str

decimals

The number of decimal places the token supports.

TYPE: int

Example
from ether import Wallet

wallet = Wallet('0xPrivateKey', 'Ethereum')

# Token details
token_address = '0xTokenAddressHere'
token = wallet.get_token(token_address)

print(f"Token {token.symbol} is loaded!")