# eip712HashStruct

Description: eip712HashStruct cheatcode documentation

Note: This document was authored using MDX

  Source: https://github.com/NomicFoundation/hardhat-website/tree/main/src/content/docs/docs/reference/cheatcodes/Utilities/eip712-hash-struct.mdx

### Signature

```solidity
function eip712HashStruct(
  string calldata typeName,
  bytes calldata abiEncodedData
) external pure returns (bytes32);
```

### Description

Returns the EIP-712 **struct hash** for a registered struct name (e.g. `"Mail"`) and its `abi.encode`-d value.

This is **not** the final signable digest. To produce the digest that `ecrecover` expects, combine the struct hash with a domain separator: `keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash))`. Alternatively, use [`eip712HashTypedData`](/docs/reference/cheatcodes/utilities/eip712-hash-typed-data) to compute the complete digest in one call.

> **Note:** Requires the `test.solidity.eip712Types` configuration. See the [EIP-712 type hashing guide](/docs/guides/testing/eip712-types) for setup and full signing examples.

### Example

```solidity
Mail memory m = Mail({
    from: Person({ wallet: address(0xA), name: "Alice" }),
    to:   Person({ wallet: address(0xB), name: "Bob"   }),
    contents: "hello"
});

bytes32 hash = cheats.eip712HashStruct("Mail", abi.encode(m));
```

### SEE ALSO

- [eip712HashType](/docs/reference/cheatcodes/utilities/eip712-hash-type)
- [eip712HashTypedData](/docs/reference/cheatcodes/utilities/eip712-hash-typed-data)
- [EIP-712 type hashing guide](/docs/guides/testing/eip712-types)
