CLI
mud deploy

mud deploy

This command deploys a MUD app to a blockchain.

Using the command

Before you run mud deploy you need to specify the private key of the deploying account. There are several ways to do this:

  • Export an environment variable.

    export PRIVATE_KEY=0x<key goes here>
  • Edit .env to specify the PRIVATE_KEY value.

    # This .env file is for demonstration purposes only.
    #
    # This should usually be excluded via .gitignore and the env vars attached to
    # your deployment enviroment, but we're including this here for ease of local
    # development. Please do not commit changes to this file!
    #
    # Anvil default private key:
    PRIVATE_KEY=0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d

You also need to specify a URL to the blockchain. Again, there are several ways to do this:

These are the command line options you can specify on mud deploy:

OptionMeaningTypeDefault value
--versionShow version numberbooleanfalse
--configPathPath to the config filestringmud.config.ts
--printConfigPrint the resolved configbooleanfalse
`--saveDeploymentSave the deployment info to a filebooleantrue
--profileThe foundry profile to usestringlocal
--rpc1The RPC URL to usestringRPC url from foundry.toml
--worldAddressDeploy to an existing World at the given addressstringEmpty, deploy new World
--srcDirSource directorystringFoundry src directory
--skipBuildSkip rebuilding the contracts before deployingbooleanfalse
--alwaysRunPostDeployRun PostDeploy.s.sol after each deploybooleanfalse (run the script only when deploying a new World)
--helpShow helpbooleanfalse

(1) The hostname localhost may not work. If that is the case, use 127.0.0.1 instead.

Examples

New World

To create a new World you can use this command line:

pnpm mud deploy --rpc <url>

This command also writes the World's address to worlds.json.

Upgrading a World

To upgrade a World (add or modify Systems, tables, etc.) you can use this command line:

pnpm mud deploy --rpc <url> --worldAddress <address>

Debugging

To generate debug messages, use this command:

export DEBUG=mud:cli:deploy