Reconcile the Internal Ledger Against On-Chain Wallet Balances

Last updated: November 29, 2026

Quick Overview

Given internal ledger entries per wallet and coin, a snapshot of on-chain balances, and a list of broadcast but unconfirmed outgoing transactions, write Python that reports every wallet and coin whose on-chain balance does not match what the ledger implies.

BitGo
Data Manipulation (SQL/Python)
Data Engineer
BitGo
November 29, 2026
Data Engineer
Take-home Project
Data Manipulation (SQL/Python)
Medium

0

0

0 solved


Given internal ledger entries per wallet and coin, a snapshot of on-chain balances, and a list of broadcast but unconfirmed outgoing transactions, write Python that reports every wallet and coin whose on-chain balance does not match what the ledger implies.

A custodian's core promise is that its books match the chain, and BitGo runs reconciliation across many coins and thousands of wallets. The exercise checks whether a candidate models timing differences (in-flight sends) correctly and produces a report finance can act on.

What the Interviewer Expects
  • Aggregates ledger entries in integer base units per wallet and coin
  • Accounts for broadcast but unconfirmed sends, including their fees
  • Includes keys that appear on only one side
  • Classifies differences as surplus or shortfall with a tolerance option
  • Explains likely causes of each class of break
Key Topics to Cover
reconciliation
aggregation
timing differences
ledger
data quality
How to Approach This
  1. Clarify the schema and expected output format before writing queries.
  2. Use CTEs (WITH clauses) to break complex queries into readable steps.
  3. Consider window functions (ROW_NUMBER, RANK, LAG, LEAD) for ranking and sequential analysis.
  4. Watch for NULLs, duplicates, and edge cases in JOINs and GROUP BY.
  5. For pandas, prefer vectorized operations over row-by-row iteration.
Possible Follow-up Questions
  • How would you handle a snapshot taken at block height H but a ledger cut at a wall-clock time?
  • How would you scale this to millions of addresses?
  • What should happen automatically when a shortfall is found?
  • How do token balances on ETH differ from native ETH?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice SQL Problems
Sample Answer
Clarify the Data

Ledger: signed base-unit entries; a withdrawal is booked as -(amount + fee) when it is broadcast. Chain snapshot: confirmed balance per (wallet, coin) at one block height. Pending: sends already i...

Approach

Sum the ledger per key. Add back in-flight amounts plus fees to get the balance the chain should show. Compare over the union of keys so a wallet missing from either side still shows up. Report the di...


Submit Your Answer
Markdown supported

Related Questions