class Eth::Client
def call(contract, function, *args, **kwargs)
-
(Object)
- returns the result of the call.
Parameters:
-
**legacy
(Boolean
) -- enables legacy transactions (pre-EIP-1559). -
**sender_key
(Eth::Key
) -- the sender private key. -
*args
() -- optional function arguments.
-
function
(String
) -- method name to be called. -
contract
(Eth::Contract
) -- the subject contract to call. -
*args
() -- optional function arguments.
-
function
(String
) -- method name to be called. -
contract
(Eth::Contract
) -- the subject contract to call. -
function
(String
) -- method name to be called. -
contract
(Eth::Contract
) -- the subject contract to call.
Overloads:
-
call(contract, function, *args, **kwargs)
-
call(contract, function, *args)
-
call(contract, function)
def call(contract, function, *args, **kwargs) func = contract.functions.select { |func| func.name == function } raise ArgumentError, "this function does not exist!" if func.nil? || func.size === 0 selected_func = func.first func.each do |f| if f.inputs.size === args.size selected_func = f end end output = call_raw(contract, selected_func, *args, **kwargs) if output&.length == 1 output[0] else output end end