Skip to main content

What is the Gateway?

The ChaosChain Gateway is an off-chain orchestration service that executes workflows between the SDK and on-chain contracts. It handles evidence storage, transaction serialization, and protocol isolation bridging.
Key Principle: The Gateway is economically powerless. All authoritative decisions occur on-chain.

Why a Gateway?

Without GatewayWith Gateway
SDK manages nonces directlyTX serialization per signer
Manual evidence archivalAutomatic Arweave uploads
No crash recoveryResumable workflows
Direct contract callsProtocol isolation bridging
SDK computes DKGServer-side DKG (pure function)

Core Responsibilities

Workflow Execution

Execute multi-step workflows as state machines with idempotency and crash recovery

TX Serialization

One nonce stream per signer prevents races and stuck transactions

Evidence Storage

Automatic upload to Arweave with confirmation tracking

Protocol Bridging

Orchestrates handoff between StudioProxy and RewardsDistributor

Gateway Design Invariants

These rules are non-negotiable and define the hard boundaries of the Gateway:
#InvariantMeaning
1Contracts are AuthorityOn-chain state is always truth; Gateway reconciles
2DKG is PureSame evidence → same DAG → same weights (no randomness)
3TX SerializationOne signer = one nonce stream (no parallel submission)
4Crash ResilientWorkflows resume from last committed state
5Protocol IsolationGateway bridges StudioProxy ↔ RewardsDistributor
6Orchestration OnlyNo protocol logic, no economic decisions
7Idempotent ActionsRunning an action twice has the same result

Workflow Types

WorkflowPurposeSteps
WorkSubmissionSubmit work to StudioUpload → Submit → Register
ScoreSubmissionSubmit verifier scoresScore → Confirm → Register Validator
CloseEpochClose epoch, distribute rewardsCheck → Submit → Confirm

Quick Start

from chaoschain_sdk import GatewayClient

# Connect to Gateway
gateway = GatewayClient("https://gateway.chaoscha.in")

# Check health
status = gateway.health_check()
print(f"Gateway: {status['status']}")

# Submit work
result = gateway.submit_work(
    studio_address="0x...",
    data_hash="0x...",
    thread_root="0x...",
    evidence_root="0x...",
    signer_address="0x..."
)

# Wait for completion
final = gateway.wait_for_workflow(result.workflow_id)
print(f"✅ Completed: {final.tx_hash}")

Mental Model

Protocol = Law       (Smart Contracts)
Gateway  = Process   (Workflow Orchestration)
Studios  = Products  (Business Logic)
SDK      = Interface (Developer Tools)
The Gateway is like a court clerk — it files paperwork, tracks deadlines, and ensures procedures are followed, but it doesn’t make legal decisions.

Next Steps