dank_mids.brownie_patch package
Submodules
dank_mids.brownie_patch.call module
- dank_mids.brownie_patch.call.decode()
- dank_mids.brownie_patch.call.decode_output()
- dank_mids.brownie_patch.call.encode()
- dank_mids.brownie_patch.call.encode_input()
- dank_mids.brownie_patch.call.format_input_but_cache_checksums()
- dank_mids.brownie_patch.call.format_output_but_cache_checksums()
dank_mids.brownie_patch.contract module
- class dank_mids.brownie_patch.contract.Contract
Bases:
Contract
An extended version of brownie.Contract with additional functionality for Dank Mids.
This class provides lazy initialization of contract methods and supports asynchronous operations through Dank Mids middleware.
- __init__(*args, **kwargs)
Initialize the Contract instance.
This method sets up lazy initialization for contract methods.
- Return type:
None
- decode_input(calldata)
Decode input calldata for this contract.
- classmethod from_abi(name, address, abi, owner=None, persist=True)
Create a new Contract instance from an ABI.
This method allows for the creation of a Contract instance using a provided ABI, which is useful when working with contracts that are not in the project’s build files and not verified on a block explorer.
- Parameters:
name (str) – The name of the contract.
address (str) – The address of the deployed contract.
abi (List[dict]) – The ABI (Application Binary Interface) of the contract.
owner (AccountsType | None) – The account that owns this contract instance.
persist (bool) – Whether to persist the contract data to brownie’s local db for future use.
- Returns:
A new Contract instance.
- Return type:
- classmethod from_ethpm(name, manifest_uri, address=None, owner=None, persist=True)
Create a new Contract instance from an ethPM manifest.
This method allows for the creation of a Contract instance using an ethPM manifest, which is a standardized format for Ethereum smart contract packages.
- Parameters:
name (str) – The name of the contract.
manifest_uri (str) – The URI of the ethPM manifest.
address (str | None) – The address of the deployed contract (optional).
owner (AccountsType | None) – The account that owns this contract instance.
persist (bool) – Whether to persist the contract data to brownie’s local db for future use.
- Returns:
A new Contract instance.
- Return type:
- classmethod from_explorer(address, as_proxy_for=None, owner=None, silent=False, persist=True)
Create a new Contract instance by fetching the ABI from a block explorer.
This method is useful for interacting with contracts that are not part of the current project, as it automatically fetches the contract’s ABI from a block explorer.
- Parameters:
address (str) – The address of the deployed contract.
as_proxy_for (str | None) – The address of the implementation contract if this is a proxy contract.
owner (AccountsType | None) – The account that owns this contract instance.
silent (bool) – Whether to suppress console output during the process.
persist (bool) – Whether to persist the contract data to brownie’s db for future use.
- Returns:
A new Contract instance.
- Return type:
- get_method_object(calldata)
Given a calldata hex string, returns a ContractMethod object.
- Parameters:
calldata (str)
- Return type:
_ContractMethod | None
- classmethod get_solc_version(compiler_str, address)
Return the solc compiler version either from the passed compiler string or try to find the latest available patch semver compiler version.
- info()
Display NatSpec documentation for this contract.
- Return type:
None
- classmethod remove_deployment(address=None, alias=None)
Removes this contract from the internal deployments db with the passed address or alias.
- set_alias(alias, persist=True)
Apply a unique alias this object. The alias can be used to restore the object in future sessions.
- class dank_mids.brownie_patch.contract.EventName
A type representing the name of an event in a smart contract.
See also
brownie.network.contract.ContractEvents
: Brownie’s implementation of contract events.alias of
str
- class dank_mids.brownie_patch.contract.LogTopic
A type representing a log topic in Ethereum transactions.
See also
Web3.eth.get_logs()
: Web3.py method for retrieving logs.alias of
str
- class dank_mids.brownie_patch.contract.Method
A type representing the name of a method in a smart contract.
See also
brownie.network.contract.ContractMethod
: Brownie’s implementation of contract methods.alias of
str
- class dank_mids.brownie_patch.contract.Signature
A type representing the signature of a method in a smart contract.
alias of
str
- dank_mids.brownie_patch.contract.patch_contract(contract: Contract, w3: DankWeb3 | None = None) Contract
- dank_mids.brownie_patch.contract.patch_contract(contract: Contract | str, w3: DankWeb3 | None = None) Contract
Patch a contract with async and call batching functionalities.
- Parameters:
contract – The contract to patch.
w3 – Optional DankWeb3 instance.
- Returns:
The patched contract.
dank_mids.brownie_patch.overloaded module
dank_mids.brownie_patch.types module
- class dank_mids.brownie_patch.types.DankContractCall
Bases:
_DankMethod
,ContractCall
- __call__(**kwargs)
Call the contract method without broadcasting a transaction.
- Parameters:
args (Tuple) – Contract method inputs. You can optionally provide a dictionary of transaction properties as the last arg.
block_identifier (int | str | bytes, optional) – A block number or hash that the call is executed at. If not given, the latest block used. Raises ValueError if this value is too far in the past and you are not using an archival node.
override (dict, optional) – A mapping from addresses to balance, nonce, code, state, stateDiff overrides for the context of the call.
- Return type:
Contract method return value(s).
- __init__(address, abi, name, owner, natspec=None)
- call(*args, block_identifier=None, override=None)
Call the contract method without broadcasting a transaction.
- Parameters:
*args – Contract method inputs. You can optionally provide a dictionary of transaction properties as the last arg.
block_identifier (int | str | bytes, optional) – A block number or hash that the call is executed at. If not given, the latest block used. Raises ValueError if this value is too far in the past and you are not using an archival node.
override (dict, optional) – A mapping from addresses to balance, nonce, code, state, stateDiff overrides for the context of the call.
- Return type:
Contract method return value(s).
- async coroutine(*args, block_identifier=None, decimals=None, override=None)
Asynchronously call the contract method via dank mids and await the result.
- Parameters:
- Raises:
ValueError – If the override parameter is used, as state overrides are not supported.
- Returns:
The result of the contract method call.
- Return type:
_EVMType
- decode_input(hexstr)
Decode input call data for this method.
- Parameters:
hexstr (str) – Hexstring of input call data
- Return type:
Decoded values
- decode_output(hexstr)
Decode hexstring data returned by this method.
- Parameters:
hexstr (str) – Hexstring of returned call data
- Return type:
Decoded values
- encode_input(*args)
Generate encoded ABI data to call the method with the given arguments.
- estimate_gas(*args)
Estimate the gas cost for a transaction.
Raises VirtualMachineError if the transaction would revert.
- info()
Display NatSpec documentation for this method.
- Return type:
None
- async map(args, block_identifier=None, *, iter_args=False, decimals=None)
Asynchronously call the contract method with multiple sets of arguments.
This method allows for efficient batch calling of the contract method with different arguments.
- Parameters:
args (Iterable[Any]) – An iterable of argument sets to be passed to the method.
block_identifier (int | None) – The block number or identifier for the calls.
iter_args (bool) – True if you are passing an Iterable of Iterables, False otherwise.
decimals (int | None) – The number of decimal places by which to scale numeric results.
- Return type:
List[_EVMType]
- transact(*args, silent=False)
Broadcast a transaction that calls this contract method.
- property abi: dict
The ABI of the contract function.
This property provides access to the complete ABI dictionary of the function.
- natspec
The NatSpec documentation for the function.
- class dank_mids.brownie_patch.types.DankContractTx
Bases:
_DankMethod
,ContractTx
- __call__(*args, silent=False)
Broadcast a transaction that calls this contract method.
- __init__(address, abi, name, owner, natspec=None)
- call(*args, block_identifier=None, override=None)
Call the contract method without broadcasting a transaction.
- Parameters:
*args – Contract method inputs. You can optionally provide a dictionary of transaction properties as the last arg.
block_identifier (int | str | bytes, optional) – A block number or hash that the call is executed at. If not given, the latest block used. Raises ValueError if this value is too far in the past and you are not using an archival node.
override (dict, optional) – A mapping from addresses to balance, nonce, code, state, stateDiff overrides for the context of the call.
- Return type:
Contract method return value(s).
- async coroutine(*args, block_identifier=None, decimals=None, override=None)
Asynchronously call the contract method via dank mids and await the result.
- Parameters:
- Raises:
ValueError – If the override parameter is used, as state overrides are not supported.
- Returns:
The result of the contract method call.
- Return type:
_EVMType
- decode_input(hexstr)
Decode input call data for this method.
- Parameters:
hexstr (str) – Hexstring of input call data
- Return type:
Decoded values
- decode_output(hexstr)
Decode hexstring data returned by this method.
- Parameters:
hexstr (str) – Hexstring of returned call data
- Return type:
Decoded values
- encode_input(*args)
Generate encoded ABI data to call the method with the given arguments.
- estimate_gas(*args)
Estimate the gas cost for a transaction.
Raises VirtualMachineError if the transaction would revert.
- info()
Display NatSpec documentation for this method.
- Return type:
None
- async map(args, block_identifier=None, *, iter_args=False, decimals=None)
Asynchronously call the contract method with multiple sets of arguments.
This method allows for efficient batch calling of the contract method with different arguments.
- Parameters:
args (Iterable[Any]) – An iterable of argument sets to be passed to the method.
block_identifier (int | None) – The block number or identifier for the calls.
iter_args (bool) – True if you are passing an Iterable of Iterables, False otherwise.
decimals (int | None) – The number of decimal places by which to scale numeric results.
- Return type:
List[_EVMType]
- transact(*args, silent=False)
Broadcast a transaction that calls this contract method.
- property abi: dict
The ABI of the contract function.
This property provides access to the complete ABI dictionary of the function.
- natspec
The NatSpec documentation for the function.
- class dank_mids.brownie_patch.types.DankOverloadedMethod
Bases:
OverloadedMethod
,_DankMethodMixin
[_T
]- __call__(*args, block_identifier=None, override=None)
Call self as a function.
- call(*args, block_identifier=None, override=None)
Call the contract method without broadcasting a transaction.
The specific function called is chosen based on the number of arguments given. If more than one function exists with this number of arguments, a ValueError is raised.
- Parameters:
*args – Contract method inputs. You can optionally provide a dictionary of transaction properties as the last arg.
block_identifier (int | str | bytes, optional) – A block number or hash that the call is executed at. If not given, the latest block used. Raises ValueError if this value is too far in the past and you are not using an archival node.
override (dict, optional) – A mapping from addresses to balance, nonce, code, state, stateDiff overrides for the context of the call.
- Return type:
Contract method return value(s).
- coroutine()
Asynchronously call the contract method with the given arguments.
This method is the core of the asynchronous functionality while using dank_mids with eth_brownie.
- Parameters:
*args – Variable length argument list for the contract method.
block_identifier – The block number or identifier for the call.
decimals – The number of decimals by which to scale numeric results.
override – Optional parameters to override chain state in the call.
Note
This is a generic method and should be implemented in subclasses.
- decode_input(hexstr)
Decode input call data for this method.
- Parameters:
hexstr (str) – Hexstring of input call data
- Return type:
Decoded values
- decode_output(hexstr)
Decode hexstring data returned by this method.
- Parameters:
hexstr (str) – Hexstring of returned call data
- Return type:
Decoded values
- encode_input(*args)
Generate encoded ABI data to call the method with the given arguments.
- info()
Display NatSpec documentation for this method.
- Return type:
None
- async map(args, block_identifier=None, *, iter_args=False, decimals=None)
Asynchronously call the contract method with multiple sets of arguments.
This method allows for efficient batch calling of the contract method with different arguments.
- Parameters:
args (Iterable[Any]) – An iterable of argument sets to be passed to the method.
block_identifier (int | None) – The block number or identifier for the calls.
iter_args (bool) – True if you are passing an Iterable of Iterables, False otherwise.
decimals (int | None) – The number of decimal places by which to scale numeric results.
- Return type:
List[_EVMType]
- transact(*args)
Broadcast a transaction that calls this contract method.
The specific function called is chosen based on the number of arguments given. If more than one function exists with this number of arguments, a ValueError is raised.
- Parameters:
*args (Tuple) – Contract method inputs. You can optionally provide a dictionary of transaction properties as the last arg.
- Returns:
Object representing the broadcasted transaction.
- Return type:
TransactionReceipt
- property abi: dict
The ABI of the contract function.
This property provides access to the complete ABI dictionary of the function.
- methods: Dict
Module contents
- class dank_mids.brownie_patch.Contract
Bases:
Contract
An extended version of brownie.Contract with additional functionality for Dank Mids.
This class provides lazy initialization of contract methods and supports asynchronous operations through Dank Mids middleware.
- __init__(*args, **kwargs)
Initialize the Contract instance.
This method sets up lazy initialization for contract methods.
- Return type:
None
- decode_input(calldata)
Decode input calldata for this contract.
- classmethod from_abi(name, address, abi, owner=None, persist=True)
Create a new Contract instance from an ABI.
This method allows for the creation of a Contract instance using a provided ABI, which is useful when working with contracts that are not in the project’s build files and not verified on a block explorer.
- Parameters:
name (str) – The name of the contract.
address (str) – The address of the deployed contract.
abi (List[dict]) – The ABI (Application Binary Interface) of the contract.
owner (AccountsType | None) – The account that owns this contract instance.
persist (bool) – Whether to persist the contract data to brownie’s local db for future use.
- Returns:
A new Contract instance.
- Return type:
- classmethod from_ethpm(name, manifest_uri, address=None, owner=None, persist=True)
Create a new Contract instance from an ethPM manifest.
This method allows for the creation of a Contract instance using an ethPM manifest, which is a standardized format for Ethereum smart contract packages.
- Parameters:
name (str) – The name of the contract.
manifest_uri (str) – The URI of the ethPM manifest.
address (str | None) – The address of the deployed contract (optional).
owner (AccountsType | None) – The account that owns this contract instance.
persist (bool) – Whether to persist the contract data to brownie’s local db for future use.
- Returns:
A new Contract instance.
- Return type:
- classmethod from_explorer(address, as_proxy_for=None, owner=None, silent=False, persist=True)
Create a new Contract instance by fetching the ABI from a block explorer.
This method is useful for interacting with contracts that are not part of the current project, as it automatically fetches the contract’s ABI from a block explorer.
- Parameters:
address (str) – The address of the deployed contract.
as_proxy_for (str | None) – The address of the implementation contract if this is a proxy contract.
owner (AccountsType | None) – The account that owns this contract instance.
silent (bool) – Whether to suppress console output during the process.
persist (bool) – Whether to persist the contract data to brownie’s db for future use.
- Returns:
A new Contract instance.
- Return type:
- get_method_object(calldata)
Given a calldata hex string, returns a ContractMethod object.
- Parameters:
calldata (str)
- Return type:
_ContractMethod | None
- classmethod get_solc_version(compiler_str, address)
Return the solc compiler version either from the passed compiler string or try to find the latest available patch semver compiler version.
- info()
Display NatSpec documentation for this contract.
- Return type:
None
- classmethod remove_deployment(address=None, alias=None)
Removes this contract from the internal deployments db with the passed address or alias.
- set_alias(alias, persist=True)
Apply a unique alias this object. The alias can be used to restore the object in future sessions.
- class dank_mids.brownie_patch.DankContractCall
Bases:
_DankMethod
,ContractCall
- __call__(**kwargs)
Call the contract method without broadcasting a transaction.
- Parameters:
args (Tuple) – Contract method inputs. You can optionally provide a dictionary of transaction properties as the last arg.
block_identifier (int | str | bytes, optional) – A block number or hash that the call is executed at. If not given, the latest block used. Raises ValueError if this value is too far in the past and you are not using an archival node.
override (dict, optional) – A mapping from addresses to balance, nonce, code, state, stateDiff overrides for the context of the call.
- Return type:
Contract method return value(s).
- __init__(address, abi, name, owner, natspec=None)
- call(*args, block_identifier=None, override=None)
Call the contract method without broadcasting a transaction.
- Parameters:
*args – Contract method inputs. You can optionally provide a dictionary of transaction properties as the last arg.
block_identifier (int | str | bytes, optional) – A block number or hash that the call is executed at. If not given, the latest block used. Raises ValueError if this value is too far in the past and you are not using an archival node.
override (dict, optional) – A mapping from addresses to balance, nonce, code, state, stateDiff overrides for the context of the call.
- Return type:
Contract method return value(s).
- async coroutine(*args, block_identifier=None, decimals=None, override=None)
Asynchronously call the contract method via dank mids and await the result.
- Parameters:
- Raises:
ValueError – If the override parameter is used, as state overrides are not supported.
- Returns:
The result of the contract method call.
- Return type:
_EVMType
- decode_input(hexstr)
Decode input call data for this method.
- Parameters:
hexstr (str) – Hexstring of input call data
- Return type:
Decoded values
- decode_output(hexstr)
Decode hexstring data returned by this method.
- Parameters:
hexstr (str) – Hexstring of returned call data
- Return type:
Decoded values
- encode_input(*args)
Generate encoded ABI data to call the method with the given arguments.
- estimate_gas(*args)
Estimate the gas cost for a transaction.
Raises VirtualMachineError if the transaction would revert.
- info()
Display NatSpec documentation for this method.
- Return type:
None
- async map(args, block_identifier=None, *, iter_args=False, decimals=None)
Asynchronously call the contract method with multiple sets of arguments.
This method allows for efficient batch calling of the contract method with different arguments.
- Parameters:
args (Iterable[Any]) – An iterable of argument sets to be passed to the method.
block_identifier (int | None) – The block number or identifier for the calls.
iter_args (bool) – True if you are passing an Iterable of Iterables, False otherwise.
decimals (int | None) – The number of decimal places by which to scale numeric results.
- Return type:
List[_EVMType]
- transact(*args, silent=False)
Broadcast a transaction that calls this contract method.
- property abi: dict
The ABI of the contract function.
This property provides access to the complete ABI dictionary of the function.
- natspec
The NatSpec documentation for the function.
- class dank_mids.brownie_patch.DankContractTx
Bases:
_DankMethod
,ContractTx
- __call__(*args, silent=False)
Broadcast a transaction that calls this contract method.
- __init__(address, abi, name, owner, natspec=None)
- call(*args, block_identifier=None, override=None)
Call the contract method without broadcasting a transaction.
- Parameters:
*args – Contract method inputs. You can optionally provide a dictionary of transaction properties as the last arg.
block_identifier (int | str | bytes, optional) – A block number or hash that the call is executed at. If not given, the latest block used. Raises ValueError if this value is too far in the past and you are not using an archival node.
override (dict, optional) – A mapping from addresses to balance, nonce, code, state, stateDiff overrides for the context of the call.
- Return type:
Contract method return value(s).
- async coroutine(*args, block_identifier=None, decimals=None, override=None)
Asynchronously call the contract method via dank mids and await the result.
- Parameters:
- Raises:
ValueError – If the override parameter is used, as state overrides are not supported.
- Returns:
The result of the contract method call.
- Return type:
_EVMType
- decode_input(hexstr)
Decode input call data for this method.
- Parameters:
hexstr (str) – Hexstring of input call data
- Return type:
Decoded values
- decode_output(hexstr)
Decode hexstring data returned by this method.
- Parameters:
hexstr (str) – Hexstring of returned call data
- Return type:
Decoded values
- encode_input(*args)
Generate encoded ABI data to call the method with the given arguments.
- estimate_gas(*args)
Estimate the gas cost for a transaction.
Raises VirtualMachineError if the transaction would revert.
- info()
Display NatSpec documentation for this method.
- Return type:
None
- async map(args, block_identifier=None, *, iter_args=False, decimals=None)
Asynchronously call the contract method with multiple sets of arguments.
This method allows for efficient batch calling of the contract method with different arguments.
- Parameters:
args (Iterable[Any]) – An iterable of argument sets to be passed to the method.
block_identifier (int | None) – The block number or identifier for the calls.
iter_args (bool) – True if you are passing an Iterable of Iterables, False otherwise.
decimals (int | None) – The number of decimal places by which to scale numeric results.
- Return type:
List[_EVMType]
- transact(*args, silent=False)
Broadcast a transaction that calls this contract method.
- property abi: dict
The ABI of the contract function.
This property provides access to the complete ABI dictionary of the function.
- natspec
The NatSpec documentation for the function.
- class dank_mids.brownie_patch.DankOverloadedMethod
Bases:
OverloadedMethod
,_DankMethodMixin
[_T
]- __call__(*args, block_identifier=None, override=None)
Call self as a function.
- call(*args, block_identifier=None, override=None)
Call the contract method without broadcasting a transaction.
The specific function called is chosen based on the number of arguments given. If more than one function exists with this number of arguments, a ValueError is raised.
- Parameters:
*args – Contract method inputs. You can optionally provide a dictionary of transaction properties as the last arg.
block_identifier (int | str | bytes, optional) – A block number or hash that the call is executed at. If not given, the latest block used. Raises ValueError if this value is too far in the past and you are not using an archival node.
override (dict, optional) – A mapping from addresses to balance, nonce, code, state, stateDiff overrides for the context of the call.
- Return type:
Contract method return value(s).
- coroutine()
Asynchronously call the contract method with the given arguments.
This method is the core of the asynchronous functionality while using dank_mids with eth_brownie.
- Parameters:
*args – Variable length argument list for the contract method.
block_identifier – The block number or identifier for the call.
decimals – The number of decimals by which to scale numeric results.
override – Optional parameters to override chain state in the call.
Note
This is a generic method and should be implemented in subclasses.
- decode_input(hexstr)
Decode input call data for this method.
- Parameters:
hexstr (str) – Hexstring of input call data
- Return type:
Decoded values
- decode_output(hexstr)
Decode hexstring data returned by this method.
- Parameters:
hexstr (str) – Hexstring of returned call data
- Return type:
Decoded values
- encode_input(*args)
Generate encoded ABI data to call the method with the given arguments.
- info()
Display NatSpec documentation for this method.
- Return type:
None
- async map(args, block_identifier=None, *, iter_args=False, decimals=None)
Asynchronously call the contract method with multiple sets of arguments.
This method allows for efficient batch calling of the contract method with different arguments.
- Parameters:
args (Iterable[Any]) – An iterable of argument sets to be passed to the method.
block_identifier (int | None) – The block number or identifier for the calls.
iter_args (bool) – True if you are passing an Iterable of Iterables, False otherwise.
decimals (int | None) – The number of decimal places by which to scale numeric results.
- Return type:
List[_EVMType]
- transact(*args)
Broadcast a transaction that calls this contract method.
The specific function called is chosen based on the number of arguments given. If more than one function exists with this number of arguments, a ValueError is raised.
- Parameters:
*args (Tuple) – Contract method inputs. You can optionally provide a dictionary of transaction properties as the last arg.
- Returns:
Object representing the broadcasted transaction.
- Return type:
TransactionReceipt
- property abi: dict
The ABI of the contract function.
This property provides access to the complete ABI dictionary of the function.
- methods: Dict
- natspec: Dict
- dank_mids.brownie_patch.patch_contract(contract, w3=None)
Patch a contract with async and call batching functionalities.