Hardfork Utility Functions For The Message Data-structure
Table of Contents
Introduction
Message specific functions used in this frontierhomestead version of specification.
Module Contents
Functions
Execute a transaction against the provided environment. |
Module Details
prepare_message
- prepare_message(caller, target, value, data, gas, env, code_address=None, should_transfer_value=True)
Execute a transaction against the provided environment.
- Parameters
caller – Address which initiated the transaction
target – Address whose code will be executed
value – Value to be transferred.
data – Array of bytes provided to the code in target.
gas – Gas provided for the code in target.
env – Environment for the Ethereum Virtual Machine.
code_address – This is usually same as the target address except when an alternative accounts code needs to be executed. eg. CALLCODE calling a precompile.
should_transfer_value – if True ETH should be transferred while executing a message call.
- Returns
message – Items containing contract creation or message call specific data.
- Return type
ethereum.frontier.vm.Message
ethereum.homestead.vm.Message
def prepare_message( caller: Address, target: Union[Bytes0, Address], value: U256, data: Bytes, gas: U256, env: Environment, code_address: Optional[Address] = None, should_transfer_value: bool = True, ) -> Message: if isinstance(target, Bytes0): current_target = compute_contract_address( caller, get_account(env.state, caller).nonce - U256(1), ) msg_data = Bytes(b"") code = data elif isinstance(target, Address): current_target = target msg_data = data code = get_account(env.state, target).code if code_address is None: code_address = target else: raise AssertionError("Target must be address or empty bytes") return Message( caller=caller, target=target, gas=gas, value=value, data=msg_data, code=code, depth=Uint(0), current_target=current_target, code_address=code_address, should_transfer_value=should_transfer_value, )