Development of Crypto Transaction Classification System
Correct transaction classification is the foundation of proper tax accounting. Trade, income, airdrop, staking reward — each type has different tax treatment in each jurisdiction. Automatic classification reduces manual work 80-90% for most users.
Classification Hierarchy
enum TaxCategory {
// Capital events
BUY = "buy",
SELL = "sell",
SWAP = "swap",
NFT_MINT = "nft_mint",
NFT_SALE = "nft_sale",
NFT_ROYALTY = "nft_royalty",
// Income events
STAKING_REWARD = "staking_reward",
MINING_REWARD = "mining_reward",
LENDING_INTEREST = "lending_interest",
LIQUIDITY_FEES = "liquidity_fees",
AIRDROP = "airdrop",
HARD_FORK = "hard_fork",
REFERRAL = "referral",
PLAY_TO_EARN = "play_to_earn",
// Non-taxable
TRANSFER = "transfer",
COLLATERAL_DEPOSIT = "collateral",
COLLATERAL_RETURN = "collateral_return",
WRAPPED_TOKEN_MINT = "wrap",
WRAPPED_TOKEN_BURN = "unwrap",
LP_DEPOSIT = "lp_deposit",
LP_WITHDRAWAL = "lp_withdrawal",
// Gas
GAS_FEE = "gas_fee",
UNCLASSIFIED = "unclassified",
}
Classification Engine
class TransactionClassifier {
async classify(tx: UnifiedTransaction, userContext: UserContext): Promise<ClassificationResult> {
const rules = this.getRulesForContext(userContext);
for (const rule of rules) {
const result = await rule.apply(tx, userContext);
if (result.matched) {
return {
category: result.category,
confidence: result.confidence,
ruleId: rule.id,
};
}
}
return {
category: TaxCategory.UNCLASSIFIED,
confidence: 0,
requiresManualReview: true,
};
}
}
ML Fallback
class TransactionMLClassifier:
def predict(self, tx_features):
features = self.extract_features(tx_features)
prediction = self.model.predict([features])[0]
confidence = max(self.model.predict_proba([features])[0])
return { "category": prediction, "confidence": confidence }
Classification system with rules engine, ML fallback and manual review queue — 2-4 weeks development.







