DIN SDK

Posted on 28 March 2026 by a.human 4 min

Document 2: The DIN SDK — Developer Implementation Guide

"Ship Accountable Agents with Cryptographic Evidence" 1. The Problem for Builders

You are building AI agents (GPT-6 wrappers, autonomous hedge funds, personal assistants). The Risk: Regulations like the EU AI Act require Human Oversight. If your agent makes a mistake, can you prove the user authorized that specific action? Without a verifiable audit trail, you are exposed to "He said/She said" disputes and regulatory scrutiny. 2. The Solution: The DIN SDK

The DIN SDK wraps your AI agent in a layer of cryptographic accountability.

 For the User: They get a unified identity they own, with transparent control over what they sign.
 For You (The Developer): You get a "Compliance Engine." Every action is logged with a verifiable receipt, proving exactly what the user authorized and when.
  1. Quick Start (Python/JS)

Integrate DIN into your existing LangChain or AutoGPT workflow instantly. python

import din_sdk

1. Initialize the Agent with the User's DIN

This connects the agent to the user's on-chain identity Spore.

agent = din_sdk.Agent(din_id="DIN:nervos:0x1a2b...")

2. Define the Policy (The "Scope")

CRITICAL: Define precise limits, not just broad permissions.

policy = din_sdk.Policy( actions=["transfer"], limits={"max_value": 1000, "currency": "USD"}, # Spending caps duration="24h" )

3. Request Authorization

This triggers a secure prompt to the user's wallet (Mobile/Browser).

The user signs the specific policy details.

The SDK handles the complex Hybrid (PQ) signature generation in the background.

auth_request = agent.request_scope(policy)

4. Execute

if auth_request.is_signed: # SUCCESS: The action is now "receipted." # You have cryptographic proof that the user authorized THIS transaction # with THESE limits at THIS time. agent.execute(transfer_tx) else: # FAIL: User denied or transaction violates policy. # The agent is blocked from acting, preventing unauthorized errors. print("Authorization denied or policy violation.")

  1. Key Features for Adoption A. The "Passport Wrapper" Strategy (Client-Side Security)

Proprietary models (OpenAI, Google) won't integrate DIN natively? It doesn't matter.

 How it works: The DIN SDK runs client-side (in the user's app or browser extension). It acts as a Local Proxy.
 Security: The user's API keys for OpenAI never leave their device. The SDK intercepts requests, checks authorization against the DIN identity, and then routes the request.
 The Benefit: You turn proprietary AI into a "utility pipe" while keeping the identity layer open. The DIN network never sees the user's secrets, only the authorization receipts.

B. The "Accountability Standard" (Evidence over Immunity)

Building on DIN doesn't grant legal immunity, but it provides the strongest possible defense: Evidence.

 The Reality: Disputes arise when users claim, "I didn't authorize that."
 The DIN Solution: DIN replaces vague consent with Parameter-Locked Signatures.
 For Regulators: You can demonstrate that the user explicitly signed: "Transfer maximum $500 to Address X within 24 hours."
 Result: You transform a potential "negligence" lawsuit into a clear-cut case of user responsibility.

C. Granular Authorization Controls

Addressing the "vague scope" risk, the SDK enforces Parameter Locking.

 User Experience: Users don't just sign "Transfer." They sign specific parameters (Amount, Recipient, Time Limit).
 Enforcement: If the Agent tries to transfer $501 when the limit was $500, the DIN SDK blocks the transaction locally before it ever reaches the network. The signature is mathematically invalid for that amount.

D. Zero-Friction Onboarding (Account Abstraction)

Stop asking users to save 24-word seed phrases.

 Implementation: DIN supports native Account Abstraction on Nervos CKB.
 UX: Users log in with Passkeys (FaceID / TouchID) or Email.
 Recovery: If the user loses their device, the Hybrid Life-Lock (Guardians) allows identity recovery without a seed phrase.
  1. Why Build on DIN?

    Interoperability: One identity works across all your apps. Cost: Uses Nervos CKB's deterministic fees—no more $50 gas spikes. Future-Proof: Your user's data is safe from Quantum decryption via Nillion integration. Sovereignty: You don't lock users in. If your app shuts down, their identity lives on. Users trust you more because they know they can leave.

The DIN Protocol is live. The standard is set. Build the future of accountable AI.