class Eth::Client

def call_raw(contract, func, *args, **kwargs)

Returns:
  • (Object) - returns the result of the call.

Parameters:
  • legacy (Boolean) -- enables legacy transactions (pre-EIP-1559).
  • sender_key (Eth::Key) -- the sender private key.
  • value (Integer|String) -- function arguments.
  • func (Eth::Contract::Function) -- method name to be called.
  • contract (Eth::Contract) -- subject contract to call.
  • value (Integer|String) -- function arguments.
  • func (Eth::Contract::Function) -- method name to be called.
  • contract (Eth::Contract) -- subject contract to call.
  • func (Eth::Contract::Function) -- method name to be called.
  • contract (Eth::Contract) -- subject contract to call.

Overloads:
  • call_raw(contract, func, value, sender_key, legacy)
  • call_raw(contract, func, value)
  • call_raw(contract, func)
def call_raw(contract, func, *args, **kwargs)
  gas_limit = Tx.estimate_intrinsic_gas(contract.bin) + Tx::CREATE_GAS
  params = {
    gas_limit: gas_limit,
    chain_id: chain_id,
    data: call_payload(func, args),
  }
  if kwargs[:address] || contract.address
    params.merge!({ to: kwargs[:address] || contract.address })
  end
  if kwargs[:legacy]
    params.merge!({
      gas_price: max_fee_per_gas,
    })
  else
    params.merge!({
      priority_fee: max_priority_fee_per_gas,
      max_gas_fee: max_fee_per_gas,
    })
  end
  unless kwargs[:sender_key].nil?
    # use the provided key as sender and signer
    params.merge!({
      from: kwargs[:sender_key].address,
      nonce: get_nonce(kwargs[:sender_key].address),
    })
    tx = Eth::Tx.new(params)
    tx.sign kwargs[:sender_key]
  else
    # use the default account as sender and external signer
    params.merge!({
      from: default_account,
      nonce: get_nonce(default_account),
    })
  end
  raw_result = eth_call(params)["result"]
  types = func.outputs.map { |i| i.type }
  Eth::Abi.decode(types, raw_result)
end