Skip to content

feat: implement agent payment protocol with stream negotiation, on-chain micropayments, and CortexAgentSDK - #74

Merged
vestor-dev merged 1 commit into
CortexRail:mainfrom
Yunusabdul38:automouse-agent
Jul 24, 2026
Merged

feat: implement agent payment protocol with stream negotiation, on-chain micropayments, and CortexAgentSDK#74
vestor-dev merged 1 commit into
CortexRail:mainfrom
Yunusabdul38:automouse-agent

Conversation

@Yunusabdul38

Copy link
Copy Markdown
Contributor

Description

This pull request implements the payment protocol layer enabling autonomous agents to discover assets, negotiate rates, manage payment streams, and execute batch settlements programmatically.

Changes

Smart Contract (Rust)

  • Added batch_settle and get_claimable_batch functions to the micropayments contract.
  • Registered unit tests and resolved a withdrawal bug in withdraw.

Database

  • Added calls_remaining, calls_used, and price_per_call columns to the streams table.
  • Added row locking and call counter update functions in streamRepository.js.

Backend Layer

  • QuoteManager.js: HMAC-SHA256 signed price quotes with TTL memory caching.
  • StreamNegotiator.js: Off-chain rate negotiation and JWT stream token generation.
  • MeteringEngine.js: Atomic call counter decrementing using database transactions.
  • BatchSettler.js: Periodic bulk withdrawals on streams with 25 or more calls.
  • StreamMonitor.js: SSE registration and warning alerts at 10% remaining calls.
  • Exposed new API routes under /api/v1/protocol/*.

Agent SDK

  • CortexAgentSDK.js client covering the end-to-end lifecycle.
  • Complete TypeScript definitions (CortexAgentSDK.d.ts) and user documentation (README.md).

Verification

  • Smart contract unit tests (cargo test) pass.
  • Backend linter and Jest tests (npm run lint & npm test) pass.

Closes #14

@vestor-dev vestor-dev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement autonomous agent-to-agent micropayment protocol with stream lifecycle, metering, and SDK

2 participants