Skip to main content

scafonix-agent

Next-Generation Non-Custodial M-of-N MPC Security & x402 USDC Payment Infrastructure for Autonomous AI Agents

scafonix-agent is the official Python SDK providing 100% Non-custodial M-of-N Threshold Signature Wallets and x402 USDC Micropayment Infrastructure for autonomous AI Agents (LangChain, CrewAI, AutoGen, ELIZA, etc.).


💻 Installation

pip install scafonix-agent

🔑 Return Data Structure Example

Dictionary structure returned when calling agent.generate_key_shares("seed1", "seed2"):

{
    "share1": "1-97c44a91cb12b926de7b01479e282a5b11f0eb6e5a5255443e7d172f552fecac",
    "share2": "2-3333333333333333333333333333333333333333333333333333333333333333",
    "share3": "3-8bce03f349a389019e3e580d1d855404c18f2b3df2cd77275a6c7cb80c70541e",
    "_meta": {"m": 2, "n": 3}
}

🚀 Quick Start: Complete 5-Step Agent Integration Guide

Copy and paste this ready-to-run 5-step Python integration workflow:

from scafonix_agent import ScafonixAgent

def main():
    # -------------------------------------------------------------
    # STEP 1. Initialize Master AI & 3 Worker AIs (2-of-3 Threshold)
    # -------------------------------------------------------------
    master = ScafonixAgent(agent_id="Master-Orchestrator")
    worker1 = ScafonixAgent(agent_id="Worker-1-TradingAI")
    worker2 = ScafonixAgent(agent_id="Worker-2-ChartAI")
    worker3 = ScafonixAgent(agent_id="Worker-3-AuditAI")

    # -------------------------------------------------------------
    # STEP 2. Generate 2-of-3 Key Shares & Derive EVM Address
    # -------------------------------------------------------------
    shares = master.generate_key_shares(
        "8bce03f349a389019e3e580d1d855404c18f2b3df2cd77275a6c7cb80c70541e",
        "97c44a91cb12b926de7b01479e282a5b11f0eb6e5a5255443e7d172f552fecac"
    )

    # [Isolated Worker Storage]
    worker1_share = shares["share1"]  # Worker 1 holds Share 1
    worker2_share = shares["share2"]  # Worker 2 holds Share 2
    worker3_share = shares["share3"]  # Worker 3 holds Share 3 (Master holds ZERO shares!)

    # Derive Consensus Wallet Address (Share 1 + Share 2 pairing)
    wallet_address = master.derive_address(worker1_share, worker2_share)
    print("📍 Agent Consensus Wallet Address:", wallet_address)

    # -------------------------------------------------------------
    # STEP 3. Target Transaction Hash (32-byte Hex Hash)
    # -------------------------------------------------------------
    tx_hash = "0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"

    # -------------------------------------------------------------
    # STEP 4. Buy x402 Signed Ticket ($0.005 USDC on Base)
    # -------------------------------------------------------------
    ticket = {
        "ticketId": "tick_sample_999",
        "msgHash": tx_hash,
        "status": "VALID"
    }

    # -------------------------------------------------------------
    # STEP 5. 2-of-3 Voting: Workers Sign Partial & Master Combines
    # -------------------------------------------------------------
    # Worker 1 (Trading AI): APPROVE ✅ (Generates Partial Signature 1)
    part1 = worker1.sign_partial(
        single_share=worker1_share,
        pair_share_id=worker2_share,
        msg_hash=tx_hash
    )

    # Worker 2 (Chart AI): APPROVE ✅ (Generates Partial Signature 2)
    part2 = worker2.sign_partial(
        single_share=worker2_share,
        pair_share_id=worker1_share,
        msg_hash=tx_hash
    )

    # Worker 3 (Audit AI): REJECT ❌ (Suspicious risk detected - Does NOT sign)

    # Master AI combines 2 valid worker partial signatures + x402 Ticket -> Final (R, S, V)
    final_sig = master.combine_signatures(
        partial_signatures=[part1, part2],
        ticket=ticket
    )

    print("🎉 Final Valid Signature (R, S, V):", final_sig)

if __name__ == "__main__":
    main()

📖 API Reference Summary

Method Parameters Description / Return Value
generate_key_shares(seed1, seed2) Two 32-byte hex entropy seeds {"share1", "share2", "share3", "_meta"} dictionary
derive_address(share_a, share_b) Two key share strings On-chain EOA Wallet Address (0x...)
sign_partial(single_share, msg_hash, pair_share_id) Own share, partner share ID, txHash 1-time Worker Partial Signature (partialS, r, v)
combine_signatures(partial_signatures, ticket) List of partial signatures, x402 Ticket On-chain Final Signature (r, s, v, ticketId)

📄 License

MIT © Scafonix Team

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

scafonix_agent-1.0.4.tar.gz (1.1 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

scafonix_agent-1.0.4-py3-none-any.whl (1.1 MB view details)

Uploaded Python 3

File details

Details for the file scafonix_agent-1.0.4.tar.gz.

File metadata

  • Download URL: scafonix_agent-1.0.4.tar.gz
  • Upload date:
  • Size: 1.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.7

File hashes

Hashes for scafonix_agent-1.0.4.tar.gz
Algorithm Hash digest
SHA256 fd6f87b871c12ee9c45a70188396bd01d60d9ffccc58564741fdc85b1cccc390
MD5 7ff4406b54d63d481575e452921c68ff
BLAKE2b-256 9846d40a9f3ae17c754cbc4f4879c7d53c71103bf92948c73f5cf18ef1e03c99

See more details on using hashes here.

File details

Details for the file scafonix_agent-1.0.4-py3-none-any.whl.

File metadata

  • Download URL: scafonix_agent-1.0.4-py3-none-any.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.7

File hashes

Hashes for scafonix_agent-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 406f1f413bfe30aab7ea4012c9932f5b8a18f04cdf32f7e7b75dc07da5e34faf
MD5 dbe4b6b075738abca6bd9c09510f1aeb
BLAKE2b-256 bfbe76517d4e0e491c6174b49e50de2dff35003cf105bb9fa5f395641dd3e83b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page