The Lattice team has been working on four templates.

Each of them can be used as a starting point for your project depending on which technology you want to use with MUD

All templates are in the v2sandbox repo: https://github.com/latticexyz/v2sandbox

To start from a template:

  1. Select the right branch (eg: react, phaser, main (minimal), three-react) or go directly to the right branch by clicking the link in the corresponding section below.

  2. Click the “Deploy” button, it will send you to Vercel and guide you through forking the repo and deploying it.

    Important: select “4242” as your VITE_CHAIN_ID when Vercel prompts you.

    CleanShot 2023-04-01 at 11.07.12@2x.png

    Note: Vercel is not mandatory in order to use MUD, but it will make it easier because we configured it for the hackathon.

Getting started

The MUD deployer requires a private key to deploy to the local development chain or the testnet. For now (while you don’t deploy to the testnet) you can use the default private key for anvil (the testnet)

  1. Run this in your global project (where the packages folder there)
echo "PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" > packages/contracts/.env
  1. run yarn to install all packages

    1. Make sure your have yarn installed (npm install -g yarn)
    2. And that version 1 is set (yarn set version 1)

    NPM, PNPM, and other package managers won’t work

  2. run yarn dev to start the development server for your frontend, the anvil local blockchain, and the deployer

  3. If you change your systems or tables, press “enter” after having focused the process 3 in the dashboard

    CleanShot 2023-04-01 at 11.17.11@2x.png

    Tap “3” on your keyboard

    CleanShot 2023-04-01 at 11.17.38@2x.png

    Press enter to restart the deployer. Your client will automatically reload with the new deployment.

    Hot reload of systems is a work in progress (ask Flo or Justin for progress)

  4. If you want to rerun code-generation after changing your config file (to regenerate libraries), run yarn initialize at the root of your project

Template: minimal

If you want to connect MUD to a different frontend library (eg: svelte, angular, etc) or 3D engine (eg: Babylon) you should start from the minimal template.

GitHub - latticexyz/v2sandbox: Nothing to see here

branch: main

Template: react

To use React to render your game (and any React library on top, like ReactPixi), you should start with the react template. MUD comes with React hooks to make it easier to get MUD data into your components.