# BEEF (BRC-62)

**BEEF** (<Hint tip="Background Evaluation Extended Format">Background Evaluation Extended Format</Hint>, <Hint tip="BSV Request for Comments 62">BRC-62</Hint>) is the binary format BSV uses to send a transaction together with the proof that it is real. A wallet or app that receives a BEEF package can check the transaction against block headers it already has, instead of asking a full node to confirm it. This check is called <Hint tip="Simplified Payment Verification">SPV</Hint>.

## Why BEEF Exists

Without BEEF, a recipient has two options when it gets a transaction:

- Trust whoever sent it, with no way to verify the claim.
- Query a full node to check every input, which is slow and means running or trusting someone else's node.

BEEF removes both problems. The sender bundles the transaction with everything needed to prove it, so the recipient can verify it on its own against block headers.

## What's Inside a BEEF Package

A BEEF package starts with a 4-byte version header, then three parts in a fixed order:

<Steps>
  <Step title="Version header">
    Always `0100BEEF`, so a parser can recognize the format immediately.
  </Step>
  <Step title="Merkle proofs (BUMPs)">
    One or more <Hint tip="BSV Unified Merkle Path, BRC-74">BUMPs</Hint>, the proofs that specific transactions are included in a mined block.
  </Step>
  <Step title="Ancestor transactions">
    The minimal chain of parent transactions needed to connect the final transaction to a proven ancestor.
  </Step>
  <Step title="The transaction itself">
    The actual transaction being sent, last in the package.
  </Step>
</Steps>

This order is not arbitrary: it lets the recipient start checking the Merkle proofs as soon as they arrive, before the rest of the package has even finished downloading.

## BUMPs: the Merkle Proofs

A BUMP is BSV's compact format for a Merkle proof (BRC-74). Two things make it efficient:

- It points to a **block height** instead of a block hash, which takes less space.
- Multiple transactions confirmed in the same block can share one BUMP, instead of each needing its own proof.

The `MerklePath` class in `@bsv/sdk` reads and writes BUMPs, including the compound case where several transactions share a proof.

## Ancestor Transactions: Building the Proof Chain

A transaction's inputs come from previous transactions, so verifying it means tracing those inputs back to something already proven. BEEF includes exactly the ancestors needed for that, no more: each one either has its own BUMP (it's confirmed) or is itself backed by further ancestors in the package.

The result is a chain: your transaction points back to its unconfirmed parents, which point back to confirmed ancestors with proofs attached.

## BEEF V2 (BRC-95)

BRC-95 extends the original format with a few additions, and `@bsv/sdk` reads and writes both versions. If your code needs to know which one it's handling, check `Beef.version`.

<Hint tip="BEEF for a single transaction, BRC-95">AtomicBEEF</Hint> is a related, narrower format used when only one transaction (plus its proof) needs to move, rather than a whole package.

## How Verification Happens

Because of the fixed ordering, a recipient can verify a BEEF package as a pipeline instead of waiting for everything to arrive first:

1. Start parsing the BUMPs as soon as they come in.
2. Check each BUMP against block headers from a header service (for example, `Chaintracks`).
3. Validate the ancestor transactions in order, each one checking its inputs against the part of the chain already verified.
4. Evaluate the final transaction once every input behind it is proven.

If any step fails, verification stops immediately rather than processing the rest of the bytes.

## Using BEEF in Code

```typescript
import { Beef, MerklePath, Transaction, WhatsOnChain } from '@bsv/sdk'

declare const tx: Transaction
declare const bump: MerklePath

// Build a BEEF package from a transaction and its proof
const beef = new Beef()
beef.mergeTransaction(tx)
beef.mergeBump(bump)
const bytes = beef.toBinary()

// Parse it back and verify
const parsed = Beef.fromBinary(bytes)
const isValid = await parsed.verify(new WhatsOnChain())
```

## Where You'll Run Into BEEF

BEEF shows up anywhere a transaction crosses a boundary between systems:

<CardGroup cols={2}>
  <Card title="Wallet actions" icon="wallet">
    `createAction` and `internalizeAction` in <Hint tip="The standard wallet-to-application interface">BRC-100</Hint> both move transactions as BEEF.
  </Card>
  <Card title="Overlay services" icon="layer-group">
    Any transaction submitted to an overlay through `engine.submit()` must be BEEF-encoded.
  </Card>
  <Card title="HTTP micropayments" icon="credit-card">
    A payment sent through BRC-121 (HTTP 402) carries its proof as BEEF in the request headers.
  </Card>
  <Card title="Peer-to-peer payments" icon="arrow-right-arrow-left">
    A BRC-29 payment between two parties is transmitted as BEEF.
  </Card>
</CardGroup>