Build a complete todo application with Pact smart contracts and modern web frameworks. This guide follows the patterns used in production Pact Toolbox applications.
Create a new project with our scaffolding tool:
A modern Pact Toolbox project follows this structure:
Configure your networks and development environment:
Add the Pact plugin to your Vite configuration:
Create pact/todos.pact
:
Pact Toolbox automatically generates TypeScript types. After saving your contract, you'll see pact/todos.pact.d.ts
with:
Create src/api/api.ts
to interact with your smart contract:
Key patterns:
.pact
filesCreate src/App.tsx
with wallet setup:
Create src/components/TodoList.tsx
:
Create pact/todos.repl
for REPL-based testing:
Run the tests:
This enables:
When you edit pact/todos.pact
:
Example: Adding a delete function:
The TypeScript types update automatically:
Use it immediately in your API:
Create scripts/deploy.ts
to deploy your contracts:
Run deployment:
.pact
filesdirtyRead()
for queries