dojo.network

Network manages everything related to blockchain forking and connection.

This includes the retrieval of contract objects from the blockchain network. And anything related to brownie

class ForkedBackend(dojo.network.base_backend.BaseBackend):

The ForkedBackend class handles comms with a forked network.

ForkedBackend(chain: dojo.common.Chain, port: Optional[int] = None)

Initialize the class.

Parameters
  • port: Port to use for the forked chain. If None, a free port will be found.
def connect( self, date_range: tuple[datetime.datetime, datetime.datetime], backend: str = 'anvil') -> None:

Instantiate and connect to the dojo network.

Parameters
  • date_range: simulation date range.
  • backend: Type of backend to use. Can be one of 'hardhat' or 'anvil'.
Raises
  • ValueError: if requested backend is not supported.
def mint_token(self, token: str, quantity: Union[int, decimal.Decimal]) -> None:

Empty function for minting tokens on forked backend.

class LocalBackend(dojo.network.base_backend.BaseBackend):

The LocalBackend class handles comms with a local network.

LocalBackend(*, chain: dojo.common.Chain, port: Optional[int] = None)

Initialize the class.

Parameters
  • port: Port to use for the forked chain. If None, a free port will be found.
def connect( self, date_range: tuple[datetime.datetime, datetime.datetime], backend: str = 'anvil') -> None:

Instantiate and connect to the dojo network.

Parameters
  • date_range: simulation date range.
  • backend: Type of backend to use. Can be one of 'hardhat'.
Raises
  • ValueError: if requested backend is not supported.
def mint_token(self, token: str, quantity: Union[int, decimal.Decimal]) -> None:

Mint tokens to the account that deployed the contract.

Parameters
  • token: Name of the token to mint.
  • quantity: quantity to mint in human or machine readable format.