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
The Backend class handles comms with the local fork network.
Initialize the class.
Parameters
- port: Port to use for the forked chain. If None, a free port will be found.
Submit a contract read-only call.
Parameters
- function: Web3.py contract function to call.
- function_params: Parameters to pass to the contract function.
- call_params: Call parameters.
Submit a contract write transaction.
Parameters
- function: Web3.py contract function to call.
- function_params: Parameters to pass to the contract function.
- transact_params: Transaction parameters.
Raises
- Exception: if called from the live backend, due to the polling frequency being very high
Submit a contract write transaction.
Parameters
- function: Web3.py contract function to call.
- function_params: Parameters to pass to the contract function.
- transact_params: Transaction parameters.
Instantiate and connect to the local network.
Parameters
- date_range: simulation date range.
- backend: Type of backend to use. Can be one of ['hardhat', 'anvil'].
Load the state of the local forked network.
Requires save_state()
to have been called first.
Get a web3 contract object directly via web3.
Parameters
- address: deployed contract address.
- abi: contract abi ID.
Register a contract that is already deployed at some address.
Parameters
- name: dojo contract name.
- contract: the deployed contract.
Raises
- ValueError: If contract is already registered.
Get a web3 contract object.
Parameters
- name: dojo contract name.
Raises
- ValueError: If contract is not registered.
Set the code at the specified address immediately, without mining.
Set the storage at the specified addresses immediately without mining.
Deploy an existing live contract to the dojo network.
Parameters
- protocol: protocol name (e.g. UniswapV3, Tokens etc.).
- name: dojo contract name.
- args: contract constructor arguments.
Returns
the deployed contract
Lookup a contract name by address or vice versa.
Parameters
- name_or_address: contract name or address.
Mint tokens for local backend.
Get the timestamp of a block.
This method is very slow, consider batching requests. batch_block_to_datetime
is
currently under development.
Get the datetime of a block.
This method is very slow, consider batching requests. batch_block_to_datetime
is
currently under development.
The ForkedBackend class handles comms with a forked network.
Initialize the class.
Parameters
- port: Port to use for the forked chain. If None, a free port will be found.
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.
The LocalBackend class handles comms with a local network.
Initialize the class.
Parameters
- port: Port to use for the forked chain. If None, a free port will be found.
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.
The live backend connects to a live network.
Instantiate and connect to a live network.
Parameters
- date_range: simulation date range.
- backend: Type of backend to use. Can be one of 'hardhat'.
Submit a contract read-only call.
Parameters
- function: Web3.py contract function to call.
- function_params: Parameters to pass to the contract function.
- call_params: Call parameters.
Submit a contract write transaction.
Parameters
- function: Web3.py contract function to call.
- function_params: Parameters to pass to the contract function.
- transact_params: Transaction parameters.