NAME
Ethereum::Contract - Support for interacting with Ethereum contracts using the geth RPC interface
BUILD
Constructor: Here we get all functions and events from the given ABI and set it to the contract class.
- contract_address => string (optional)
- contract_abi => string (required, https://solidity.readthedocs.io/en/develop/abi-spec.html)
- rpc_client => Ethereum::RPC::Client (optional, default: Ethereum::RPC::Client)
- from => string (optional)
- gas => numeric (optional)
- gas_price => numeric (optional)
- max_fee_per_gas => numeric (optional)
- max_priority_fee_per_gas => numeric (optional)
invoke
Prepare a function to be called/sent to a contract.
Returns a Ethereum::Contract::ContractTransaction object.
get_function_id
The function ID is derived from the function signature using: SHA3(approve(address,uint256)).
- fuction_name => string (required)
- params_size => numeric (required, size of inputs called by the function)
Returns a string hash
_prepare_transaction
Join the data and parameters and return a prepared transaction to be called as send, call or deploy.
- compiled_data => string (required, function signature or the contract bytecode)
- function_name => string (contract function as specified in the ABI)
- params => array (required)
Future object on_done: Ethereum::Contract::ContractTransaction on_fail: error string
encode
Encode function arguments to the ABI format
function_name
ABI function nameparams
all the values for the function in the same order than the ABI
Returns an encoded data string
get_function_offset
Get the abi function total offset
For the cases we have arrays as parameters we can have a dynamic size for the static values, for sample if the basic type has a fixed value and also the array is fixed, we will have all the items on the array being added with the static items before the dynamic items in the encoded data
return the integer offset
get_hex_param
Convert parameter list to the ABI format: https://solidity.readthedocs.io/en/develop/abi-spec.html#function-selector-and-argument-encoding
current_offset_count
The offset where we should base the calculation for the next dynamic valueinput_type
The input type specified in the abi sample: string, bytes, uintparam
The input value
Returns 2 arrays
Static => contains the static values from the conversion Dynamic => contains the dynamic values from the conversion
read_event
Read the specified log from the specified block to the latest block
Returns a json encoded object: https://github.com/ethereum/wiki/wiki/JSON-RPC#returns-42
invoke_deploy
Prepare a deploy transaction.
Returns a Ethereum::Contract::ContractTransaction object.
append_prefix
Ensure that the given hexadecimal string starts with 0x.
Returns a string hexadecimal