The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

    Ethereum::Contract - Support for interacting with Ethereum contracts using the geth RPC interface

BUILD

Constructor: Here we get all functions from the passed ABI and bring it to contract class subs.

Parameters: contract_address ( Optional - only if the contract already exists ), contract_abi ( Required - https://solidity.readthedocs.io/en/develop/abi-spec.html ), rpc_client ( Optional - Ethereum::RPC::Client(https://github.com/binary-com/perl-Ethereum-RPC-Client) - if not given, new instance will be created ); from ( Optional - Address ) gas ( Optional - Integer gas ) gas_price ( Optional - Integer gasPrice )

Return: New contract instance

invoke

Invokes all calls from ABI to the contract.

Parameters: name (Required - the string function name ) params (Optional - the parameters)

Return: Ethereum::Contract::ContractTransaction

get_function_id

Get the function and parameters and merge to create the hashed ethereum function ID

Ex: function approve with the inputs address _spender and uint value must be represented as: SHA3("approve(address,uint)")

Parameters: function_string (Required - the string function name ) inputs (Required - the input list given on the contract ABI)

Return: New function ID hash

_prepare_transaction

Join the data and parameters and return a prepared transaction to be called as send, call or deploy.

Parameters: $compiled_data ( Required - the hashed function string name with parameters or the compiled contract bytecode ) params ( Required - the parameters args given by the method call )

Return: Future object on_done: Ethereum::Contract::ContractTransaction on_fail: string message

get_hex_param

Convert the given value to hexadecimal format

Parameters: function_id (Required - arg to be converted to hexadecimal)

Return: Hexadecimal string

read_all_events_from_block

Create a filter based on the given block to listen all events sent by the contract.

The filter is killed before the list return, so for each request a new filter will be created.

Parameters: from_block ( Optional - start search block ) function ( Required - function name )

Return: https://github.com/ethereum/wiki/wiki/JSON-RPC#returns-42

invoke_deploy

Prepare a deploy transaction,

Parameters: compiled ( Required - contract bytecode) params ( Required - contract constructor params

Return: Ethereum::Contract::ContractTransaction

append_prefix

Ensure that the given hexadecimal string starts with 0x.