Skip to content
dongowuPublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

47 Commits

Folders and files

Repository files navigation

Sui-Nexus

The settlement infrastructure for the AI agent economy on Sui.

πŸ† Sui Overflow 2026 β€” Agentic Web + Walrus Tracks

Live on Sui Testnet: 0x262b81797305980a5ddf2c509a6ac8fb9577dee6ac6c96ceba6580bd3dde5058 (Verify on Explorer)

Original v1 still addressable at 0xa051...4453 (audit trail, never deleted on Sui).

v2 upgrade (tx HEpaW4...AH5G): on-chain expected_price > 0 is now a hard requirement (was previously a stub). See move/sources/agent_wallet.move execute_trade for the rationale.


TL;DR

Sui-Nexus is the missing middle layer between AI agents and Sui. Instead of building another agent that trades, it builds the settlement infrastructure those agents need to trade safely on-chain: HMAC + zkLogin auth, Move-enforced wallet policy (not middleware-enforced), Walrus-backed memory, and PTB-based atomic execution.

Core innovation: Policy constraints (budget, protocol scope, time window, price floor) are enforced atomically in a Move smart contract β€” not in gateway middleware. The blockchain itself rejects policy violations. See Key Innovation.

# judge-friendly demo β€” no setup, no keys, no chain
HACKATHON_DEMO_MODE=true ./scripts/demo/run_agent_wallet_demo.sh
# open the dashboard it prints

🎯 Key Innovation: Policy Lives in Move, Not in Middleware

Most "AI agent wallets" check budget caps and protocol scope in backend middleware β€” a if amount > budget { return } in Python or Node.js that any agent can bypass by calling a different endpoint. Sui-Nexus does not.

The AgentWallet is a Move shared object. Every trade goes through a single execute_trade function in the Move contract, which atomically enforces all 7 policy constraints in one transaction:

Agent β†’ Gateway Guardian β†’ Move Contract (atomic 7-check enforcement on-chain)
                                ↓ fails any check β†’ whole tx reverts
# Constraint Move Check (agent_wallet.move:206-250) Bypassable?
1 Agent identity assert!(agent_addr == wallet.agent_address, ENotAuthorized) ❌ Chain-enforced
2 Wallet active assert!(wallet.is_active, EWalletRevoked) ❌ Chain-enforced
3 Time window assert!(epoch >= time_start && epoch <= time_end) ❌ Chain-enforced
4 Protocol allowlist vector::contains(&allowed_protocols, &protocol) ❌ Chain-enforced
5 Budget cap assert!(new_spent <= budget_cap_mist, EBudgetExceeded) ❌ Chain-enforced
6 Balance sufficiency assert!(balance >= amount_mist) ❌ Chain-enforced
7 Price-floor commitment assert!(expected_price > 0, EGuardianRejected) ❌ Chain-enforced

The gateway is a relay, not the authority. The Move contract is the authority.

This is defense-in-depth β€” the gateway Guardian (slippage, concentration checks) catches bad inputs early, and the Move contract enforces policy immutably on-chain. An agent that tries to overspend, use an unauthorized protocol, or skip the price floor gets rejected by the blockchain, not by a config file.


The Problem

Blocker Today Sui-Nexus
Key custody Agent must hold private keys β†’ security + compliance risk HMAC + zkLogin β€” no keys on the agent
Statelessness Agents lose context across sessions β†’ no learning loop Walrus + MemoryObject on-chain
No guardrails One bad prompt drains the wallet Move-enforced: budget cap, protocol allowlist, time window

Architecture

flowchart TB
    subgraph AgentLayer[" AI AGENT LAYER "]
        direction LR
        Agent1["Analyst Agent\n(Python, LLM)"]
        Agent2["Trader Agent\n(Python, LLM)"]
        Agent3["Custom Agents\n(Any Language)"]
    end

    subgraph Gateway[" GO GATEWAY (Gin) "]
        direction TB
        subgraph MW[" Middleware "]
            direction LR
            HMAC["HMAC Auth"]
            RL["Rate Limiter"]
            CORS["CORS / Recovery"]
        end
        subgraph API[" API Endpoints "]
            direction LR
            Intent["/api/v1/intent\nTrade submission"]
            Wallet["/api/v1/wallet/*\nPolicy-enforced ops"]
            ZK["/api/v1/auth/zklogin\nzkLogin OAuth"]
            WS["/ws\nReal-time dashboard"]
        end
        subgraph Guardian[" GUARDIAN RISK LAYER "]
            direction LR
            SL["Slippage <5%"]
            BC["Budget Cap"]
            PA["Protocol Allowlist"]
        end
        MW --> API --> Guardian
    end

    subgraph Infra[" INFRASTRUCTURE "]
        direction LR
        Kafka["Kafka Queue\n(async processing)"]
        Redis["Redis Cache\n(task/wallet state)"]
        WSHub["WebSocket Hub\n(live push)"]
    end

    subgraph PTB[" PTB BUILDER & EXECUTOR "]
        direction LR
        Swap["Swap (Cetus)"]
        Transfer["Transfer"]
        AgentW["AgentWallet"]
        DB["DeepBook Orders"]
    end

    subgraph Sui[" SUI BLOCKCHAIN "]
        direction TB
        subgraph Move[" Move Contracts "]
            direction LR
            AW["agent_wallet\nΒ· budget caps\nΒ· protocol scope\nΒ· time windows\nΒ· revocation"]
            AM["agent_memory\nΒ· Walrus blob ID\nΒ· task reference"]
            DEX["DeepBook / Cetus\nΒ· limit orders\nΒ· swap routes"]
        end
        WalrusLayer["WALRUS\nDecentralized AI context, logs, and cross-agent memory"]
        Move --> WalrusLayer
    end

    AgentLayer -- "HMAC" --> Gateway
    Gateway --> Infra
    Infra --> PTB
    PTB --> Sui
Loading

Key flows

  • Agent Wallet lifecycle β€” Owner creates wallet (Move policy) β†’ Agent authenticates via zkLogin (Google OAuth β†’ client-side ZK proof) β†’ Agent submits intent β†’ Guardian pre-checks (slippage / budget / protocol) β†’ PTB atomically enforces policy on-chain and executes via DeepBook/Cetus β†’ Owner can revoke at any time.
  • Cross-agent memory β€” Analyst writes LLM context to Walrus + mints a MemoryObject on-chain (blob_id + task_id) β†’ Trader reads blob via task lookup β†’ Trader submits an informed intent. Two agents, one shared memory, no off-chain coordination.

Sui Primitives

Primitive Usage Depth
PTB Atomic multi-agent settlement: swap β†’ distribute to N agents in one tx Core
Move Objects AgentWallet (policy state), MemoryObject (Walrus blob ref) Core
zkLogin Agent identity: Google OAuth β†’ client-side ZK proof β†’ Sui address Core
Walrus AI context storage: agent analysis, logs, cross-agent shared memory Core
DeepBook V3 Limit order placement within agent wallet policy bounds Integration

Track Submissions

πŸš€ One-Command Judge Demo (no setup needed)

HACKATHON_DEMO_MODE=true ./scripts/demo/run_agent_wallet_demo.sh

HACKATHON_DEMO_MODE is an explicit judge-friendly simulation path. It keeps the same HTTP API, Move-call plans, wallet policy cache, Guardian checks, WebSocket stream, and Walrus memory references, but uses deterministic local digests instead of submitting live Sui transactions. The live testnet path remains available by disabling demo mode and configuring signer / gas / funding / package IDs.

It then prints the dashboard URL β€” open it in a browser for the interactive console.

Track 1 β€” Agentic Web: "Intent Engine + Agent Wallet with zkLogin"

Key demo: scripts/demo/agent_wallet_demo.py β€” exercises the full lifecycle:

  1. Owner creates wallet with Move-enforced policy (e.g. 500 SUI budget, DeepBook only, 24h window)
  2. Agent authenticates via zkLogin (Google OAuth β†’ client-side ZK proof β†’ session)
  3. Agent executes trade within policy β†’ Guardian passes β†’ on-chain execution
  4. Agent attempts overspend β†’ rejected by Move contract (budget cap enforced on-chain)
  5. Owner revokes wallet β†’ agent permanently frozen β†’ WalletRevoked event emitted
  6. Activity log verified on-chain via Sui Explorer

Track 2 β€” Walrus: "AI Agent Memory System"

Key demo: scripts/demo/walrus_memory_demo.py β€” cross-agent persistent memory:

  1. Analyst Agent analyzes market news via LLM β†’ writes context to Walrus
  2. Gateway stores blob β†’ mints MemoryObject on-chain (blob_id + task_id)
  3. Trader Agent queries shared memory β†’ reads analyst's context from Walrus
  4. Trader submits a follow-up intent informed by the analyst's research

On-Chain Verification (Sui Testnet)

Contract Address Explorer
Package 0x262b81797305980a5ddf2c509a6ac8fb9577dee6ac6c96ceba6580bd3dde5058 (v2) View
Upgrade Cap 0x225f7b278c1fc2d3b5cf3d38a5f5e344463aaaf67f52a97b4a51008499a2145f View

Quick Start

Option A β€” Judge demo (recommended, 30 seconds)

HACKATHON_DEMO_MODE=true ./scripts/demo/run_agent_wallet_demo.sh

Open the printed dashboard URL.

Option B β€” Live testnet

# 1. env (minimum required for live mode)
export HMAC_SECRET_KEY="$(openssl rand -hex 32)"
export SUI_RPC_URL="https://fullnode.testnet.sui.io"
export SUI_SIGNER_PRIVATE_KEY="suiprivkey..."
export SUI_GAS_OBJECT_ID="0x..."
export SUI_FUNDING_OBJECT_ID="0x..."        # dedicated coin for wallet funding
export SUI_GAS_BUDGET="10000000"
export AGENT_WALLET_PACKAGE_ID="0x262b81797305980a5ddf2c509a6ac8fb9577dee6ac6c96ceba6580bd3dde5058"
export DEEPBOOK_PACKAGE_ID="0xdee9"         # DeepBook V3 testnet
export DEEPBOOK_POOL_ID="0x..."             # SUI/USDC pool

# 2. (optional) infra β€” Redis is optional, Kafka is only needed for /api/v1/intent
docker run -d --name redis -p 6379:6379 redis:alpine

# 3. gateway
go run cmd/gateway/main.go

# 4. live smoke check
bash scripts/demo/live_testnet_smoke.sh

Option C β€” Deploy Move contracts from source

cd move
sui move build
sui client publish --gas-budget 100000000   # save the new package ID

See docs/DORAHACKS_SUBMISSION.md for the submission guide and docs/ZKLOGIN_SETUP.md for zkLogin OAuth setup.


API (key endpoints)

Method Path Auth Purpose
POST /api/v1/wallet/create Owner session Create + fund Agent Wallet (Move)
POST /api/v1/wallet/execute zkLogin session Agent executes trade (Guardian + Move)
POST /api/v1/wallet/:id/revoke Owner session Owner revokes wallet
GET /api/v1/wallet/:id β€” Query wallet state
GET /api/v1/wallet/:id/activity β€” Query on-chain activity log
POST /api/v1/intent HMAC Submit agent trading intent
GET /api/v1/auth/zklogin OAuth Initiate zkLogin flow
GET /ws β€” WebSocket live task updates

Full reference: see router registration in internal/gateway/router.go.


Project Structure

sui-nexus/
β”œβ”€β”€ cmd/gateway/main.go            # Entry point
β”œβ”€β”€ internal/
β”‚   β”œβ”€β”€ gateway/                   # HTTP handlers, router, middleware, WS hub
β”‚   β”‚   └── zklogin/               # OAuth + ephemeral key + ZK proof
β”‚   β”œβ”€β”€ ptb/                       # PTB builder + Sui SDK / demo executor
β”‚   β”œβ”€β”€ kafka/                     # Async task queue (producer + consumer)
β”‚   β”œβ”€β”€ storage/                   # Redis task/wallet cache
β”‚   β”œβ”€β”€ walrus/                    # Walrus HTTP client
β”‚   β”œβ”€β”€ model/                     # Domain types
β”‚   └── config/                    # Env-driven config
β”œβ”€β”€ pkg/hmac/                      # HMAC-SHA256 signer
β”œβ”€β”€ move/sources/                  # agent_wallet.move, agent_memory.move
β”œβ”€β”€ scripts/demo/                  # Judge demos (Python + shell)
β”œβ”€β”€ web/dashboard.html             # Real-time WebSocket dashboard
└── docs/                          # DORAHACKS_SUBMISSION, RECORDING_GUIDE, ZKLOGIN_SETUP

Full per-file comments live at the top of each file. Deep dives: docs/DORAHACKS_SUBMISSION.md Β· docs/RECORDING_GUIDE.md Β· docs/ZKLOGIN_SETUP.md


License

MIT


Dev notes

Design tradeoffs and project rationale are documented in inline code comments.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages