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
To run any of the TypeScript templates:
Create the template with pnpm. If you need, replace
tutorialwith your application name.
pnpm create mud@next tutorial
@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 dev
You 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 the
IWorld.abi.jsonfile, which the
clientpackage needs, yet. As soon as it is created, the
clientpackage will use it.
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.
The applications in these two templates is the same.
You have an onchain counter and you can press
Increment to increment it.
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.