Skip to main content

Contract Hub Tutorial

Push and pull Modality contracts to a hub (centralized) or chain (decentralized).

Hub vs Chain

FeatureHubChain
URL formathttp://.../ip4/.../p2p/...
Authed25519 keypairsNode identity
ValidationServer-sideConsensus
SpeedFastDepends on network
TrustHub operatorValidators

Quick Start

1. Start the Hub

modal hub start --detach
modal hub status

2. Register Your Identity

modal hub register

This saves credentials to .modal-hub/credentials.json.

3. Create a Contract on Hub

modal hub create "My Contract" --description "Description here"

Push/Pull Workflow

Add a Remote

modal c remote add hub http://localhost:3100/contracts/my-contract

Push Changes

modal c push hub

Pull Changes

modal c pull hub

Multi-Party Collaboration

Alice Creates the Contract

modal hub create "Escrow with Bob"
# Output: Contract ID: con_abc123

modal c remote add hub http://localhost:3100/contracts/con_abc123
modal c push hub

Alice Grants Bob Access

modal hub grant con_abc123 --identity bob_id_xyz --role writer

Bob Clones and Contributes

# Bob clones
modal c clone http://localhost:3100/contracts/con_abc123

# Bob adds his changes
modal c set /parties/bob.id $(modal id get --path ./bob.passfile)
modal c commit --all --sign bob.passfile -m "Bob joins"
modal c push hub

Access Control

RolePermissions
ownerFull control (push, grant, delete)
writerPush commits
readerPull only

Grant Access

modal hub grant <contract_id> --identity <id> --role writer

Revoke Access

modal hub revoke <contract_id> --identity <id>

Two-Tier Authentication

The hub uses two ed25519 keypairs:

  • Identity Key — Long-lived, represents your permanent identity
  • Access Key — Short-lived, rotatable session key

If an access key is compromised, you can revoke it without changing your identity.

Chain Sync (Decentralized)

For trustless operation, sync to the chain instead:

# Add chain remote
modal c remote add chain /ip4/validator.modality.network/tcp/4001/p2p/12D3KooW...

# Push to chain
modal c push chain

Chain commits are validated by consensus — no single party can censor or tamper.