_Networks
¶
- class moccasin.config._Networks(toml_data: dict, project_root: Path)¶
Bases:
object
A container class that manages network configurations defined in the
moccasin.toml
file.This class parses and validates network-related settings from the configuration file, handling both default network settings and network-specific overrides. It manages contract deployments, network connections, and explorer configurations for each network.
- Variables:
_networks (dict[str, Network]) – Dictionary mapping network names to their Network objects
_default_named_contracts (dict[str, NamedContract]) – Default contract configurations that apply across all networks
_overriden_active_network (Network | None) – Currently active network if manually overridden
default_db_path (Path) – Default path for the database storage
default_network_name (str) – Name of the default network to use
- default_db_path: Path¶
- default_network_name: str¶
- get_networks() dict[str, Network] ¶
Return the networks.
- Returns:
The networks
- Return type:
dict[str, Network]
- get_default_db_path() Path ¶
Return the default database path.
- Returns:
The default database path
- Return type:
Path
- get_network(network_name_or_id: str | int) Network ¶
Return a network by name or chain ID.
- Parameters:
network_name_or_id (str | int) – The name or chain ID of the network
- Returns:
The network
- Return type:
- get_network_by_chain_id(chain_id: int) Network ¶
Return a network by chain ID.
- Parameters:
chain_id (int) – The chain ID of the network
- Returns:
The network
- Return type:
- get_network_by_name(alias: str) Network ¶
Return a network by name.
- Parameters:
alias (str) – The name of the network
- Returns:
The network
- Return type:
- get_or_deploy_named_contract(*args, **kwargs) VyperContract | ZksyncContract | ABIContract ¶
Return a contract by name or deploy it if it’s not found.
- Parameters:
args (tuple) – The arguments to pass to the get_or_deploy_named_contract method
kwargs (dict) – The keyword arguments to pass to the get_or_deploy_named_contract method
- Returns:
The contract
- Return type:
VyperContract | ZksyncContract | ABIContract
- set_active_network(name_of_network_or_network: str | Network, activate_boa=True, **kwargs) Network ¶
Set the active network.
- activate_boa()¶
Activate boa on the active network by creating and setting the boa env.