Skip to main content

Contract Commands (modal contract / modal c)

Manage contracts — create, commit, push, pull, and inspect.

Create

modal c create [OPTIONS]

Creates a new contract in the current directory.

What it creates:

.contract/           # Contract metadata
├── config.json # Contract configuration
├── commits/ # Commit storage
└── HEAD # Current commit reference
state/ # Working state directory

Options:

OptionDescription
--name <NAME>Contract name
--template <TEMPLATE>Initialize from template

Commit

modal c commit [OPTIONS]

Create a new commit from staged changes.

Options:

OptionDescription
--all, -aCommit all changes (state + rules + model)
--stateCommit only state changes
--rulesCommit only rule changes
--modelCommit only model changes
--sign <PASSFILE>Sign commit with passfile
--message, -m <MSG>Commit message
--action <JSON>Commit a domain action

Examples:

# Commit all changes with signature
modal c commit --all --sign alice.passfile -m "Add escrow rules"

# Commit a domain action
modal c commit --action '{"type":"DEPOSIT","amount":100}' --sign alice.passfile

# Commit only state changes
modal c commit --state -m "Update configuration"

Checkout

modal c checkout [OPTIONS]

Extract committed state to the working state/ directory.

Options:

OptionDescription
--commit <HASH>Checkout specific commit
--forceOverwrite local changes

Status

modal c status
modal status # shortcut when in contract directory

Shows:

  • Current commit
  • Modified files
  • Staged changes
  • Rule validation status

Diff

modal c diff [OPTIONS]

Show changes between working state and committed state.

Options:

OptionDescription
--commit <HASH>Compare against specific commit
--statShow only file statistics

Log

modal c log [OPTIONS]

Show commit history.

Options:

OptionDescription
--verbose, -vShow full commit details
--limit <N>Limit number of commits shown
--onelineCompact format

Example output:

abc123 (HEAD) Add escrow rules [alice] 2024-01-15 10:30:00
def456 Initial contract setup [alice] 2024-01-15 10:00:00

Set

modal c set <PATH> [VALUE] [OPTIONS]

Set a state file value.

Options:

OptionDescription
--file <FILE>Read value from file
--type <TYPE>Explicit path type

Examples:

# Set text value
modal c set /config/name.text "My Contract"

# Set from file
modal c set /data/config.json --file ./local-config.json

# Set boolean
modal c set /flags/active.bool true

Set Named ID

modal c set-named-id <PATH> --named <NAME>

Set a .id file from a named passfile in your passfile directory.

modal c set-named-id /parties/alice.id --named alice
# Uses ~/.modal/passfiles/alice.passfile

Get

modal c get <PATH> [OPTIONS]

Get contract or state information.

Options:

OptionDescription
--commit <HASH>Get from specific commit
--rawOutput raw bytes
modal c get /parties/alice.id
modal c get /data/config.json --commit abc123

ID Commands

# Get contract ID
modal c id

# Get current commit ID
modal c commit-id

Push

modal c push <REMOTE> [OPTIONS]

Push commits to a hub or chain validators.

Remote formats:

  • Hub: http://hub.example.com/contracts/<id>
  • Chain: /ip4/<addr>/tcp/<port>/p2p/<peer_id>

Options:

OptionDescription
--sign <PASSFILE>Sign push request
--forceForce push

Pull

modal c pull <REMOTE> [OPTIONS]

Pull commits from a hub or chain.

Options:

OptionDescription
--checkoutCheckout after pulling

Pack / Unpack

# Pack contract into portable file
modal c pack --output contract.modal

# Unpack contract file
modal c unpack contract.modal --output ./my-contract

Assets

modal c assets [OPTIONS]

Manage contract assets.

Options:

OptionDescription
--listList all assets
--add <PATH>Add asset
--remove <PATH>Remove asset

WASM Upload

modal c wasm-upload <WASM_FILE> [OPTIONS]

Upload a WASM module for custom predicates.

Options:

OptionDescription
--name <NAME>Module name
--sign <PASSFILE>Sign upload