The MUD CLI
The MUD CLI is used for building and developing a MUD project.
It comes with
tablegen
: code-generation tool that makes it easy to work with Store tablescreate
: bootstrap a MUD project from one of the template.dev-contracts
: start a local MUD development server, including local Ethereum node and file watchersdeploy
: deployer for MUD v2 projects that deploys an app using the World kernel onchaindevnode
: a wrapper around Anvil with defaults needed to make MUD work properly in development. We recommend runningmud devnode
overanvil
.faucet
: a interface to the Lattice Testnet faucet. It makes it easy to fund addresses on the testnet
Installation
We don’t recommend installing the CLI globally.
Instead, you should add the CLI as a dev dependency to your project (done automatically if you start from a starter kit using yarn create mud@canary
), and use it with pnpm mud
inside your project directory.
Commands
tablegen
Generates Store libraries from a mud.config.ts
file. See the Store Config and tablegen
documentation in the Store section for more details.
create
Bootstrap a MUD project from a template. You can specify a template interactively when running the command without arguments, or pass it via --template
The valid templates are:
react
: A MUD template with React client side that uses the MUD React hooks
minimal
: A minimal template with javascript for the frontend (no framework)
dev-contracts
Start a local MUD development server.
The tool with start a local Ethereum node in the background, or use a custom node via the provided --rpc
argument.
It will run all the necessary codegeneration steps, deploy the MUD contracts to the local node.
It will also watch for file changes to the mud.config.ts
file and all Solidity source files, and re-run the codegen or deploy steps if necessary.
The latest deployment is saved to the worlds.json
file, where the client can find it to always connect to the latest local deployment.
The tsgenOutput
argument is used to specify the output path for code generated for recs
.
To run the dev server with internal development node:
pnpm mud dev-contracts --tsgenOutput ../client/src/mud
To run the dev server with a custom development node:
# Terminal 1:
anvil --port 8545
# Terminal 2:
pnpm mud dev-contracts --tsgenOutput ../client/src/mud --rpc localhost:8545
deploy
Deploy a MUD project with the World framework.
This tool will use the mud.config.ts
to detect all systems, tables, modules, and namespaces in the World and will deploy them to the chain specified in your Foundry profile.
When using the deployer, you must set the private key of the deployer using the PRIVATE_KEY
environment variable. You can make this easier by using [dotenv](https://www.npmjs.com/package/dotenv)
before running mud deploy
in your deployment script.
To set the profile used by the deployer, either set your FOUNDRY_PROFILE
environment variable, or pass --profile <profileName>
to the deployer (eg: mud deploy --profile optimism-mainnet
).
The RPC used by the deployer will be [http://localhost:8545](http://localhost:8545)
if no profile is set, otherwise it will be read from the eth_rpc_url
configuration field of the Foundry profile.
Example profile:
# foundry.toml
[profile.lattice-testnet]
eth_rpc_url = "https://follower.testnet-chain.linfra.xyz"
[profile.optimism-mainnet]
eth_rpc_url = "https://infura[...]"
devnode
Runs Anvil with a block time of 1s, and no base fee (to make it possible for unfunded account to send transactions).
This command also wipes the Anvil cache. Anvil cache blow-up problems won’t happen to you anymore 🙂
faucet
Connects to a MUD faucet service to fund an address.
pnpm mud faucet --faucetUrl <faucetService> --address <address>
The default faucet service is the one running on the Lattice testnet.
To fund an address on the testnet, run mud faucet --address <address>