dank_mids.brownie_patch package

Submodules

dank_mids.brownie_patch.call module

dank_mids.brownie_patch.call.decode(self, data)
async dank_mids.brownie_patch.call.decode_output(call, data)
Parameters:
Return type:

Any

dank_mids.brownie_patch.call.encode(self, *args)

A lambda function that encodes input data for contract calls. It uses the BROWNIE_ENCODER_PROCESSES to run the __encode_input function asynchronously.

Parameters:
  • self – The contract method instance.

  • *args – The arguments to be encoded.

Returns:

The encoded input data for the contract call.

async dank_mids.brownie_patch.call.encode_input(call, len_inputs, get_request_data, *args)
Parameters:

call (ContractCall)

Return type:

HexStr

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.

balance()

Returns the current ether balance of the contract, in wei.

Return type:

Wei

decode_input(calldata)

Decode input calldata for this contract.

Parameters:

calldata (str | bytes) – Calldata for a call to this contract

Returns:

  • str – Signature of the function that was called

  • Any – Decoded input arguments

Return type:

Tuple[str, Any]

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:

Contract

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:

Contract

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:

Contract

get_method(calldata)
Parameters:

calldata (str)

Return type:

str | None

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.

Parameters:
  • compiler_str (str) – The compiler string passed from the contract metadata.

  • address (str) – The contract address to check for.

Return type:

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.

Parameters:
  • address (str | None) – An address to apply

  • alias (str | None) – An alias to apply

Return type:

Tuple[Dict | None, Dict | None]

set_alias(alias, persist=True)

Apply a unique alias this object. The alias can be used to restore the object in future sessions.

Parameters:
  • alias (str | None) – An alias to apply. If None, any existing alias is removed.

  • persist (bool)

Return type:

None

property abi: List
property alias: str | None
signatures: Dict[Method, Signature]

A dictionary mapping method names to their corresponding signatures.

topics: Dict[str, str]

A dictionary mapping event names to their corresponding topics.

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

A brownie.network.contract.ContractCall subclass with async support via the coroutine method.

It uses less memory than a ContractTx by using __slots__ along with the FunctionABI singleton to hold the function abi and related logic.

You can await this object directly to call the contract method with no arguments at the latest block.

__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)
Parameters:
  • address (str)

  • abi (Dict)

  • name (str)

  • owner (AccountsType | None)

  • natspec (Dict | None)

Return type:

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:
  • *args (-) –

    The arguments for the contract method.

  • block_identifier (-) – The block at which the chain will be read. If not provided, will read the chain at latest block.

  • decimals (-) – if provided, the output will be result / 10 ** decimals

  • *args

  • override (Dict[str, str] | None)

Returns:

  • Whatever the node sends back as the output for this contract method.

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.

Parameters:

*args (Tuple) – Contract method inputs

Returns:

Hexstring of encoded ABI data

Return type:

str

estimate_gas(*args)

Estimate the gas cost for a transaction.

Raises VirtualMachineError if the transaction would revert.

Parameters:

*args (Tuple) – Contract method inputs

Returns:

Estimated gas value in wei.

Return type:

int

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.

Returns:

A list of results from calling the method with each set of arguments.

Return type:

List[_EVMType]

transact(*args, silent=False)

Broadcast a transaction that calls this contract method.

Parameters:
  • *args (Tuple) – Contract method inputs. You can optionally provide a dictionary of transaction properties as the last arg.

  • silent (bool)

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.

natspec

The NatSpec documentation for the function.

property payable: bool
property signature: str

The function signature.

This property returns the unique signature of the contract function, which is used to identify the function in transactions.

class dank_mids.brownie_patch.types.DankContractTx

Bases: _DankMethod, ContractTx

A brownie.network.contract.ContractTx subclass with async support via the coroutine method.

It uses less memory than a ContractTx by using __slots__ along with the FunctionABI singleton to hold the function abi and related logic.

You can await this object directly to call the contract method with no arguments at the latest block.

__call__(*args, silent=False)

Broadcast a transaction that calls this contract method.

Parameters:
  • *args (Tuple) – Contract method inputs. You can optionally provide a dictionary of transaction properties as the last arg.

  • silent (bool)

Returns:

Object representing the broadcasted transaction.

Return type:

TransactionReceipt

__init__(address, abi, name, owner, natspec=None)
Parameters:
  • address (str)

  • abi (Dict)

  • name (str)

  • owner (AccountsType | None)

  • natspec (Dict | None)

Return type:

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:
  • *args (-) –

    The arguments for the contract method.

  • block_identifier (-) – The block at which the chain will be read. If not provided, will read the chain at latest block.

  • decimals (-) – if provided, the output will be result / 10 ** decimals

  • *args

  • override (Dict[str, str] | None)

Returns:

  • Whatever the node sends back as the output for this contract method.

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.

Parameters:

*args (Tuple) – Contract method inputs

Returns:

Hexstring of encoded ABI data

Return type:

str

estimate_gas(*args)

Estimate the gas cost for a transaction.

Raises VirtualMachineError if the transaction would revert.

Parameters:

*args (Tuple) – Contract method inputs

Returns:

Estimated gas value in wei.

Return type:

int

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.

Returns:

A list of results from calling the method with each set of arguments.

Return type:

List[_EVMType]

transact(*args, silent=False)

Broadcast a transaction that calls this contract method.

Parameters:
  • *args (Tuple) – Contract method inputs. You can optionally provide a dictionary of transaction properties as the last arg.

  • silent (bool)

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.

natspec

The NatSpec documentation for the function.

property payable: bool
property signature: str

The function signature.

This property returns the unique signature of the contract function, which is used to identify the function in transactions.

class dank_mids.brownie_patch.types.DankOverloadedMethod

Bases: OverloadedMethod, _DankMethodMixin

A brownie.network.contract.OverloadedMethod subclass with async support via the coroutine method.

It uses less memory than a OverloadedMethod by using __slots__ along with the FunctionABI singleton to hold the function abi and related logic.

You can await this object directly to call the contract method with no arguments at the latest block.

__call__(*args, block_identifier=None, override=None)

Call self as a function.

Parameters:
Return type:

Any

__getitem__(key)
Parameters:

key (Tuple | str)

Return type:

_ContractMethod

__init__(address, name, owner)
Parameters:
  • address (str)

  • name (str)

  • owner (AccountsType | None)

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).

async coroutine(*args, block_identifier=None, decimals=None, override=None)

Asynchronously call the contract method via dank mids and await the result.

Parameters:
  • *args (-) –

    The arguments for the contract method.

  • block_identifier (-) – The block at which the chain will be read. If not provided, will read the chain at latest block.

  • decimals (-) – if provided, the output will be result / 10 ** decimals

  • *args

  • override (Dict[str, str] | None)

Returns:

  • Whatever the node sends back as the output for this contract method.

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.

Parameters:

*args (Tuple) – Contract method inputs

Returns:

Hexstring of encoded ABI data

Return type:

str

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.

Returns:

A list of results from calling the method with each set of arguments.

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[Tuple[str, ...], DankContractCall | DankContractTx]
natspec: Dict
property signature: str

The function signature.

This property returns the unique signature of the contract function, which is used to identify the function in transactions.

dank_mids.brownie_patch.types.ContractMethod

Type alias for Brownie contract methods.

alias of ContractCall | ContractTx | OverloadedMethod

dank_mids.brownie_patch.types.DankContractMethod

These are ContractMethod objects with async support via an added coroutine method.

They use less memory than ContractMethod objects by using FunctionABI singleton to hold the function abi and related logic.

You can await this object directly to call the contract method with no arguments at the latest block.

alias of DankContractCall | DankContractTx | DankOverloadedMethod

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.

balance()

Returns the current ether balance of the contract, in wei.

Return type:

Wei

decode_input(calldata)

Decode input calldata for this contract.

Parameters:

calldata (str | bytes) – Calldata for a call to this contract

Returns:

  • str – Signature of the function that was called

  • Any – Decoded input arguments

Return type:

Tuple[str, Any]

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:

Contract

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:

Contract

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:

Contract

get_method(calldata)
Parameters:

calldata (str)

Return type:

str | None

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.

Parameters:
  • compiler_str (str) – The compiler string passed from the contract metadata.

  • address (str) – The contract address to check for.

Return type:

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.

Parameters:
  • address (str | None) – An address to apply

  • alias (str | None) – An alias to apply

Return type:

Tuple[Dict | None, Dict | None]

set_alias(alias, persist=True)

Apply a unique alias this object. The alias can be used to restore the object in future sessions.

Parameters:
  • alias (str | None) – An alias to apply. If None, any existing alias is removed.

  • persist (bool)

Return type:

None

property abi: List
property alias: str | None
signatures: Dict[Method, Signature]

A dictionary mapping method names to their corresponding signatures.

topics: Dict[str, str]

A dictionary mapping event names to their corresponding topics.

class dank_mids.brownie_patch.DankContractCall

Bases: _DankMethod, ContractCall

A brownie.network.contract.ContractCall subclass with async support via the coroutine method.

It uses less memory than a ContractTx by using __slots__ along with the FunctionABI singleton to hold the function abi and related logic.

You can await this object directly to call the contract method with no arguments at the latest block.

__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)
Parameters:
  • address (str)

  • abi (Dict)

  • name (str)

  • owner (AccountsType | None)

  • natspec (Dict | None)

Return type:

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:
  • *args (-) –

    The arguments for the contract method.

  • block_identifier (-) – The block at which the chain will be read. If not provided, will read the chain at latest block.

  • decimals (-) – if provided, the output will be result / 10 ** decimals

  • *args

  • override (Dict[str, str] | None)

Returns:

  • Whatever the node sends back as the output for this contract method.

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.

Parameters:

*args (Tuple) – Contract method inputs

Returns:

Hexstring of encoded ABI data

Return type:

str

estimate_gas(*args)

Estimate the gas cost for a transaction.

Raises VirtualMachineError if the transaction would revert.

Parameters:

*args (Tuple) – Contract method inputs

Returns:

Estimated gas value in wei.

Return type:

int

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.

Returns:

A list of results from calling the method with each set of arguments.

Return type:

List[_EVMType]

transact(*args, silent=False)

Broadcast a transaction that calls this contract method.

Parameters:
  • *args (Tuple) – Contract method inputs. You can optionally provide a dictionary of transaction properties as the last arg.

  • silent (bool)

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.

natspec

The NatSpec documentation for the function.

property payable: bool
property signature: str

The function signature.

This property returns the unique signature of the contract function, which is used to identify the function in transactions.

class dank_mids.brownie_patch.DankContractTx

Bases: _DankMethod, ContractTx

A brownie.network.contract.ContractTx subclass with async support via the coroutine method.

It uses less memory than a ContractTx by using __slots__ along with the FunctionABI singleton to hold the function abi and related logic.

You can await this object directly to call the contract method with no arguments at the latest block.

__call__(*args, silent=False)

Broadcast a transaction that calls this contract method.

Parameters:
  • *args (Tuple) – Contract method inputs. You can optionally provide a dictionary of transaction properties as the last arg.

  • silent (bool)

Returns:

Object representing the broadcasted transaction.

Return type:

TransactionReceipt

__init__(address, abi, name, owner, natspec=None)
Parameters:
  • address (str)

  • abi (Dict)

  • name (str)

  • owner (AccountsType | None)

  • natspec (Dict | None)

Return type:

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:
  • *args (-) –

    The arguments for the contract method.

  • block_identifier (-) – The block at which the chain will be read. If not provided, will read the chain at latest block.

  • decimals (-) – if provided, the output will be result / 10 ** decimals

  • *args

  • override (Dict[str, str] | None)

Returns:

  • Whatever the node sends back as the output for this contract method.

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.

Parameters:

*args (Tuple) – Contract method inputs

Returns:

Hexstring of encoded ABI data

Return type:

str

estimate_gas(*args)

Estimate the gas cost for a transaction.

Raises VirtualMachineError if the transaction would revert.

Parameters:

*args (Tuple) – Contract method inputs

Returns:

Estimated gas value in wei.

Return type:

int

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.

Returns:

A list of results from calling the method with each set of arguments.

Return type:

List[_EVMType]

transact(*args, silent=False)

Broadcast a transaction that calls this contract method.

Parameters:
  • *args (Tuple) – Contract method inputs. You can optionally provide a dictionary of transaction properties as the last arg.

  • silent (bool)

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.

natspec

The NatSpec documentation for the function.

property payable: bool
property signature: str

The function signature.

This property returns the unique signature of the contract function, which is used to identify the function in transactions.

class dank_mids.brownie_patch.DankOverloadedMethod

Bases: OverloadedMethod, _DankMethodMixin

A brownie.network.contract.OverloadedMethod subclass with async support via the coroutine method.

It uses less memory than a OverloadedMethod by using __slots__ along with the FunctionABI singleton to hold the function abi and related logic.

You can await this object directly to call the contract method with no arguments at the latest block.

__call__(*args, block_identifier=None, override=None)

Call self as a function.

Parameters:
Return type:

Any

__getitem__(key)
Parameters:

key (Tuple | str)

Return type:

_ContractMethod

__init__(address, name, owner)
Parameters:
  • address (str)

  • name (str)

  • owner (AccountsType | None)

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).

async coroutine(*args, block_identifier=None, decimals=None, override=None)

Asynchronously call the contract method via dank mids and await the result.

Parameters:
  • *args (-) –

    The arguments for the contract method.

  • block_identifier (-) – The block at which the chain will be read. If not provided, will read the chain at latest block.

  • decimals (-) – if provided, the output will be result / 10 ** decimals

  • *args

  • override (Dict[str, str] | None)

Returns:

  • Whatever the node sends back as the output for this contract method.

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.

Parameters:

*args (Tuple) – Contract method inputs

Returns:

Hexstring of encoded ABI data

Return type:

str

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.

Returns:

A list of results from calling the method with each set of arguments.

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[Tuple[str, ...], DankContractCall | DankContractTx]
natspec: Dict
property signature: str

The function signature.

This property returns the unique signature of the contract function, which is used to identify the function in transactions.

dank_mids.brownie_patch.patch_contract(contract, w3=None)

Patch a contract with async and call batching functionalities.

Parameters:
  • contract (Contract | Contract | str) – The contract to patch.

  • w3 (DankWeb3 | None) – Optional DankWeb3 instance.

Returns:

The patched contract.

Return type:

Contract | Contract

dank_mids.brownie_patch.dank_eth: DankEth = <dank_mids.eth.DankEth object>

If you have brownie installed and connected, an instance of AsyncEth, providing asynchronous access to Ethereum blockchain methods via dank_web3.

If you do not have brownie or it is not connected to an rpc when this module is loaded, this object will not exist.

dank_mids.brownie_patch.dank_web3: DankWeb3 = <web3.main.Web3 object>

If you have brownie installed and connected, an instance of DankWeb3, which is a wrapper around brownie’s standard Web3 object with Dank Middleware injected.

If you do not have brownie or it is not connected to an rpc when this module is loaded, this object will not exist.