Skip to content

eip712HashType

function eip712HashType(
string calldata typeNameOrDefinition
) external pure returns (bytes32);

Returns keccak256(bytes(canonicalTypeString)) for the given EIP-712 type.

The argument can be a registered struct name (e.g. "Mail") or a full EIP-712 type definition string.

Note: Requires the test.solidity.eip712Types configuration. See the EIP-712 type hashing guide for setup.

// Look up by registered name
bytes32 hash = cheats.eip712HashType("Mail");
// Or pass a full type definition directly
bytes32 hash2 = cheats.eip712HashType(
"Mail(Person from,Person to,string contents)Person(address wallet,string name)"
);
assertEq(hash, hash2);