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

# Receipt

> Transaction receipt with execution details

## Overview

Receipt is a branded type containing the results and metadata from executing a transaction on Ethereum. Receipts include gas usage, logs, status, and contract addresses.

```typescript theme={null}
import * as Receipt from '@tevm/primitives/Receipt'

const receipt = Receipt.from({
  transactionHash,
  transactionIndex: 0,
  blockHash,
  blockNumber: 19000000n,
  from: senderAddress,
  to: recipientAddress,
  cumulativeGasUsed: 42000n,
  gasUsed: 21000n,
  contractAddress: null,
  logs: [],
  logsBloom: new Uint8Array(256),
  status: TransactionStatus.success(21000n),
  effectiveGasPrice: 20000000000n,
  type: 'legacy'
})
```

## Type Definition

```typescript theme={null}
type ReceiptType = {
  readonly transactionHash: TransactionHashType;
  readonly transactionIndex: TransactionIndexType;
  readonly blockHash: BlockHashType;
  readonly blockNumber: BlockNumberType;
  readonly from: AddressType;
  readonly to: AddressType | null;
  readonly cumulativeGasUsed: Uint256Type;
  readonly gasUsed: Uint256Type;
  readonly contractAddress: AddressType | null;
  readonly logs: readonly EventLogType[];
  readonly logsBloom: Uint8Array;
  readonly status: TransactionStatusType;
  readonly effectiveGasPrice: Uint256Type;
  readonly type: "legacy" | "eip2930" | "eip1559" | "eip4844" | "eip7702";
  readonly blobGasUsed?: Uint256Type;
  readonly blobGasPrice?: Uint256Type;
} & { readonly [brand]: "Receipt" }
```

## Creating Receipts

### from

Create receipt from fields.

```typescript theme={null}
import * as Receipt from '@tevm/primitives/Receipt'
import * as TransactionHash from '@tevm/primitives/TransactionHash'
import * as TransactionIndex from '@tevm/primitives/TransactionIndex'
import * as BlockHash from '@tevm/primitives/BlockHash'
import * as BlockNumber from '@tevm/primitives/BlockNumber'
import * as TransactionStatus from '@tevm/primitives/TransactionStatus'
import * as Address from '@tevm/primitives/Address'

const receipt = Receipt.from({
  transactionHash: TransactionHash.fromHex('0x1234...'),
  transactionIndex: TransactionIndex.from(0),
  blockHash: BlockHash.fromHex('0xabcd...'),
  blockNumber: BlockNumber.from(19000000n),
  from: Address.fromHex('0xa0cf...'),
  to: Address.fromHex('0xdac1...'),
  cumulativeGasUsed: 42000n as Uint256Type,
  gasUsed: 21000n as Uint256Type,
  contractAddress: null,
  logs: [],
  logsBloom: new Uint8Array(256),
  status: TransactionStatus.success(21000n as Uint256Type),
  effectiveGasPrice: 20000000000n as Uint256Type,
  type: 'legacy'
})
```

**Validation**: All required fields must be provided. `logsBloom` must be 256 bytes.

## Receipt Fields

### Transaction Identifiers

* **transactionHash**: Transaction hash
* **transactionIndex**: Position in block (0-based)
* **blockHash**: Block hash
* **blockNumber**: Block height

### Addresses

* **from**: Sender address
* **to**: Recipient address (null for contract creation)
* **contractAddress**: Deployed contract address (null for non-creation)

### Gas Usage

* **gasUsed**: Gas consumed by this transaction
* **cumulativeGasUsed**: Total gas used in block up to this transaction
* **effectiveGasPrice**: Actual gas price paid (wei per gas)

### Execution Results

* **status**: Execution status (pending, success, failed)
* **logs**: Event logs emitted
* **logsBloom**: Bloom filter for log topics (256 bytes)

### Transaction Type

* **type**: Transaction type
  * `"legacy"` - Pre-EIP-2930
  * `"eip2930"` - Access list transactions
  * `"eip1559"` - Fee market transactions
  * `"eip4844"` - Blob transactions
  * `"eip7702"` - Account abstraction

### EIP-4844 (Blob Transactions)

* **blobGasUsed**: Gas used for blobs (optional)
* **blobGasPrice**: Price per blob gas (optional)

## Common Patterns

### Contract Creation

```typescript theme={null}
const creationReceipt = Receipt.from({
  // ... standard fields
  to: null,  // null indicates contract creation
  contractAddress: Address.fromHex('0x1234...'),
  // ...
})

if (creationReceipt.contractAddress) {
  console.log('Contract deployed at:',
    creationReceipt.contractAddress.toHex())
}
```

### Processing Logs

```typescript theme={null}
import * as EventLog from '@tevm/primitives/EventLog'

for (const log of receipt.logs) {
  console.log('Event from:', log.address.toHex())
  console.log('Topics:', log.topics.map(t => t.toHex()))
}
```

### Gas Analysis

```typescript theme={null}
const totalGasUsed = receipt.gasUsed
const totalCost = totalGasUsed * receipt.effectiveGasPrice

console.log('Gas used:', totalGasUsed)
console.log('Cost (wei):', totalCost)
```

### Status Checking

```typescript theme={null}
import * as TransactionStatus from '@tevm/primitives/TransactionStatus'

if (TransactionStatus.isSuccess(receipt.status)) {
  console.log('Transaction succeeded')
} else if (TransactionStatus.isFailed(receipt.status)) {
  console.error('Transaction failed:', receipt.status.revertReason)
}
```

### EIP-4844 Blob Transactions

```typescript theme={null}
if (receipt.type === 'eip4844' && receipt.blobGasUsed) {
  console.log('Blob gas used:', receipt.blobGasUsed)
  console.log('Blob gas price:', receipt.blobGasPrice)
}
```

## Type Alias

**TransactionReceiptType** - Alias for `ReceiptType`.

```typescript theme={null}
import type { TransactionReceiptType } from '@tevm/primitives/Receipt'
```

## Errors

**InvalidReceiptError**: Missing required field or invalid value.

## See Also

* [Receipt (Effect)](https://voltaire-effect.tevm.sh/primitives/receipt) - Effect.ts integration with Schema validation
* [TransactionHash](/primitives/transaction-hash) - Transaction identifier
* [TransactionIndex](/primitives/transaction-index) - Transaction position
* [TransactionStatus](/primitives/transaction-status) - Execution status
* [BlockHash](/primitives/block-hash) - Block identifier
* [BlockNumber](/primitives/block-number) - Block height
* [LogIndex](/primitives/log-index) - Log position
* [EventLog](/primitives/eventlog) - Event logs
* [Address](/primitives/address) - Ethereum addresses
