Truebasis

Truebasis
RoleCreator & Lead Architect
PeriodApr 2026 — Jul 2026
TechGo (Golang), go-ethereum, gRPC, Next.js 16, NestJS, MongoDB, Redis, Docker Compose, Hardhat
Cool Links-
LocationRemote

System Concept

Truebasis was created to address a primary challenge in Web3 financial tracking: the accurate calculation of token cost basis and unrealized capital gains. Rather than relying on simple snapshot balances, Truebasis reconstructs a precise double-entry transaction ledger chronologically from address histories, determining cost-basis using First-In, First-Out (FIFO) tax rules.

Truebasis Portfolio Dashboard Interface
Truebasis dynamic portfolio tracker: showcasing currency conversions, aggregated address balances, and tax lot breakdown cards.

The system is built as a polyglot microservice architecture. A high-performance Go daemon leverages go-ethereum (Geth) to maintain live WebSocket subscriptions to EVM nodes, decode raw ABI event topics, stream structured transactions into Redis, and expose a gRPC control plane for historical block range queries. The NestJS backend consumes these event streams, manages double-entry MongoDB journal entries, and handles JWT auth, while the Next.js frontend delivers a responsive real-time portfolio dashboard.

Polyglot Microservices Stack
Go EVM RPC IndexerGo 1.26 & go-ethereumMaintains live WebSocket subscriptions to EVM nodes, decodes raw ABI event topics, pushes to Redis, and serves gRPC sync endpoints.
Backend API & LedgerNestJS & MongoDB (Mongoose)Consumes Redis event streams, manages double-entry journal ACID sessions, recalculates FIFO tax lots, and exposes REST endpoints.
Frontend Web AppNext.js 16 (App Router)Renders a dark-mode portfolio dashboard with TanStack Query, wallet filter carousels, real-time currency conversions, and expandable lot breakdowns.
Message Bus & CacheRedis (ioredis & go-redis)Acts as the decoupled event bus between Go and NestJS via pub/sub channels and reliable queue lists (events:evm:transfers).
Simulated TestnetHardhat Network EVM nodeDeploys mock ERC20 tokens, staking pools, and constant-product AMMs locally to seed deterministic test events without mainnet rate limits.
Container OrchestrationDocker ComposeWires together all heterogeneous services (MongoDB, Redis, Go Indexer, NestJS API, Next.js Web) with health checks and isolated network bridges.

Go EVM RPC Indexer & gRPC Control Plane

Blockchain network I/O is inherently high-concurrency and data-intensive. Rather than overloading the Node.js event loop with persistent raw socket parsing and binary ABI log unpacking, I extracted the blockchain telemetry layer into a standalone Go microservice using go-ethereum (Geth).

Go Microservice Event Ingestion & Control Plane
1. WebSocket SubGo daemon maintains persistent WebSocket connection to EVM node (ethclient.SubscribeFilterLogs)
2. ABI Log DecodingUnpacks raw 32-byte topics & hex data into typed structs (Transfer(from, to, value))
3. Redis Stream PushPublishes JSON events to queue list & pub/sub channel for decoupled NestJS ingestion
4. gRPC Control PlaneNestJS triggers on-demand historical block range scans via TriggerAddressSync RPC
Why Go for Blockchain Indexing?
  • Native go-ethereum ABI reflection and keccak hash optimizations.
  • Lightweight goroutines per contract subscription without thread contention.
  • Sub-millisecond serialization latency and predictable, minimal memory footprint.
Clean Architectural Boundary
  • Go owns RPC connections, ABI log unpacking, and Redis publishing.
  • NestJS owns MongoDB transactions, user authentication, and business rules.
  • Redis prevents tight coupling, enabling zero-downtime service restarts.

FIFO Replay Engine

Truebasis determines cost basis dynamically by chronological transaction-ledger replay instead of static balance points. During synchronization, the core engine processes address histories, filters spam or airdrop scam tokens, and replays each transfer in block order.

When an inbound credit is processed, the engine pushes a new lot onto an in-memory FIFO stack, storing the precise quantity, unit price, date, and transaction hash. Outbound debits consume lots from the bottom of the stack (oldest first). If an outbound transfer targets another user-owned wallet, the engine performs a cost-basis preservation split, replicating the consumed lot in the recipient's wallet at its original acquisition price.

FIFO Transaction Replay Pipeline
Genesis SyncDeletes existing lots → Replays historical ledger in mined order → Saves lastSyncAt
IncrementalFilters transactions mined after lastSyncAt → Appends updates in real-time
Replica SplitMatches internal transfers → Backfills credit with sender's cost & date

DeFi Position Modeling

Tracking DeFi positions (staking pools, yield aggregators, and AMM pools) requires decomposing complex tokens. Truebasis monitors rebasing stakes (like stETH) and reward-bearing tokens (like rETH) to update quantities dynamically. Interest harvested from lending positions is integrated as zero-cost CREDIT entries, updating the average cost basis automatically.

Liquidity pools are modeled dynamically. Depositing tokens into a pool is recorded as a trade (SWAP) of constituent assets for LP shares. Redeeming is mapped as a debit of the LP tokens and credit of the returned tokens, calculating gains or losses against the LP share acquisition cost.

Web3 Auth Roadmap (SIWE)

To supplement standard email and GitHub OAuth credentials, the integration spec introduces Sign-In with Ethereum (SIWE - ERC-4361). This provides cryptographic session authentication, letting users sign in securely via browser-injected private keys.

1. Challenge NonceGET /auth/nonceGenerates a random, time-sensitive cryptographic string on the server to prevent replay attacks.
2. EIP-191 SignaturesignMessage()Requests private key cryptographic signature of the formatted SIWE challenge in the browser.
3. Verification JWTPOST /auth/verifyBackend verifies signature using ECRecover, fetches user address, and returns a secure JWT token.

Interactive FIFO Sandbox

Interact with the live simulator below to explore the core FIFO replay engine and cryptographic SIWE flow in real-time. Toggle between tabs, add manual buys/sells/transfers, and trigger step-by-step walk-throughs to see how lots are processed.

Truebasis Interactive Ledger SandboxSimulate cryptocurrency database ledgers, FIFO lot stack adjustments, and Web3 cryptographic signature flows.
Asset Balance0.00 ETH
Net Worth (Current)$0.00
Total Cost Basis$0.00
Unrealized Profit/Loss$0.00(0.0%)
Replay Walkthrough (FIFO Engine)
Manual Transaction Input
Active Cost-Basis Lots StackFIFO Queue (Bottom-first consumption)
No active tax lots found. Run Genesis Sync to build the database lot queue.
FIFO Ledger Event Replay Stream

Milestones

NestJS Modular Backend API Setup|Backend

Apr 2026

Genesis Sync & FIFO Stack Rebuild Engine|Backend/Database

May 2026

Dynamic DeFi Staking & LP Calculation|Protocol API

May 2026

Hardhat Ethers Simulation Harness Deploy|Simulation

Jun 2026

Interactive Next.js Dashboard Frontend|Frontend/Design

Jun 2026

Go EVM RPC Indexer & gRPC Microservice|Distributed Systems / Go

Jul 2026

Closing Thoughts

Truebasis serves as a robust foundation for automated tax lot accounting and real-time blockchain telemetry. The combination of Go for low-level EVM indexing and TypeScript for rich ledger modeling showcases a production-ready polyglot architecture.