MonmouthMonmouth Docs

Transaction Classification

Overview

Monmouth's transaction classification system automatically detects the intent behind every transaction. This happens at the protocol level — not via smart contracts or external oracles.

Classification powers routing, guardrail enforcement, and reputation tracking.

Classification Types

Every transaction is classified into one of five categories:

TypeDescriptionExample
SwapToken exchange operationsETH → USDC via DEX
TransferDirect asset movementSend 1 ETH to 0x...
LendingDeposit, borrow, repay, withdrawDeposit USDC into lending pool
StakingValidator delegation and rewardsStake ETH for yield
NFTMinting, transfers, marketplaceMint NFT, list for sale

Confidence Scoring

Each classification includes a confidence score (0.0 to 1.0):

const classification = await wallet.classifyTransaction(tx)
 
console.log(classification)
// {
//   type: 'swap',
//   confidence: 0.96,
//   details: {
//     fromToken: 'ETH',
//     toToken: 'USDC',
//     estimatedValue: '1842.50 USDC',
//     protocol: 'uniswap-v3',
//   }
// }

Confidence Thresholds

Configure minimum confidence for different actions:

const wallet = new MonmouthWallet({
  classification: {
    minConfidence: 0.85,          // Reject below 85%
    requireManualAbove: '5 ETH',  // Human review for high-value
    autoExecuteBelow: '0.1 ETH',  // Auto-execute small txs
  },
})

Classification Methods

Heuristic Classification

Function selector matching against known contract interfaces:

0x38ed1739 → swap (Uniswap V2)
0x5ae401dc → swap (Uniswap V3)
0xa9059cbb → transfer (ERC-20)
0x42842e0e → nft-transfer (ERC-721)

Semantic Classification

For complex or multi-step transactions, the classification engine analyzes:

  • Target contract type
  • Calldata structure
  • Token flow patterns
  • Historical patterns from the agent

Multi-Step Classification

Complex operations (e.g., flash loan + swap + repay) are classified as composite:

// {
//   type: 'composite',
//   confidence: 0.91,
//   steps: [
//     { type: 'lending', action: 'borrow', confidence: 0.95 },
//     { type: 'swap', confidence: 0.97 },
//     { type: 'lending', action: 'repay', confidence: 0.94 },
//   ]
// }

Integration with Other Primitives

Classification feeds into:

  • Guardrails: Block or flag transactions based on type
  • Reputation: Track success rate per classification type
  • Intent Resolution: Validate that resolved intent matches classification
  • Validation: Verify agent capability for classified operation type

On-Chain Interface

interface IClassification {
    function classifyTransaction(
        bytes calldata txData
    ) external view returns (
        uint8 classificationType,
        uint256 confidence
    );
}

On this page