module Eth::Tx

def estimate_intrinsic_gas(data = "", list = [])

Returns:
  • (Integer) - the estimated intrinsic gas cost.

Parameters:
  • list (Array) -- the access list.
  • data (String) -- the call data.
def estimate_intrinsic_gas(data = "", list = [])
  gas = DEFAULT_GAS_LIMIT
  unless data.nil? or data.empty?
    data = Util.hex_to_bin data if Util.is_hex? data
    # count zero bytes
    zero = data.count ZERO_BYTE
    gas += zero * COST_ZERO_BYTE
    # count non-zero bytes
    none = data.size - zero
    gas += none * COST_NON_ZERO_BYTE
  end
  unless list.nil? or list.empty?
    list.each do |entry|
      # count addresses
      gas += COST_ADDRESS
      entry.last.each do |key|
        # count storage keys
        gas += COST_STORAGE_KEY
      end
    end
  end
  return gas
end