class Eth::Client

def is_valid_signature(contract, hash, signature, magic = "1626ba7e")

Raises:
  • (ArgumentError) - in case the contract cannot be called yet.

Returns:
  • (Boolean) - true if magic matches and signature is valid.

Parameters:
  • magic (String) -- the expected magic value (defaults to `1626ba7e`).
  • signature (String) -- the signature to be recovered by the contract.
  • hash (String) -- the message hash to be checked against the signature.
  • contract (Eth::Contract) -- a deployed contract implementing EIP-1271.
def is_valid_signature(contract, hash, signature, magic = "1626ba7e")
  raise ArgumentError, "Contract not deployed yet." if contract.address.nil?
  hash = Util.hex_to_bin hash if Util.is_hex? hash
  signature = Util.hex_to_bin signature if Util.is_hex? signature
  magic = Util.hex_to_bin magic if Util.is_hex? magic
  result = call(contract, "isValidSignature", hash, signature)
  return result === magic
end