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

# getPlugArrayHash

Encode an array of [Plugs](/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 hash of the encoded [Plug](/generated/base-types/Plug) array data.

## Onchain Implementation

With `getPlugArrayHash` you can call the function as a `read` and get the built hash back. 
    
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:getPlugArrayHash]
function getPlugArrayHash(
	TypesLib.Plug[] memory $input
)  public pure virtual returns (bytes32 $typeHash) {
	/// @dev Load the stack.
	bytes memory encoded;
	uint256 i;
	uint256 length = $input.length;

	/// @dev Encode each item in the array.
	for (i; i < length; i++) {
		encoded = bytes.concat(
			encoded,
			getPlugHash($input[i])
		);
	}
	
	/// @dev Hash the encoded array.
	$typeHash = keccak256(encoded);
}
``` 

:::