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 instancefunction_name (
str) – Name of the function to format output foroutput (
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.get_contract_address(sender_address, nonce)[source]¶
Compute the contract address like Ethereum does.
- Return type:
NewType()(ChecksumAddress,NewType()(HexAddress,NewType()(HexStr,str)))
- exception arbitrum_py.utils.helper.ContractLoadError[source]¶
Bases:
ExceptionCustom 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(contract_name, provider=None, address=None)[source]¶
Load a contract instance
- Parameters:
contract_name (
str) – Name of the contractprovider (
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
- class arbitrum_py.utils.helper.CaseDict(x)[source]¶
Bases:
object-
SPECIAL_CASES:
Dict[str,str] = {'erc20': 'Erc20'}¶
-
SPECIAL_CASES:
- 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 aTypeError).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