Getting started
The TypeScript templates (opens in a new tab) are provided by Lattice (opens in a new tab).
Prerequisites
To install the TypeScript templates you need:
- Node.js v18 (opens in a new tab)
- git (opens in a new tab)
- Foundry (opens in a new tab)
- pnpm (opens in a new tab)
sudo npm install -g pnpm
Installation
To run any of the TypeScript templates:
-
Create the template with pnpm. If you need, replace
tutorialwith your application name.pnpm create mud@next tutorialNote: The
@nextis only necessary until MUD v2.0 is officially released. -
Select the template:
-
Start the development server, which updates automatically when you modify files.
cd tutorial pnpm devYou may receive this error message:
[vite] Internal server error: Failed to resolve import "contracts/out/IWorld.sol/IWorld.abi.json" from "src/mud/setupNetwork.ts"If so, ignore it. It simply means the
contractspackage hasn't created theIWorld.abi.jsonfile, which theclientpackage needs, yet. As soon as it is created, theclientpackage will use it.
Using the templates
Code organization
Other than a few utility files, most of the code is in two packages:
packages/contractscontains the onchain part of the application.packages/clientcontains the offchain part of the application, the user interface. The app runs in the user's browser, in development it is served from a vite (opens in a new tab) server. The content of this package varies based on the template used.
Vanilla and react-ecs
The applications in these two templates is the same.
You have an onchain counter and you can press Increment to increment it.
Three.js
In this application the position of an object, the big green cube, is stored onchain. In the user interface you can move that cube using the arrow keys, space, and ctrl.