Helper

arbitrum_py.utils.helper.format_contract_output(contract, function_name, output)[source]

Format contract function output according to ABI specification.

Parameters:
  • contract (Contract) – Web3 Contract instance

  • function_name (str) – Name of the function to format output for

  • output (Any) – Raw output from contract function call

Return type:

Union[Dict[str, Any], Any]

Returns:

Formatted output according to ABI specification

Raises:

ValueError – If function not found in contract ABI

arbitrum_py.utils.helper.to_checksum_address(address)[source]
Return type:

NewType()(ChecksumAddress, NewType()(HexAddress, NewType()(HexStr, str)))

arbitrum_py.utils.helper.parse_raw_tx_pyevm(raw_tx)[source]
arbitrum_py.utils.helper.get_contract_address(sender_address, nonce)[source]

Compute the contract address like Ethereum does.

Return type:

NewType()(ChecksumAddress, NewType()(HexAddress, NewType()(HexStr, str)))

arbitrum_py.utils.helper.parse_raw_tx(raw_tx)[source]
exception arbitrum_py.utils.helper.ContractLoadError[source]

Bases: Exception

Custom exception for contract loading errors

arbitrum_py.utils.helper.get_normalized_provider(provider)[source]

Normalize different provider types to Web3 instance

Return type:

Optional[Web3]

arbitrum_py.utils.helper.load_contract_data(contract_name, custom_path=None)[source]

Load contract ABI and bytecode from JSON file

Parameters:

contract_name (str) – Name of the contract

Return type:

Tuple[Sequence[Union[ABIFunction, ABIEvent]], Optional[NewType()(HexStr, str)]]

Returns:

Tuple of (ABI, bytecode)

Raises:

ContractLoadError – If ABI file not found or invalid

arbitrum_py.utils.helper.normalize_contract_address(address)[source]

Convert various address formats to checksum address

Return type:

NewType()(ChecksumAddress, NewType()(HexAddress, NewType()(HexStr, str)))

arbitrum_py.utils.helper.create_contract_instance(contract_name)[source]

Create a contract instance without provider for decoding function calls.

Parameters:

contract_name (str) – Name of the contract.

Returns:

Contract instance for decoding calls.

Return type:

Contract

arbitrum_py.utils.helper.load_contract_by_abi(contract_data, provider=None, address=None)[source]
arbitrum_py.utils.helper.load_contract(contract_name, provider=None, address=None)[source]

Load a contract instance

Parameters:
  • contract_name (str) – Name of the contract

  • provider (Union[Web3, SignerOrProvider, ArbitrumProvider, None]) – Web3 provider instance (optional if only interface needed)

  • address (Union[str, Contract, NewType()(Address, bytes), None]) – Contract address (optional)

Return type:

Contract

Returns:

Contract instance or interface

Raises:

ContractLoadError – If contract loading fails

arbitrum_py.utils.helper.deploy_abi_contract(provider, deployer, contract_name, constructor_args=None, **tx_params)[source]
Return type:

Contract

arbitrum_py.utils.helper.is_contract_deployed(provider, address)[source]
Return type:

bool

arbitrum_py.utils.helper.sign_and_sent_raw_transaction(signer, tx)[source]
Return type:

TxReceipt

class arbitrum_py.utils.helper.CaseDict(x)[source]

Bases: object

SPECIAL_CASES: Dict[str, str] = {'erc20': 'Erc20'}
__init__(x)[source]
classmethod snake_to_camel(name)[source]
Return type:

str

classmethod camel_to_snake(name)[source]
Return type:

str

get(key, default=None)[source]
Return type:

Optional[TypeVar(T)]

keys()[source]
Return type:

List[str]

items()[source]
Return type:

List[Tuple[str, Any]]

convert_to_serializable(value)[source]
Return type:

Any

to_dict()[source]

Convert CaseDict to a regular dict for JSON serialization

Return type:

Dict[str, Any]

_convert_value(value)[source]

Helper method to convert values for serialization

Return type:

Any

class arbitrum_py.utils.helper.CaseDictEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)[source]

Bases: JSONEncoder

default(obj)[source]

Implement this method in a subclass such that it returns a serializable object for o, or calls the base implementation (to raise a TypeError).

For example, to support arbitrary iterators, you could implement default like this:

def default(self, o):
    try:
        iterable = iter(o)
    except TypeError:
        pass
    else:
        return list(iterable)
    # Let the base class default method raise the TypeError
    return JSONEncoder.default(self, o)
Return type:

Any