This tutorial walks you through building your first Trellis service step by step. By the end, you will have a working orders-service that connects to the network, stores data, handles requests, listens to events, publishes its own events, and exposes a feed.
Before diving in, we recommend skimming Trellis Concepts to understand how contracts, RPCs, and NATS work together.
Each implementation section uses language selectors for TypeScript and Rust. The service contract and runtime lifecycle are the same in both languages; Rust uses generated SDK artifacts plus the service runtime facade during service compilation.
What you need
- A running Trellis environment (see Starting Trellis)
- Deno or Node.js for the TypeScript path
- Rust stable for the Rust path
- The
trellisCLI installed trellis-generateavailable for Rust contract artifact generation
Tutorial path
- Set up the project
- Your first contract
- The service entry point
- Adding a database
- Writing our first RPC
- Retrieving an order with service errors
- Listening to the outside world
- Publishing your own events
- Use a feed for filtered live views
- Handle graceful shutdown
- Prepare SDKs and contract artifacts
- Declare optional dependencies
- Use the development loop