Web3JS Online
Viem Online
Webhooks, Alerts, and a simple API.
The hashTypedData function takes in four parameters: domain, types, primaryType, and message. It returns a hashed message in Ethereum-specific EIP-712 format.
The domain parameter is an object that contains information about the domain in which the typed data is defined. It has four properties: name, version, chainId, and verifyingContract.
The types parameter is an object that defines the types of the data in the message. It contains two properties: Person and Mail. The Person property is an array of objects, each with two properties: name and wallet. The Mail property is also an array of objects, each with three properties: from, to, and contents.
The primaryType parameter is a string that specifies the primary type of the message. In this case, it is set to 'Mail'.
The message parameter is an object that contains the actual data of the message. It has three properties: from, to, and contents. The from and to properties are objects with the same structure as the Person type defined in the types object. The contents property is a string.
The function first concatenates the domain separator (\x19\x01) with the hash of the domain object, and then hashes the resulting string using Keccak-256. It then takes the resulting hash and appends it to the message object, along with the primaryType and types objects. Finally, it returns the hashed message in EIP-712 format.
Here is an example of how to use the hashMessage function:
In summary, the hashTypedData function takes in a domain, types, primary type, and message, and returns a hashed message in EIP-712 format that can be used to verify the authenticity of the message.
Output will appear here. You can scroll the text if it becomes too long.