Method: Klay::Key#sign_typed_data

Defined in:
lib/klay/key.rb

#sign_typed_data(typed_data, chain_id = nil) ⇒ String

Prefixes, hashes, and signes a typed data structure in the common way used by many web3 wallets. Complies with EIP-191 prefix 0x19 and EIP-712 version byte 0x01. Supports V3, V4. See also Signature#recover_typed_data. Ref: https://eips.ethereum.org/EIPS/eip-712

Parameters:

  • typed_data (Array)

    all the data in the typed data structure to be signed.

  • chain_id (Integer) (defaults to: nil)

    the chain id the signature should be generated on.

Returns:

  • (String)

    an EIP-712 conform, hexa-decimal signature.



109
110
111
112
# File 'lib/klay/key.rb', line 109

def sign_typed_data(typed_data, chain_id = nil)
  hash_to_sign = Eip712.hash typed_data
  sign hash_to_sign, chain_id
end