MonmouthMonmouth Docs

Intent Parser

Overview

The Intent Parser precompile (0x1002) parses, validates, and normalizes agent intents at the protocol level. It ensures that intents are well-formed before they enter the resolution pipeline.

Address

0x0000000000000000000000000000000000001002

Use Cases

  • Intent validation: Verify intent structure before execution
  • Intent normalization: Standardize intent formats across agents
  • Nested intent parsing: Handle complex multi-step intents
  • Intent estimation: Estimate gas and output for an intent

Interface

interface IIntentParser {
    /// @notice Parse and validate an intent
    /// @param intentData ABI-encoded intent data
    /// @return intentType The classified intent type
    /// @return isValid Whether the intent is well-formed
    /// @return normalized The normalized intent data
    function parseIntent(
        bytes calldata intentData
    ) external view returns (
        uint8 intentType,
        bool isValid,
        bytes memory normalized
    );
 
    /// @notice Estimate execution cost for an intent
    /// @param intentData ABI-encoded intent data
    /// @return estimatedGas Estimated gas cost
    /// @return estimatedValue Estimated output value
    function estimateIntent(
        bytes calldata intentData
    ) external view returns (
        uint256 estimatedGas,
        uint256 estimatedValue
    );
 
    /// @notice Validate intent against agent guardrails
    /// @param intentData ABI-encoded intent data
    /// @param agentDid The agent's DID
    /// @return allowed Whether the intent is within guardrails
    /// @return reason Rejection reason (empty if allowed)
    function validateAgainstGuardrails(
        bytes calldata intentData,
        bytes32 agentDid
    ) external view returns (bool allowed, string memory reason);
}

SDK Usage

import { IntentParser } from '@monmouth/wallet-sdk'
 
const parser = new IntentParser(wallet)
 
// Parse and validate
const parsed = await parser.parse({
  type: 'swap',
  fromToken: 'ETH',
  toToken: 'USDC',
  amount: '1 ETH',
})
 
console.log(parsed)
// {
//   intentType: 'swap',
//   isValid: true,
//   normalized: { ... },
//   estimatedGas: 180000,
//   estimatedOutput: '1842.50 USDC',
// }
 
// Validate against guardrails
const validation = await parser.validateForAgent(intent, agentDid)
 
console.log(validation)
// { allowed: true }

Intent Types

Type CodeNameFields
0x01SwapfromToken, toToken, amount, maxSlippage
0x02Transfertoken, amount, recipient
0x03Lendingprotocol, action, token, amount
0x04Stakingvalidator, amount, action
0x05NFTcollection, tokenId, action
0x06Compositesteps[] (array of sub-intents)

Gas Costs

OperationGas
parseIntent10,000
estimateIntent20,000
validateAgainstGuardrails15,000
Per nested intent+2,000

On this page