# Copy-ready Beancount crypto transaction templates

This guide provides practical Beancount templates and real-world examples for common cryptocurrency scenarios. Copy and adapt these templates for your own [crypto accounting](https://beancount.io/docs/Solutions/cryptocurrency-portfolio-tracking) needs.

## How to read these blocks

Every fenced block below is one of three things, and they are not interchangeable:

- **Templates** contain `[BRACKETED]` placeholders and `YYYY-MM-DD` dates. They will **not** load until you substitute real values — the brackets are not Beancount syntax.
- **Examples** sit directly under their template, carry real dates and amounts, and are written to load. Each one still needs the accounts it touches to be open, which is what the **Account Structure Template** below is for. The one exception is the reconciliation block, which asserts balances only your own ledger can satisfy.
- The **Flash Loan Arbitrage** block is **pseudocode**, and is labelled as such where it appears.

Two conventions run through all of them:

- **Income accounts hold credits, so they are negative.** A realized gain is a *negative* posting to `Income:CapitalGains:…`; a realized loss is a *positive* posting to `Expenses:CapitalLoss:…`. Getting this backwards is the single most common way a crypto entry fails to balance.
- **A fee is recorded once as an expense and once as a reduction in cash.** Gross proceeds go to the cash account, the fee comes back out of it, and the difference is what actually lands in your account.

Explore a live cryptocurrency example ledger:

<LedgerEmbed
  username="open_ledger"
  ledger="crypto-example"
  page=""
  title="Cryptocurrency Example Ledger"
/>

## Basic Setup Template

### Account Structure Template

```bean
; =============================================================================
; CRYPTOCURRENCY ACCOUNT SETUP TEMPLATE
; =============================================================================

; Bank Accounts
1970-01-01 open Assets:Checking

; Exchange Accounts
1970-01-01 open Assets:Crypto:Coinbase:USD
1970-01-01 open Assets:Crypto:Coinbase:BTC
1970-01-01 open Assets:Crypto:Coinbase:ETH
1970-01-01 open Assets:Crypto:Binance:USD
1970-01-01 open Assets:Crypto:Binance:BTC
1970-01-01 open Assets:Crypto:Binance:ETH
1970-01-01 open Assets:Crypto:Binance:BNB
1970-01-01 open Assets:Crypto:Binance:ADA

; On-Chain and Mining Accounts
1970-01-01 open Assets:Crypto:Ethereum:ETH
1970-01-01 open Assets:Crypto:Polygon:ETH
1970-01-01 open Assets:Crypto:Mining:BTC

; Wallet Accounts
1970-01-01 open Assets:Crypto:Wallet:Ledger:BTC
1970-01-01 open Assets:Crypto:Wallet:Ledger:ETH
1970-01-01 open Assets:Crypto:Wallet:MetaMask:ETH
1970-01-01 open Assets:Crypto:Wallet:MetaMask:USDC
1970-01-01 open Assets:Crypto:Wallet:MetaMask:UNI

; DeFi Protocol Accounts
1970-01-01 open Assets:DeFi:Uniswap:ETH-USDC-LP
1970-01-01 open Assets:DeFi:Compound:CUSDC
1970-01-01 open Assets:Staking:Ethereum:ETH

; Income Accounts
1970-01-01 open Income:Crypto:Staking:ETH
1970-01-01 open Income:Crypto:Mining:BTC
1970-01-01 open Income:Crypto:Airdrops
1970-01-01 open Income:Crypto:DeFi:Yield
1970-01-01 open Income:CapitalGains:Crypto
1970-01-01 open Income:CapitalGains:LongTerm

; Expense Accounts
1970-01-01 open Expenses:Crypto:Fees:Trading
1970-01-01 open Expenses:Crypto:Fees:Network
1970-01-01 open Expenses:Crypto:Fees:Withdrawal
1970-01-01 open Expenses:Crypto:Bridge:Fees
1970-01-01 open Expenses:Crypto:Mining:Electricity
1970-01-01 open Expenses:CapitalLoss:Crypto

; Commodity Definitions
1970-01-01 commodity BTC
  name: "Bitcoin"
  asset-class: "cryptocurrency"

1970-01-01 commodity ETH
  name: "Ethereum"
  asset-class: "cryptocurrency"

1970-01-01 commodity USDC
  name: "USD Coin"
  asset-class: "stablecoin"

; Compound writes this receipt token "cUSDC", but a Beancount commodity
; and every account component must start with a capital letter or a digit,
; so the ledger spells it CUSDC and keeps the display name in metadata.
1970-01-01 commodity CUSDC
  name: "cUSDC (Compound USD Coin)"
  asset-class: "defi-receipt"
```

## Trading Templates

### Basic Cryptocurrency Purchase

```bean
; Template: Buy cryptocurrency on exchange
YYYY-MM-DD * "Buy [AMOUNT] [CRYPTO] on [EXCHANGE]"
  Assets:Crypto:[EXCHANGE]:[CRYPTO]     [AMOUNT] [CRYPTO] {[PRICE] USD}
  Assets:Crypto:[EXCHANGE]:USD         -[TOTAL_COST] USD
  Expenses:Crypto:Fees:Trading          [FEE] USD
  Assets:Crypto:[EXCHANGE]:USD         -[FEE] USD

; Example: Buy 1 BTC on Coinbase
2024-01-15 * "Buy 1 BTC on Coinbase"
  Assets:Crypto:Coinbase:BTC      1.0 BTC {45000.00 USD}
  Assets:Crypto:Coinbase:USD  -45000.00 USD
  Expenses:Crypto:Fees:Trading    50.00 USD
  Assets:Crypto:Coinbase:USD     -50.00 USD
```

### Cryptocurrency Sale

```bean
; Template: Sell cryptocurrency on exchange
YYYY-MM-DD * "Sell [AMOUNT] [CRYPTO] on [EXCHANGE]"
  Assets:Crypto:[EXCHANGE]:[CRYPTO]    -[AMOUNT] [CRYPTO] {[COST_BASIS] USD} @ [SALE_PRICE] USD
  Assets:Crypto:[EXCHANGE]:USD          [GROSS_PROCEEDS] USD
  Expenses:Crypto:Fees:Trading          [FEE] USD
  Assets:Crypto:[EXCHANGE]:USD         -[FEE] USD
  Income:CapitalGains:Crypto           -[GAIN] USD  ; a loss is a positive Expenses:CapitalLoss:Crypto instead

; Example: Sell 0.5 BTC with a gain
2024-03-20 * "Sell 0.5 BTC on Coinbase"
  Assets:Crypto:Coinbase:BTC     -0.5 BTC {45000.00 USD} @ 48000.00 USD
  Assets:Crypto:Coinbase:USD   24000.00 USD  ; gross proceeds, 0.5 * 48,000.00
  Expenses:Crypto:Fees:Trading    30.00 USD
  Assets:Crypto:Coinbase:USD     -30.00 USD  ; the fee leaves the same cash account
  Income:CapitalGains:Crypto   -1500.00 USD  ; 24,000.00 proceeds - 22,500.00 basis
```

The disposed lot is worth $22,500.00 at cost, the sale brings in $24,000.00 gross, and $30.00 of that goes to the exchange — so $23,970.00 of cash arrives and $1,500.00 of gain is realized. Do not net the fee into the gain: the fee is already an expense, and subtracting it a second time is what leaves the transaction unbalanced.

### Crypto-to-Crypto Trade

```bean
; Template: Trade one crypto for another
YYYY-MM-DD * "Trade [AMOUNT1] [CRYPTO1] for [AMOUNT2] [CRYPTO2]"
  Assets:Crypto:[EXCHANGE]:[CRYPTO1]   -[AMOUNT1] [CRYPTO1] {[COST_BASIS] USD}
  Assets:Crypto:[EXCHANGE]:[CRYPTO2]    [AMOUNT2] [CRYPTO2] {[NEW_PRICE] USD}
  Income:CapitalGains:Crypto           -[GAIN] USD  ; taxable event; a loss is a positive Expenses:CapitalLoss:Crypto
  Expenses:Crypto:Fees:Trading          [FEE] USD
  Assets:Crypto:[EXCHANGE]:USD         -[FEE] USD

; Example: Trade BTC for ETH
2024-02-10 * "Trade 1 BTC for 20 ETH on Binance"
  Assets:Crypto:Binance:BTC     -1.0 BTC {46000.00 USD}
  Assets:Crypto:Binance:ETH      20 ETH {2400.00 USD}
  Income:CapitalGains:Crypto  -2000.00 USD  ; 48,000.00 received - 46,000.00 basis
  Expenses:Crypto:Fees:Trading    40.00 USD
  Assets:Crypto:Binance:USD      -40.00 USD
```

A crypto-to-crypto trade disposes of the first commodity, so it realizes gain exactly like a sale for cash: 20 ETH acquired at $2,400.00 is $48,000.00 of value received against $46,000.00 of BTC basis. The $40.00 fee is paid in cash and does not change the gain.

## Transfer Templates

### Exchange to Wallet Transfer

```bean
; Template: Transfer crypto from exchange to wallet
YYYY-MM-DD * "Transfer [AMOUNT] [CRYPTO] from [EXCHANGE] to [WALLET]"
  Assets:Crypto:[EXCHANGE]:[CRYPTO]      -[AMOUNT] [CRYPTO] {[COST_BASIS] USD}
  Assets:Crypto:Wallet:[WALLET]:[CRYPTO]  [AMOUNT] [CRYPTO] {[COST_BASIS] USD}
  Expenses:Crypto:Fees:Withdrawal         [FEE] [CRYPTO] {[COST_BASIS] USD}
  Assets:Crypto:[EXCHANGE]:[CRYPTO]      -[FEE] [CRYPTO] {[COST_BASIS] USD}

; Example: Transfer BTC to Ledger
2024-01-20 * "Transfer 1 BTC from Coinbase to Ledger"
  Assets:Crypto:Coinbase:BTC      -1.0 BTC {45000.00 USD}
  Assets:Crypto:Wallet:Ledger:BTC  1.0 BTC {45000.00 USD}
  Expenses:Crypto:Fees:Withdrawal  0.0005 BTC {45000.00 USD}
  Assets:Crypto:Coinbase:BTC      -0.0005 BTC {45000.00 USD}
```

A transfer is **not** a disposal, so it realizes nothing: the same `{45000.00 USD}` cost travels with the coins and the receiving account inherits the basis. Two consequences follow. The withdrawal fee is paid *in* BTC and is expensed at that same cost, so it realizes no gain either — if your treatment says otherwise, price the fee with `@` and add a gain posting. And the sending account must already hold **1.0005 BTC at that exact cost**, not 1.0, because the fee comes out of the same lot. A reduction with no matching lot fails to book however well the totals add up.

### Cross-Exchange Transfer

```bean
; Template: Transfer between exchanges
YYYY-MM-DD * "Transfer [AMOUNT] [CRYPTO] from [EXCHANGE1] to [EXCHANGE2]"
  Assets:Crypto:[EXCHANGE1]:[CRYPTO]  -[AMOUNT] [CRYPTO] {[COST_BASIS] USD}
  Assets:Crypto:[EXCHANGE2]:[CRYPTO]   [AMOUNT] [CRYPTO] {[COST_BASIS] USD}
  Expenses:Crypto:Fees:Network         [FEE] [CRYPTO] {[COST_BASIS] USD}
  Assets:Crypto:[EXCHANGE1]:[CRYPTO]  -[FEE] [CRYPTO] {[COST_BASIS] USD}

; Example: Transfer ETH from Coinbase to Binance
2024-02-05 * "Transfer 10 ETH from Coinbase to Binance"
  Assets:Crypto:Coinbase:ETH   -10 ETH {2500.00 USD}
  Assets:Crypto:Binance:ETH     10 ETH {2500.00 USD}
  Expenses:Crypto:Fees:Network  0.01 ETH {2500.00 USD}
  Assets:Crypto:Coinbase:ETH   -0.01 ETH {2500.00 USD}
```

## Staking Templates

### Ethereum Staking

```bean
; Template: Stake ETH
YYYY-MM-DD * "Stake [AMOUNT] ETH"
  Assets:Crypto:Wallet:MetaMask:ETH    -[AMOUNT] ETH {[PRICE] USD}
  Assets:Staking:Ethereum:ETH           [AMOUNT] ETH {[PRICE] USD}
  Expenses:Crypto:Fees:Network          [FEE] ETH {[PRICE] USD}
  Assets:Crypto:Wallet:MetaMask:ETH    -[FEE] ETH {[PRICE] USD}

; Example: Stake 32 ETH
2024-01-10 * "Stake 32 ETH on Ethereum 2.0"
  Assets:Crypto:Wallet:MetaMask:ETH    -32 ETH {2500.00 USD}
  Assets:Staking:Ethereum:ETH           32 ETH {2500.00 USD}
  Expenses:Crypto:Fees:Network          0.01 ETH {2500.00 USD}
  Assets:Crypto:Wallet:MetaMask:ETH    -0.01 ETH {2500.00 USD}
```

### Staking Rewards

```bean
; Template: Receive staking rewards
YYYY-MM-DD * "[CRYPTO] Staking Rewards - [PERIOD]"
  Assets:Staking:[PROTOCOL]:[CRYPTO]    [AMOUNT] [CRYPTO] {[PRICE] USD}
  Income:Crypto:Staking:[CRYPTO]       -[VALUE] USD  ; [VALUE] = [AMOUNT] * [PRICE]

; Example: ETH staking rewards
2024-02-01 * "ETH Staking Rewards - January"
  Assets:Staking:Ethereum:ETH     0.08 ETH {2600.00 USD}
  Income:Crypto:Staking:ETH     -208.00 USD  ; 0.08 * 2,600.00
```

A reward is income received in kind, so the two postings describe the same event from both sides: 0.08 ETH arrives with a $2,600.00-per-unit basis, and the matching $208.00 of income is a credit — negative. The `{2,600.00 USD}` is **an external price you have to source yourself**; Beancount records it, it does not fetch it. Note it from the exchange or index you actually use, and keep the same source across the year.

That $208.00 is also the reward's cost basis from here on. When you eventually sell the 0.08 ETH, only the movement *since* this date is a gain — the $208.00 has already been taxed as income and must not be recognized twice. Whether the income is taxable on receipt or on disposal differs by jurisdiction; the ledger records the facts either way.

## DeFi Templates

### Uniswap Liquidity Provision

```bean
; Template: Add liquidity to Uniswap pool
YYYY-MM-DD * "Add liquidity to [TOKEN1]-[TOKEN2] pool"
  Assets:Crypto:Wallet:MetaMask:[TOKEN1]    -[AMOUNT1] [TOKEN1] {[PRICE1] USD}
  Assets:Crypto:Wallet:MetaMask:[TOKEN2]    -[AMOUNT2] [TOKEN2] {[PRICE2] USD}
  Assets:DeFi:Uniswap:[TOKEN1]-[TOKEN2]-LP   [LP_AMOUNT] [LP_TOKEN] {[LP_PRICE] USD}
  Expenses:Crypto:Fees:Network               [FEE] ETH {[ETH_PRICE] USD}
  Assets:Crypto:Wallet:MetaMask:ETH         -[FEE] ETH {[ETH_PRICE] USD}

; Example: Add ETH-USDC liquidity
2024-01-15 * "Add liquidity to ETH-USDC pool"
  Assets:Crypto:Wallet:MetaMask:ETH     -10 ETH {2500.00 USD}
  Assets:Crypto:Wallet:MetaMask:USDC  -25000 USDC @ 1.00 USD
  Assets:DeFi:Uniswap:ETH-USDC-LP        100 UNI-V3-ETH-USDC {500.00 USD}
  Expenses:Crypto:Fees:Network          0.02 ETH {2500.00 USD}
  Assets:Crypto:Wallet:MetaMask:ETH    -0.02 ETH {2500.00 USD}
```

Reconcile this one commodity at a time: $25,000.00 of ETH plus $25,000.00 of USDC leaves, $50,000.00 of LP token arrives, and the gas fee moves $50.00 of ETH from the wallet into an expense. The stablecoin leg carries `@ 1.00 USD` because it is held without a cost basis — without the price annotation its weight is 25,000 `USDC`, which cannot cancel dollars. In many jurisdictions depositing into a pool is itself a disposal of both tokens; this entry deliberately carries basis across instead, so add the gain postings if your treatment requires them.

### Compound Lending

```bean
; Template: Supply assets to Compound
YYYY-MM-DD * "Supply [AMOUNT] [TOKEN] to Compound"
  Assets:Crypto:Wallet:MetaMask:[TOKEN]  -[AMOUNT] [TOKEN] @ [TOKEN_PRICE] USD
  Assets:DeFi:Compound:C[TOKEN]           [C_AMOUNT] C[TOKEN] {[C_PRICE] USD}
  Expenses:Crypto:Fees:Network            [FEE] ETH {[ETH_PRICE] USD}
  Assets:Crypto:Wallet:MetaMask:ETH      -[FEE] ETH {[ETH_PRICE] USD}

; Example: Supply USDC to Compound
2024-01-20 * "Supply 10000 USDC to Compound"
  Assets:Crypto:Wallet:MetaMask:USDC  -10000 USDC @ 1.00 USD
  Assets:DeFi:Compound:CUSDC             500 CUSDC {20.00 USD}
  Expenses:Crypto:Fees:Network          0.008 ETH {2500.00 USD}
  Assets:Crypto:Wallet:MetaMask:ETH    -0.008 ETH {2500.00 USD}
```

Two things make this one load. The USDC leg carries `@ 1.00 USD` so both sides of the swap weigh in the same currency — without it Beancount sees $10,000.00 of `CUSDC` appearing against 10,000 units of `USDC` disappearing, which are different commodities and do not cancel. And the receipt token is `CUSDC`, not `cUSDC`: a lowercase first letter is a lexer error in both an account component and a commodity symbol, however the protocol spells it in its own interface.

## Mining Templates

### Mining Rewards

```bean
; Template: Receive mining rewards
YYYY-MM-DD * "[CRYPTO] Mining Reward - [POOL/SOLO]"
  Assets:Crypto:Mining:[CRYPTO]     [AMOUNT] [CRYPTO] {[PRICE] USD}
  Income:Crypto:Mining:[CRYPTO]    -[VALUE] USD  ; [VALUE] = [AMOUNT] * [PRICE]

; Example: Bitcoin mining reward
2024-01-15 * "BTC Mining Reward - Slush Pool"
  Assets:Crypto:Mining:BTC    0.01 BTC {45000.00 USD}
  Income:Crypto:Mining:BTC  -450.00 USD  ; 0.01 * 45,000.00
```

### Mining Expenses

```bean
; Template: Mining operational expenses
YYYY-MM-DD * "Mining [EXPENSE_TYPE] - [PERIOD]"
  Expenses:Crypto:Mining:[EXPENSE_TYPE]  [AMOUNT] USD
  Assets:Checking                       -[AMOUNT] USD

; Example: Mining electricity costs
2024-01-31 * "Mining Electricity - January"
  Expenses:Crypto:Mining:Electricity  800.00 USD
  Assets:Checking                    -800.00 USD
```

## Airdrop Templates

### Token Airdrops

```bean
; Template: Receive token airdrop
YYYY-MM-DD * "[TOKEN] Airdrop from [PROJECT]"
  Assets:Crypto:Wallet:[WALLET]:[TOKEN]  [AMOUNT] [TOKEN] {[PRICE] USD}
  Income:Crypto:Airdrops                -[VALUE] USD  ; [VALUE] = [AMOUNT] * [PRICE]

; Example: UNI token airdrop
2024-03-01 * "UNI Airdrop from Uniswap"
  Assets:Crypto:Wallet:MetaMask:UNI   400 UNI {8.00 USD}
  Income:Crypto:Airdrops            -3200.00 USD  ; 400 * 8.00
```

Like a staking reward, the airdrop's recognized value becomes its cost basis. Record the price you can defend — the token's first liquid quote, from a source you name — rather than a round number.

## Advanced Templates

### Flash Loan Arbitrage

**This block is pseudocode, not a template.** It sketches the sequence of value movements inside a flash loan. It will not load even after you substitute values, because the blank lines between the groups end the transaction — Beancount reports a syntax error on the postings that follow one. Record a real flash loan as a single transaction with no blank lines (labelling the legs with indented `;` comments), dropping the intermediate legs that net to zero within the same block.

```text
Pseudocode: flash loan arbitrage

  borrow      Assets:Crypto:Temp:FlashLoan       +[LOAN_AMOUNT] [TOKEN]
              Liabilities:DeFi:[PROTOCOL]:Flash  -[LOAN_AMOUNT] [TOKEN]

  execute     Assets:Crypto:Temp:FlashLoan       -[LOAN_AMOUNT] [TOKEN]
              Assets:Crypto:Temp:Arbitrage       +[RETURN_AMOUNT] [TOKEN]

  repay       Liabilities:DeFi:[PROTOCOL]:Flash  +[LOAN_AMOUNT] [TOKEN]
              Assets:Crypto:Temp:Arbitrage       -[LOAN_PLUS_FEE] [TOKEN]

  keep        Assets:Crypto:Wallet:[WALLET]:[TOKEN]  +[PROFIT] [TOKEN]
              Income:Crypto:Arbitrage                -[PROFIT_USD] USD
```

Everything the loan touched is gone by the end of the block, so what the ledger actually needs to record is the profit and the protocol fee. The [arbitrage example](https://beancount.io/docs/Solutions/cryptocurrency-portfolio-tracking) in the portfolio-tracking guide shows the single-transaction shape.

### Cross-Chain Bridge

```bean
; Template: Bridge assets across chains
YYYY-MM-DD * "Bridge [AMOUNT] [TOKEN] from [CHAIN1] to [CHAIN2]"
  Assets:Crypto:[CHAIN1]:[TOKEN]     -[AMOUNT] [TOKEN] {[PRICE] USD}
  Assets:Crypto:[CHAIN2]:[TOKEN]      [AMOUNT] [TOKEN] {[PRICE] USD}
  Expenses:Crypto:Bridge:Fees         [FEE] [TOKEN] {[PRICE] USD}
  Assets:Crypto:[CHAIN1]:[TOKEN]     -[FEE] [TOKEN] {[PRICE] USD}

; Example: Bridge ETH to Polygon
2024-02-05 * "Bridge 5 ETH from Ethereum to Polygon"
  Assets:Crypto:Ethereum:ETH     -5 ETH {2600.00 USD}
  Assets:Crypto:Polygon:ETH       5 ETH {2600.00 USD}
  Expenses:Crypto:Bridge:Fees    0.01 ETH {2600.00 USD}
  Assets:Crypto:Ethereum:ETH    -0.01 ETH {2600.00 USD}
```

## Tax-Optimized Templates

### Tax Loss Harvesting

```bean
; Template: Tax loss harvesting
YYYY-MM-DD * "Tax loss harvesting - Sell [CRYPTO] at loss"
  Assets:Crypto:[EXCHANGE]:[CRYPTO]    -[AMOUNT] [CRYPTO] {[HIGH_COST_BASIS] USD}
  Assets:Crypto:[EXCHANGE]:USD          [PROCEEDS] USD
  Expenses:Crypto:Fees:Trading          [FEE] USD
  Assets:Crypto:[EXCHANGE]:USD         -[FEE] USD
  Expenses:CapitalLoss:Crypto           [LOSS] USD

; Example: Harvest ADA loss
2024-12-15 * "Tax loss harvesting - Sell ADA at loss"
  Assets:Crypto:Binance:ADA      -1000 ADA {0.60 USD} @ 0.45 USD
  Assets:Crypto:Binance:USD       450.00 USD  ; gross proceeds, 1,000 * 0.45
  Expenses:Crypto:Fees:Trading      5.00 USD
  Assets:Crypto:Binance:USD        -5.00 USD
  Expenses:CapitalLoss:Crypto     150.00 USD  ; 600.00 basis - 450.00 proceeds
```

The loss is the mirror image of a gain: $600.00 of basis leaves, $450.00 of gross proceeds arrive, and the $150.00 difference is a *positive* posting to an expense account. $445.00 of cash is what actually lands, after the $5.00 fee.

### Long-term Capital Gains

```bean
; Template: Long-term capital gains sale
YYYY-MM-DD * "Long-term sale - [CRYPTO] held > 1 year"
  date-acquired: "[PURCHASE_DATE]"
  holding-period: "[DAYS] days"
  Assets:Crypto:[EXCHANGE]:[CRYPTO]    -[AMOUNT] [CRYPTO] {[COST_BASIS] USD} @ [SALE_PRICE] USD
  Assets:Crypto:[EXCHANGE]:USD          [GROSS_PROCEEDS] USD
  Expenses:Crypto:Fees:Trading          [FEE] USD
  Assets:Crypto:[EXCHANGE]:USD         -[FEE] USD
  Income:CapitalGains:LongTerm         -[GAIN] USD

; Example: Long-term BTC sale
2025-02-01 * "Long-term sale - BTC held 382 days"
  date-acquired: "2024-01-15"
  holding-period: "382 days"
  Assets:Crypto:Coinbase:BTC     -1.0 BTC {45000.00 USD} @ 55000.00 USD
  Assets:Crypto:Coinbase:USD   55000.00 USD
  Expenses:Crypto:Fees:Trading    50.00 USD
  Assets:Crypto:Coinbase:USD     -50.00 USD
  Income:CapitalGains:LongTerm -10000.00 USD  ; 55,000.00 proceeds - 45,000.00 basis
```

The gain is $10,000.00, not $9,950.00: the $50.00 fee is already recorded as an expense, so netting it into the gain would deduct it twice. `Income:CapitalGains:LongTerm` is a separate account from `Income:CapitalGains:Crypto` only so the holding period is visible in a report — Beancount does not compute holding periods for you, which is why the `date-acquired` and `holding-period` metadata are worth carrying.

## Reconciliation Templates

### Monthly Balance Verification

```bean
; Template: Monthly balance assertions
YYYY-MM-DD balance Assets:Crypto:[EXCHANGE]:[CRYPTO]  [EXPECTED_BALANCE] [CRYPTO]
YYYY-MM-DD balance Assets:Crypto:Wallet:[WALLET]:[CRYPTO]  [EXPECTED_BALANCE] [CRYPTO]

; Example: January balance verification
2024-01-31 balance Assets:Crypto:Coinbase:BTC    2.5 BTC
2024-01-31 balance Assets:Crypto:Binance:ETH    15.0 ETH
2024-01-31 balance Assets:Crypto:Wallet:Ledger:BTC  1.0 BTC
```

Unlike the other examples here, this one is **not** self-contained by design: the amounts are whatever your own exchange screens say, and the assertion fails until your transactions are in the ledger — which is the entire point of it. Note that `balance` checks the balance at the **start** of the named day, so date the assertion the day *after* the period you are closing.

### Price Updates

```bean
; Template: Daily price updates
YYYY-MM-DD price [CRYPTO] [PRICE] USD

; Example: Daily prices
2024-01-15 price BTC 45000.00 USD
2024-01-15 price ETH 2500.00 USD
2024-01-15 price ADA 0.50 USD
```

For a hosted ledger, [Live Prices](https://beancount.io/docs/live-prices) can maintain supported crypto valuation prices automatically. Keep the static prices above for reproducible examples. Managed prices do not populate a trade price, staking income, or an airdrop cost basis; record those transaction values explicitly.

## Usage Instructions

1. **Copy the relevant template** for your transaction type
2. **Replace every placeholder.** A template is not valid Beancount until `YYYY-MM-DD` and each `[BRACKETED]` token is gone — brackets are not Beancount syntax, and a leftover one is a parse error, not a silently ignored value. Substituting is mechanical:

   | Placeholder | Substitute | Example |
   | :--------------- | :----------------------------------------------- | :----------------- |
   | `YYYY-MM-DD` | the transaction's date | `2024-03-20` |
   | `[AMOUNT]` | units of the commodity, unquoted | `0.5` |
   | `[CRYPTO]` | the commodity symbol, uppercase | `BTC` |
   | `[EXCHANGE]` | the account component for the venue | `Coinbase` |
   | `[COST_BASIS]` | the **per-unit** cost of the lot you are removing | `45000.00` |
   | `[SALE_PRICE]` | the **per-unit** price you sold at | `48000.00` |
   | `[GROSS_PROCEEDS]` | `[AMOUNT]` × `[SALE_PRICE]`, before fees | `24000.00` |
   | `[FEE]` | the venue's fee, in the currency it was charged | `30.00` |
   | `[GAIN]` | `[GROSS_PROCEEDS]` − `[AMOUNT]` × `[COST_BASIS]` | `1500.00` |

   Substituting that column into the **Cryptocurrency Sale** template reproduces the worked example printed under it, which is the quickest way to check you have read the template correctly.

3. **Adjust account names** to match [your account structure](https://beancount.io/docs/Basics/cheatsheet), and make sure each one is opened by the **Account Structure Template** — an account that is never opened is a load error, not a warning
4. **Add metadata** as needed for [tax reporting](/blog/2026/06/05/independent-cryptocurrency-miner-staking-validator-defi-yield-farmer-bookkeeping-form-1099-da-rev-rul-2023-14-obbba-section-174-fbar-form-8938-self-employment-tax-cost-per-coin-mined-kpi-guide) or tracking
5. **Verify calculations** with `bea --file your-file.bean check` before finalizing entries. An entry that does not balance, or that reduces a lot you do not hold, fails there rather than quietly producing a wrong report

## Best Practices

- Use consistent naming conventions
- Include transaction IDs in metadata
- Document complex transactions thoroughly
- Verify exchange rates and prices
- Maintain regular backups of your files

These templates provide a solid foundation for cryptocurrency accounting in Beancount.io. Customize them based on your specific needs and trading patterns.
