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

# Plug

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

## The Data Type

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

::: code-group

``` typescript [Typescript/Javascript]
type Plug = {
	target: `0x${string}`;
	value: bigint;
	data: `0x${string}`; 
}
```

```typescript [EIP-712]
const Plug = [
	{ name: 'target', type: 'address' },
	{ name: 'value', type: 'uint256' },
	{ name: 'data', type: 'bytes' } 
]
```

:::

::: 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 `target`, `value` and `data` as the fields of the `Plug` data type we can generate the type hash as follows:

::: code-group

```solidity [Inline.sol]
bytes32 constant PLUG_TYPEHASH = keccak256(
    'Plug(address target,uint256 value,bytes data)'
);
```

```solidity [Hash.sol]
bytes32 constant PLUG_TYPEHASH = 0x0d73e94823fdaacb148d9146f00bc268b7834e768ced483d796db05a52e1e395
```

:::