Detailed Use Case & Demo

In our previous article, we introduced Sahara x402 as the foundation for a new kind of computational economy — one where autonomous agents deploy, verify, and govern intelligence through the same universal protocol.

To make the architecture more concrete, let’s walk through a real scenario: a multi-agent payment flow for a data request, where multiple agents freely access services and pay for them through the x402 serverless protocol — no permissions, no pre-approvals, no manual setup.

Here’s how it works:

  • A User asks a question.

  • The Planner Agent determines which downstream agents or tools are required.

  • The request flows through x/function, where policy checks, cost estimation, payments, and verifiable execution occur.

  • Service Providers run inside a TEE, compute the result, and receive payment instantly.

  • The entire network can verify both the computation and the payment, ensuring the result is trustworthy.

User Flow

  1. User asks a question to the planner Agent.

  2. Planner Agent discovers data service provider - Social Agent/Onchain Agent.

  3. Request to the social agent for tweets data

  4. Social agent spawned accordingly and start the computation

  5. Social agent publishes the payment bill: 0.002 USDC(According to the actual CPU workload and LLM token consumed).

  6. Planner Agent paid 0.002 USDC successfully to Social Agent’s address

  7. Everyone would be able to verify if this payment transaction actual competed and tweets data is actually delivered

  8. The whole process is running on the TEE

TEE Security Execution Phase

  • Agent A's TEE environment receives the payment request.

  • It verifies the service provider's identity and pricing rationality in an isolated environment.

  • It generates an ERC-3009 authorized signature without exposing the private key to the external environment.

  • The TEE output contains proof of payment authorization.

Payment Verification Phase

  • Service provider B verifies the payment authorization through the facilitator.

  • The TEE proof is submitted to the on-chain verification contract.

  • The multi-agent network confirms the consistency of the payment state.

Demo For Extension 1

Try the x/function enabled dApp: https://x-function.saharalabs.ai/

This reference implementation demonstrates the power of user-funded computation. Instead of developers managing always-on servers, the protocol allows users to trigger service deployment and execution via a small payment. It’s a true serverless model with no DevOps overhead for the creator.

This dApp turns the x402 payment flow into a serverless launchpad.

  • Devs: You define the code. The user pays the server bill.

  • Users: You get on-demand agents/services that run, complete your task, and vanish.

No setup. No subscriptions. Just pay-per-execution.

Demo For Extension 2

Agent Deployment and A2A Protocol Support

The demo below illustrates the process of deploying an agent and highlights the supported agent-to-agent (A2A) protocol, showcasing how it facilitates seamless communication between agents in a network. This demonstration aims to provide a practical understanding of both the deployment process and the protocol's integration.

Demo For Extension 3

The x/function/customized-policy adds a programmable rules layer that lets providers define and enforce “terms of use” for their data, models, and tools.

Demo Scenario

In this demo, we deploy a cryptocurrency question-answering LLM agent that processes crypto-related queries from users. The agent has access to a synthetic marketplace where four synthetic tools provide different cryptocurrency data and analytics services.

Each tool provider seeks to ensure their data is used in a safe and compliant manner by the requesting agent. To enforce this, they define usage policies that restrict how the provisioned data can be used. This synthetic environment and the objectives are illustrated below.

With the x/function/customized protocol, the tool providers can cryptographically verify:

  1. Integrity of Policy Compliance Checking: A trusted policy compliance function is correctly applied to evaluate whether the requesting agent's intended actions comply with the specified policies.

  2. Integrity of Policy Enforcement: A trusted policy enforcement mechanism is correctly applied during agent execution.

Workflow

In this implementation, the agent execution, policy compliance checking, and policy enforcement are all managed by an open-source hypervisor H running within a Trusted Execution Environment (TEE). After compliance checks pass, the hypervisor generates TEE attestation quotes containing the compliance results and passes them to the tools (or agents) in the marketplace. The tool providers verify the RTMR (Runtime Measurement Register) values and quote signatures in these attestations against the expected open-source hypervisor measurements.

In this way, the tool providers can cryptographically verify:

  1. The hypervisor's code integrity (via RTMR matching the known open-source build)

  2. That proper compliance checks were performed before their tools were invoked as specified in the hypervisor

  3. That the same hypervisor will continue to enforce policies after tool execution

This provides end-to-end assurance that policies are both checked before and enforced after tool invocation.

The workflow is illustrated as follows:

In conclusion, this approach ensures robust security and compliance by validating hypervisor integrity and adherence to policies throughout the tool execution process. For detailed information, refer to the our github repo here: https://github.com/SaharaLabsAI/x-function/blob/main/policy/README.md.

Last updated