Soroban Contracts
Not yet deployed
Soroban Smart Contracts

On-Chain Infrastructure

Two Soroban contracts anchor every StellarFlow workflow run on the Stellar network. Written in Rust, compiled to WASM, and deployed to Soroban.

WorkflowRegistry

contracts/workflow-registry/src/lib.rs

Stores workflow definitions and run state on-chain. Every workflow run is anchored on Stellar — the network enforces valid state transitions.

Contract Functions
initialize(admin)
One-time setup, sets admin address
register_workflow(name, version, step_count)
Register a workflow definition
start_run(run_id, workflow_name)
Start a new workflow run, creates on-chain record
record_step(run_id, step_id, agent, status, inputs_hash, outputs_hash)
Anchor a step completion
complete_run(run_id, success)
Mark run completed or failed
cancel_run(run_id)
Cancel an active run
get_run(run_id)
Query run state
get_step(run_id, step_id)
Query individual step record
Emitted Events
wf_reg
Emitted when a workflow is registered
run_start
Emitted when a run starts
step_done
Emitted on each step completion
run_end
Emitted when a run completes or fails
Env Variable
WORKFLOW_REGISTRY_CONTRACT

AuditLog

contracts/audit-log/src/lib.rs

Immutable append-only audit trail. Each step records SHA-256 hashes of its inputs and outputs. Entries can never be modified — tamper-proof by design.

Contract Functions
initialize(admin)
One-time setup
record(kind, workflow_id, run_id, step_id, agent, inputs_hash, outputs_hash)
Append an audit entry
get_entry(entry_id)
Fetch a single audit entry
get_run_entries(run_id)
Get all entry IDs for a run
verify(entry_id, inputs_hash, outputs_hash)
Tamper-check: verify hashes match
entry_count()
Total entries ever recorded
Emitted Events
audit
Emitted on every record() call — streamable via Horizon
Env Variable
AUDIT_LOG_CONTRACT

Deploy to Stellar Testnet

1
Install Stellar CLI
cargo install --locked stellar-cli --features opt
2
Set deployer keypair
export DEPLOYER_SECRET=S...your_testnet_secret
3
Build + deploy both contracts to testnet
bash contracts/deploy.sh
4
Set WORKFLOW_REGISTRY_CONTRACT and AUDIT_LOG_CONTRACT
# Copy output into .env

How the contracts integrate

When a workflow run is triggered via POST /api/workflows/run, the API calls start_run() on the WorkflowRegistry contract — anchoring the run on-chain before any agent executes.

As each step completes, record_step() is invoked with SHA-256 hashes of the step's inputs and outputs. The AuditLog contract appends an immutable entry and emits an event that any indexer (Horizon) can stream in real-time.

If WORKFLOW_REGISTRY_CONTRACT or AUDIT_LOG_CONTRACT are not set, the API falls back to in-memory simulation — so the app works fully without deploying contracts first.