---
head:
    - - meta
      - property: og:title
        content: getPlugHash
    - - meta
      - name: description
        content: Encode a Plug into a hash and verify the decoded data to verify type compliance.
    - - meta
      - property: og:description
        content: Encode a Plug into a hash and verify the decoded data to verify type compliance.
notes:
    - - author: Auto generated by @nftchance/plug-types/cli
---
        
# getPlugHash

Encode a [Plug](/generated/base-types/Plug) into a hash and verify the decoded [Plug](/generated/base-types/Plug) data from a hash to verify type compliance.

## Parameters

- `$input` : [Plug](/generated/base-types/Plug) : The `Plug` data to encode.

## Returns

- `$typeHash` : `bytes32` : The packet hash of the encoded [Plug](/generated/base-types/Plug) data.

## Onchain Implementation

With `getPlugHash` you can call the function as a `read` and get the encoded data back as a hash. 
        
This is helpful in times when you need to build a message hash without tracking down all the types as well as when you need to verify a signed message hash containing a `Plug` data type.

::: code-group

``` solidity [Types.sol:getPlugHash]
function getPlugHash(
	TypesLib.Plug memory $input
) public pure virtual returns (bytes32 $typeHash) {
	$typeHash = keccak256(abi.encode(
		PLUG_TYPEHASH,
		$input.target,
	$input.value,
	keccak256($input.data)
	));
}
``` 

:::