> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dfns.co/llms.txt
> Use this file to discover all available pages before exploring further.

# EVM chains

EVM chains like Ethereum, Polygon, Base etc support the following signature `kinds`:

* `Transaction`: unsigned transaction.
* `Eip191`: personal\_sign message defined in [EIP-191](https://eips.ethereum.org/EIPS/eip-191). Also available as `Message` (they are equivalent).
* `Eip712`: typed structured data defined in [EIP-712](https://eips.ethereum.org/EIPS/eip-712).
* `Eip7702`: authorization tuple for type 4 set code transaction defined in [EIP-7702](https://eips.ethereum.org/EIPS/eip-7702).

## Transaction

Signs an unsigned transaction. The `transaction` field accepts either a hex-encoded string or a JSON object.

| Field            | Description                                                         | Type - Optional                                     |
| ---------------- | ------------------------------------------------------------------- | --------------------------------------------------- |
| `blockchainKind` | `Evm`                                                               | String                                              |
| `kind`           | `Transaction`                                                       | String                                              |
| `transaction`    | The unsigned transaction formatted as JSON or a hex-encoded string. | String or [EvmTransactionJson](#evmtransactionjson) |

### Hex string

```json theme={null}
{
  "blockchainKind": "Evm",
  "kind": "Transaction",
  "transaction": "0x02e783aa36a71503850d40e49def82520894e5a2ebc128e262ab1e3bd02bffbe16911adfbffb0180c0"
}
```

#### Typescript example with Ethers

First install the Ethers JS. You can find the full documentation [here](https://docs.ethers.org/v6/).

Here a code sample to generate a signature via [the Dfns TypeScript SDK](https://github.com/dfns/dfns-sdk-ts):

```typescript theme={null}
import { parseUnits, Transaction } from 'ethers'

const walletId = 'wa-6lbfv-9esgj-xxxxxxxxxxxxxxxx'

const transaction = Transaction.from({
  to: '0xa238b6008Bc2FBd9E386A5d4784511980cE504Cd',
  value: '1',
  gasLimit: '21000',
  maxPriorityFeePerGas: parseUnits('5', 'gwei'),
  maxFeePerGas: parseUnits('20', 'gwei'),
  nonce: 3,
  type: 2,
  chainId: 11155111,
})

const res = await dfnsClient.wallets.generateSignature({
  walletId,
  body: { kind: 'Transaction', transaction: transaction.unsignedSerialized },
})
```

### EvmTransactionJson

<table data-full-width="false"><thead><tr><th>Field</th><th>Description</th><th>Type - Optional</th></tr></thead><tbody><tr><td><code>type</code></td><td>Ethereum transaction type. <code>0</code> for legacy transaction; <code>2</code> for EIP-1559 transaction; <code>4</code> for EIP-7702 transaction. Default is <code>2</code> if undefined.</td><td>Integer (optional)</td></tr><tr><td><code>to</code></td><td>The destination address or target contract. Leave undefined when the transaction is a contract deployment.</td><td>String (optional)</td></tr><tr><td><code>value</code></td><td>The amount of native tokens to transfer in minimum denomination.</td><td>String <em>(optional)</em></td></tr><tr><td><code>data</code></td><td>ABI encoded function call data in hex format. Can also be the encoded smart contract data when the transaction is a contract deployment.</td><td>String <em>(optional)</em></td></tr><tr><td><code>nonce</code></td><td>The transaction number to guarantee idempotency. If omitted, it will be provided automatically. Note the same nonce can be submitted multiple times with a higher <code>maxFeePerGas</code> to "overwrite" existing transactions in the mempool.</td><td>Integer or String <em>(optional)</em></td></tr><tr><td><code>gasLimit</code></td><td>The maximum amount of gas that can be spent for executing the transaction. If omitted, it will be calculated automatically.</td><td>String <em>(optional)</em></td></tr><tr><td><code>gasPrice</code></td><td>The amount of per unit gas. Only valid for a type 0 legacy transaction. If omitted, it will be calculated automatically.</td><td>String <em>(optional)</em></td></tr><tr><td><code>maxFeePerGas</code></td><td>The maximum amount of per unit gas willing to be paid for the transaction. Valid for type 2 and type 4 transactions. If omitted, it will be calculated automatically.</td><td>String <em>(optional)</em></td></tr><tr><td><code>maxPriorityFeePerGas</code></td><td>The maximum amount of per unit gas to be included as a tip to the validator. Valid for type 2 and type 4 transactions. If omitted, it will be calculated automatically.</td><td>String <em>(optional)</em></td></tr><tr><td><code>authorizationList</code></td><td>A list that indicates what code the signer of each authorization desires to execute in the context of their EOA. Only valid for type 4 transaction.</td><td><a href="#authorization">Authorization</a> <em>(optional)</em></td></tr></tbody></table>

### Authorization

| Field       | Description                                                        | Type - Optional |
| ----------- | ------------------------------------------------------------------ | --------------- |
| `chainId`   | Chain ID.                                                          | Integer         |
| `address`   | The address of the contract the signer's EOA will be delegated to. | String          |
| `nonce`     | The current nonce of the signer EOA.                               | Integer         |
| `signature` | The signer signature.                                              | String          |

```json theme={null}
{
  "blockchainKind": "Evm",
  "kind": "Transaction",
  "transaction": {
    "to": "0x00fb58432ef9d418bf6688bcf0a226d2fcaa18e2",
    "data": "0x40d097c3000000000000000000000000d2f77f85a50cdd650ca562f3a180284e1d5b4934",
    "maxFeePerGas": "1626000000000",
    "maxPriorityFeePerGas": "1332000000000"
  }
}
```

## EIP-191 personal\_sign

Signs a `personal_sign` message as defined in [EIP-191](https://eips.ethereum.org/EIPS/eip-191).

| Field            | Description          | Type - Optional |
| ---------------- | -------------------- | --------------- |
| `blockchainKind` | `Evm`                | String          |
| `kind`           | `Eip191`             | String          |
| `message`        | Hex-encoded message. | String          |

```json theme={null}
{
  "blockchainKind": "Evm",
  "kind": "Eip191",
  "message": "0x49206c6f76652044666e73"
}
```

## EIP-712 TypedData

Signs a typed structured data defined in [EIP-712](https://eips.ethereum.org/EIPS/eip-712).

| Field            | Description                 | Type - Optional                 |
| ---------------- | --------------------------- | ------------------------------- |
| `blockchainKind` | `Evm`                       | String                          |
| `kind`           | `Eip712`                    | String                          |
| `types`          | Type definitions.           | Map\<String, TypedDataField\[]> |
| `domain`         | Domain separator.           | Eip712Domain                    |
| `message`        | Structured message to sign. | Object                          |

#### TypedDataField

| Field  | Description | Type - Optional |
| ------ | ----------- | --------------- |
| `name` | Field name. | String          |
| `type` | Field type. | String          |

#### Eip712Domain

| Field               | Description                                                 | Type - Optional |
| ------------------- | ----------------------------------------------------------- | --------------- |
| `name`              | Name of the signing domain.                                 | String          |
| `version`           | Current major version of the signing domain.                | String          |
| `chainId`           | Chain ID.                                                   | Integer         |
| `verifyingContract` | The address of the contract that will verify the signature. | String          |
| `salt`              | 32-byte value as a last-resort domain separator.            | String          |

```shell theme={null}
{
  "blockchainKind": "Evm",
  "kind": "Eip712",
  "types": {
    "Person": [
      { "name": "name", "type": "string" },
      { "name": "wallet", "type": "address" }
    ],
    "Mail": [
      { "name": "from", "type": "Person" },
      { "name": "to", "type": "Person" },
      { "name": "contents", "type": "string" }
    ]
  },
  "domain": {
    "name": "Ether Mail",
    "version": "1",
    "chainId": 1,
    "verifyingContract": "0x1b352de7a926ebd1bf52194dab487c2cb0793a9b",
    "salt": "0xf2d857f4a3edcb9b78b4d503bfe733db1e3f6cdc2b7971ee739626c97e86a558"
  },
  "message": {
    "from": {
      "name": "Chris",
      "wallet": "0x00e3495cf6af59008f22ffaf32d4c92ac33dac47"
    },
    "to": {
      "name": "Bob",
      "wallet": "0xcc0ee1a1c5e788b61916c8f1c96c960f9a9d3db7"
    },
    "contents": "Hello, Bob!"
  }
}
```

## EIP-7702 Authorization

Signs an authorization tuple for type 4 set code transaction defined in [EIP-7702](https://eips.ethereum.org/EIPS/eip-7702).

| Field            | Description                                                        | Type - Optional |
| ---------------- | ------------------------------------------------------------------ | --------------- |
| `blockchainKind` | `Evm`                                                              | String          |
| `kind`           | `Eip7702`                                                          | String          |
| `chainId`        | Chain ID.                                                          | Integer         |
| `address`        | The address of the contract the signer's EOA will be delegated to. | String          |
| `nonce`          | The current nonce of the signer EOA.                               | Integer         |

```json theme={null}
{
  "blockchainKind": "Evm",
  "kind": "Eip7702",
  "chainId": 1,
  "address": "0xcea43594f38316f0e01c161d8dabde0a07a1f512",
  "nonce": 0
}
```
