Bitcoin Extras Extension Format (BEEF) - an efficient way to package Bitcoin transactions with their verification data.
What is BEEF?
BEEF is a standardized format that combines:
- Transaction Data: The actual Bitcoin transaction
- Merkle Proofs: SPV verification data
- Block Headers: Chain validation information
- Metadata: Additional context and references
BEEF in the SDK
import { Transaction } from '@bsv/sdk'
// Create transaction with BEEF data
const tx = Transaction.fromHexBEEF(beefHex)
// Serialize transaction to BEEF
const beefData = transaction.toBEEF()
// Verify transaction using included proofs
const isValid = await tx.verify(chainTracker)
Key Benefits
Efficiency
- Compact: Includes only necessary verification data
- Self-Contained: No external lookups required
- Batch Processing: Multiple transactions in one package
SPV Integration
- Merkle Proofs: Verify transaction inclusion
- Block Headers: Validate proof of work
- Chain Context: Understand transaction position
Interoperability
- Standardized: Consistent format across applications
- Portable: Easy to transmit and store
- Compatible: Works with SPV clients
Use Cases
Transaction Broadcasting
// Broadcast transaction with proof
const beefTx = Transaction.fromHexBEEF(beefData)
await beefTx.broadcast(arcConfig)
Data Exchange
- Share transactions between applications
- Provide verification data to SPV clients
- Archive transactions with proofs
Wallet Integration
- Import transactions with full context
- Verify historical transactions
- Synchronize between devices
BEEF Structure
The format includes:
- Version: BEEF format version
- Transactions: One or more Bitcoin transactions
- Proofs: Merkle proofs for each transaction
- Headers: Relevant block headers
- Metadata: Additional application data
Best Practices
- Use BEEF for transactions that need verification
- Include minimal necessary proof data
- Validate BEEF structure before processing
- Cache parsed BEEF data for performance
Next Steps