---
head:
    - - meta
      - property: og:title
        content: Plugs
    - - meta
      - name: description
        content: A Plugs data type provides EIP-712 compatability for encoding and decoding.
    - - meta
      - property: og:description
        content: A Plugs data type provides EIP-712 compatability for encoding and decoding. 
notes:
    - - author: Auto generated by @nftchance/plug-types/cli
---

# Plugs

A [Plugs](/generated/base-types/Plugs) data type provides EIP-712 compatability for encoding and decoding the data needed for an `Plug` to be securely distributed and executed. 

::: info
                
Inside the declaration of a `Plugs` data type there are nested [Plug](/generated/base-types/Plug) data types that need to be built independently.
                    
:::

## The Data Type

To interact with the data type onchain will you need both the `Typescript` and `EIP-712` representations of the `Plugs` data type: 

::: code-group

``` typescript [Typescript/Javascript]
type Plugs = {
	socket: `0x${string}`;
	plugs: Array<Plug>;
	solver: `0x${string}`;
	salt: `0x${string}`; 
}
```

```typescript [EIP-712]
const Plugs = [
	{ name: 'socket', type: 'address' },
	{ name: 'plugs', type: 'Plug[]' },
	{ name: 'solver', type: 'bytes' },
	{ name: 'salt', type: 'bytes32' } 
]
```

:::

::: tip

The `Typescript` representation is used to build and work with the object in your dApp and API while the `EIP-712` representation is used to encode and decode the data type onchain.

:::

## Onchain Implementation

With `socket`, `plugs`, `solver` and `salt` as the fields of the `Plugs` data type we can generate the type hash as follows:

::: code-group

```solidity [Inline.sol]
bytes32 constant PLUGS_TYPEHASH = keccak256(
    'Plugs(address socket,Plug[] plugs,bytes solver,bytes32 salt)Plug(address target,uint256 value,bytes data)'
);
```

```solidity [Hash.sol]
bytes32 constant PLUGS_TYPEHASH = 0xab17334cacf66e0b0c0e533c2822a50549311ba957ec52ec037e1c8083f023ab
```

:::