Getting started
Prerequisites
- git (download (opens in a new tab))
- foundry (forge, anvil, cast) (download (opens in a new tab), make sure to
foundryup
at least once) - node.js (v18) (download (opens in a new tab))
- pnpm (
npm install pnpm --global
after installing node)
Setup
Most projects in MUD are started by running pnpm create mud@latest <project name>
, but for this tutorial we've included some initial code to get you up and running quicker. This includes React components and base TailwindCSS styles.
-
Fork or clone from the Emojimon starter kit repo (opens in a new tab). You can use the command below.
git clone https://github.com/latticexyz/emojimon.git
-
Install the dependencies and start up the MUD services (anvil node, contracts deployer, and client).
cd emojimon && pnpm install && pnpm dev
-
At this point you can play the game to see the finished game. Open the game in your browser. By default the game is at http://localhost:3000 (opens in a new tab).
-
Click the map to spawn at a specific location and move using the arrow keys. Note that on each block you can only move one space, and the block time on the anvil blockchain is one second.
-
Now that you've seen our end goal, reset the repository to the starting snapshot (opens in a new tab).
git reset --hard start
After you do this, the game is just a green area where the map is going to be.
Code structure
Except for a few utility files, most of the code is in two packages:
packages/contracts
(opens in a new tab) contains the onchain part of the game.packages/client
(opens in a new tab) contains the offchain part of the game, the user interface. The software runs on the user's browser, it is just served from a vite (opens in a new tab) server.