# Transaction

Utilities & types for working with **Transactions** as defined in the [Execution API specification](https://github.com/ethereum/execution-apis/blob/main/src/schemas/transaction.yaml)

## Examples

### Converting from RPC Format

Transactions can be converted from RPC format using [`Transaction.fromRpc`](/api/Transaction/fromRpc):

```ts twoslash
import { Transaction } from 'ox'

const transaction = Transaction.fromRpc({
  hash: '0x353fdfc38a2f26115daadee9f5b8392ce62b84f410957967e2ed56b35338cdd0',
  nonce: '0x357',
  blockHash:
    '0xc350d807505fb835650f0013632c5515592987ba169bbc6626d9fc54d91f0f0b',
  blockNumber: '0x12f296f',
  transactionIndex: '0x2',
  from: '0x814e5e0e31016b9a7f138c76b7e7b2bb5c1ab6a6',
  to: '0x3fc91a3afd70395cd496c647d5a6cc9d4b2b7fad',
  value: '0x9b6e64a8ec60000',
  gas: '0x43f5d',
  maxFeePerGas: '0x2ca6ae494',
  maxPriorityFeePerGas: '0x41cc3c0',
  input:
    '0x3593564c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000006643504700000000000000000000000000000000000000000000000000000000000000040b080604000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002800000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000009b6e64a8ec600000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000009b6e64a8ec60000000000000000000000000000000000000000000000000000019124bb5ae978c000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000c56c7a0eaa804f854b536a5f3d5f49d2ec4b12b80000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c56c7a0eaa804f854b536a5f3d5f49d2ec4b12b8000000000000000000000000000000fee13a103a10d593b9ae06b3e05f2e7e1c00000000000000000000000000000000000000000000000000000000000000190000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c56c7a0eaa804f854b536a5f3d5f49d2ec4b12b800000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000190240001b9872b',
  r: '0x635dc2033e60185bb36709c29c75d64ea51dfbd91c32ef4be198e4ceb169fb4d',
  s: '0x50c2667ac4c771072746acfdcf1f1483336dcca8bd2df47cd83175dbe60f0540',
  yParity: '0x0',
  chainId: '0x1',
  accessList: [],
  type: '0x2'
})
```

## Functions

| Name                | Description                         |
| ------------------- | ----------------------------------- |
| [`Transaction.fromRpc`](/api/Transaction/fromRpc) | Converts an [`Transaction.Rpc`](/api/Transaction/types#rpc) to an [`Transaction.Transaction`](/api/Transaction/types#transaction). |
| [`Transaction.toRpc`](/api/Transaction/toRpc) | Converts an [`Transaction.Transaction`](/api/Transaction/types#transaction) to an [`Transaction.Rpc`](/api/Transaction/types#rpc). |

## Types

| Name                | Description                         |
| ------------------- | ----------------------------------- |
| [`Transaction.Base`](/api/Transaction/types#transactionbase) | Base properties of a Transaction as defined in the [Execution API specification](https://github.com/ethereum/execution-apis/blob/main/src/schemas/transaction.yaml). |
| [`Transaction.BaseRpc`](/api/Transaction/types#transactionbaserpc) | Base properties of an RPC Transaction as defined in the [Execution API specification](https://github.com/ethereum/execution-apis/blob/main/src/schemas/transaction.yaml). |
| [`Transaction.Eip1559`](/api/Transaction/types#transactioneip1559) | An [EIP-1559](https://eips.ethereum.org/EIPS/eip-1559) Transaction as defined in the [Execution API specification](https://github.com/ethereum/execution-apis/blob/main/src/schemas/transaction.yaml). |
| [`Transaction.Eip1559Rpc`](/api/Transaction/types#transactioneip1559rpc) | An [EIP-1559](https://eips.ethereum.org/EIPS/eip-1559) RPC Transaction as defined in the [Execution API specification](https://github.com/ethereum/execution-apis/blob/main/src/schemas/transaction.yaml). |
| [`Transaction.Eip2930`](/api/Transaction/types#transactioneip2930) | An [EIP-2930](https://eips.ethereum.org/EIPS/eip-2930) Transaction as defined in the [Execution API specification](https://github.com/ethereum/execution-apis/blob/main/src/schemas/transaction.yaml). |
| [`Transaction.Eip2930Rpc`](/api/Transaction/types#transactioneip2930rpc) | An RPC [EIP-2930](https://eips.ethereum.org/EIPS/eip-2930) Transaction as defined in the [Execution API specification](https://github.com/ethereum/execution-apis/blob/main/src/schemas/transaction.yaml). |
| [`Transaction.Eip4844`](/api/Transaction/types#transactioneip4844) | An [EIP-4844](https://eips.ethereum.org/EIPS/eip-4844) Transaction as defined in the [Execution API specification](https://github.com/ethereum/execution-apis/blob/main/src/schemas/transaction.yaml). |
| [`Transaction.Eip4844Rpc`](/api/Transaction/types#transactioneip4844rpc) | An RPC [EIP-4844](https://eips.ethereum.org/EIPS/eip-4844) Transaction as defined in the [Execution API specification](https://github.com/ethereum/execution-apis/blob/main/src/schemas/transaction.yaml). |
| [`Transaction.Eip7702`](/api/Transaction/types#transactioneip7702) | An [EIP-7702](https://eips.ethereum.org/EIPS/eip-7702) Transaction as defined in the [Execution API specification](https://github.com/ethereum/execution-apis/blob/main/src/schemas/transaction.yaml). |
| [`Transaction.Eip7702Rpc`](/api/Transaction/types#transactioneip7702rpc) | An RPC [EIP-7702](https://eips.ethereum.org/EIPS/eip-7702) Transaction as defined in the [Execution API specification](https://github.com/ethereum/execution-apis/blob/main/src/schemas/transaction.yaml). |
| [`Transaction.FromRpcType`](/api/Transaction/types#transactionfromrpctype) | RPC Type to Type mapping. |
| [`Transaction.Legacy`](/api/Transaction/types#transactionlegacy) | An legacy Transaction as defined in the [Execution API specification](https://github.com/ethereum/execution-apis/blob/main/src/schemas/transaction.yaml). |
| [`Transaction.LegacyRpc`](/api/Transaction/types#transactionlegacyrpc) | A legacy RPC Transaction as defined in the [Execution API specification](https://github.com/ethereum/execution-apis/blob/main/src/schemas/transaction.yaml). |
| [`Transaction.Rpc`](/api/Transaction/types#transactionrpc) | An RPC Transaction as defined in the [Execution API specification](https://github.com/ethereum/execution-apis/blob/main/src/schemas/transaction.yaml). |
| [`Transaction.ToRpcType`](/api/Transaction/types#transactiontorpctype) | Type to RPC Type mapping. |
| [`Transaction.Transaction`](/api/Transaction/types#transactiontransaction) | A Transaction as defined in the [Execution API specification](https://github.com/ethereum/execution-apis/blob/main/src/schemas/transaction.yaml). |
