Guides
Deploy to a blockchain

Deploy to a blockchain

In this tutorial you deploy a MUD application to our test blockchain, Garnet (opens in a new tab)

Setup

Create a new MUD application from the template. Use the vanilla template.

pnpm create mud@latest tutorial --template vanilla
cd tutorial
pnpm dev

Deployment

  1. Change to the contracts package.

    cd packages/contracts
  2. See that foundry.toml has a [profile.garnet] section with the RPC URL.

  3. Connect to the Garnet faucet (opens in a new tab) to obtain test ETH.

  4. Specify the private key for the address that got the test ETH on Garnet.

    export PRIVATE_KEY=0x <your private key goes here>
  5. Deploy using the mud deploy command.

    pnpm mud deploy --profile garnet
  6. After the deployment is over, look at the World information. The key, 17069, is the chain ID for Garnet.

    cat worlds.json | jq .\"17069\"
  7. To go to your application, specify the chain ID on the URL (opens in a new tab). You can also quit out of the pnpm dev and specify the chain ID when running vite.

    cd packages/client
    export VITE_CHAIN_ID=17069
    pnpm vite

    When you do that, it is no longer necessary to specify the chain ID on the URL. The default URL (opens in a new tab) takes you directly to the onchain application.