# `Ethers.TypedData.Field`
[🔗](https://github.com/ExWeb3/elixir_ethers/blob/v0.8.0/lib/ethers/typed_data/field.ex#L1)

A single member of an EIP-712 struct type.

A field pairs a member `name` with its Solidity `type` string (e.g. `"string"`,
`"address"`, `"uint256"`, `"Person"`, `"Person[]"`). The ordered list of fields for a
given struct type is what `encodeType`/`hashStruct` operate on in the EIP-712 algorithm.

Both `name` and `type` are plain strings using the JSON/Solidity spelling (for example the
domain's chain id field is named `"chainId"` with type `"uint256"`).

# `t`

```elixir
@type t() :: %Ethers.TypedData.Field{name: String.t(), type: String.t()}
```

An EIP-712 struct member.

- `name` - the member name as it appears in the message (e.g. `"wallet"`, `"chainId"`).
- `type` - the Solidity type string of the member (e.g. `"address"`, `"Person[]"`).

# `new`

```elixir
@spec new(t() | map() | keyword()) :: t()
```

Creates a new `Ethers.TypedData.Field` from a map, keyword list, or an existing field.

Accepts atom (`:name`/`:type`) or string (`"name"`/`"type"`) keys. An existing
`Ethers.TypedData.Field` is returned unchanged.

## Examples

    iex> Ethers.TypedData.Field.new(%{name: "wallet", type: "address"})
    %Ethers.TypedData.Field{name: "wallet", type: "address"}

    iex> Ethers.TypedData.Field.new(%{"name" => "contents", "type" => "string"})
    %Ethers.TypedData.Field{name: "contents", type: "string"}

---

*Consult [api-reference.md](api-reference.md) for complete listing*
