(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1612],{18563:function(e,n,t){(window.__NEXT_P=window.__NEXT_P||[]).push(["/cli/deploy",function(){return t(7583)}])},73307:function(e,n,t){"use strict";t.d(n,{Z:function(){return d}});var r=t(7505),s=t(11689);let i={logo:function(){return(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"0.25em",fontSize:"32px",fontFamily:"PP Supply Mono",textTransform:"uppercase"},children:[(0,r.jsx)("img",{src:"/images/logos/mud-white.svg",style:{height:"calc(var(--nextra-navbar-height) - 35px)"},alt:"MUD logo"}),"MUD"]})},useNextSeoProps(){let{asPath:e}=(0,s.useRouter)();return{titleTemplate:"/"===e?"MUD – a framework for ambitious Ethereum applications":"%s – MUD"}},project:{link:"https://github.com/latticexyz/mud"},docsRepositoryBase:"https://github.com/latticexyz/mud/tree/main/docs",head:(0,r.jsx)(r.Fragment,{children:(0,r.jsx)("meta",{property:"title",content:"MUD documentation"})}),darkMode:!1,nextThemes:{defaultTheme:"dark"},footer:{text:"MIT 2023 \xa9 MUD"},primaryHue:28,sidebar:{defaultMenuCollapseLevel:1}};var d=i},7583:function(e,n,t){"use strict";t.r(n);var r=t(7505),s=t(42585),i=t(38288),d=t(73307);t(54693);var o=t(26736);t(98823);var a=t(64738);let l={MDXContent:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{wrapper:n}=Object.assign({},(0,o.ah)(),e.components);return n?(0,r.jsx)(n,{...e,children:(0,r.jsx)(c,{...e})}):c(e)},pageOpts:{filePath:"pages/cli/deploy.mdx",route:"/cli/deploy",headings:[{depth:1,value:"mud deploy",id:"mud-deploy"},{depth:2,value:"Using the command",id:"using-the-command"},{depth:3,value:"Interaction with the templates",id:"interaction-with-the-templates"},{depth:2,value:"Examples",id:"examples"},{depth:3,value:"New World",id:"new-world"},{depth:3,value:"Upgrading a World",id:"upgrading-a-world"},{depth:2,value:"Debugging",id:"debugging"},{depth:2,value:"Known issues",id:"known-issues"},{depth:3,value:"Out of gas",id:"out-of-gas"}],pageMap:[{kind:"Meta",data:{introduction:{title:"What is MUD?",theme:{breadcrumb:!1}},quickstart:{title:"Get started",theme:{breadcrumb:!1}},protocol:{title:"Protocol",type:"separator"},store:"Store",world:"World",framework:{title:"Framework",type:"separator"},config:"Config",cli:"CLI","state-query":"State Query",services:"Services","---":{title:"",type:"separator"},guides:"Guides",templates:"Templates",contribute:{title:"Contribute",theme:{breadcrumb:!1}},changelog:"Changelog",retrospectives:"Retrospectives",audits:"Audits",version:{title:"2.1.0",type:"menu",items:{changelog:{title:"Changelog",href:"/changelog"},contribute:{title:"Contribute",href:"/contribute"}}},status:{title:"Status",type:"page",href:"https://status.mud.dev",newWindow:!0},community:{title:"Community",type:"page",href:"https://community.mud.dev",newWindow:!0},twitter:{title:"Twitter",type:"page",href:"https://twitter.com/latticexyz",newWindow:!0},discord:{title:"Discord",type:"page",href:"https://lattice.xyz/discord",newWindow:!0}}},{kind:"Folder",name:"audits",route:"/audits",children:[{kind:"MdxPage",name:"2024-02-11-open-zeppelin",route:"/audits/2024-02-11-open-zeppelin"},{kind:"Meta",data:{"2024-02-11-open-zeppelin":"2024-02-11 OpenZeppelin",pdf:{display:"hidden"},icons:{display:"hidden"}}}]},{kind:"MdxPage",name:"changelog",route:"/changelog"},{kind:"Folder",name:"cli",route:"/cli",children:[{kind:"Meta",data:{tablegen:"mud tablegen",worldgen:"mud worldgen",test:"mud test",deploy:"mud deploy",verify:"mud verify","dev-contracts":"mud dev-contracts","abi-ts":"mud abi-ts","set-version":"mud set-version"}},{kind:"MdxPage",name:"abi-ts",route:"/cli/abi-ts"},{kind:"MdxPage",name:"deploy",route:"/cli/deploy"},{kind:"MdxPage",name:"dev-contracts",route:"/cli/dev-contracts"},{kind:"MdxPage",name:"set-version",route:"/cli/set-version"},{kind:"MdxPage",name:"tablegen",route:"/cli/tablegen"},{kind:"MdxPage",name:"test",route:"/cli/test"},{kind:"MdxPage",name:"verify",route:"/cli/verify"},{kind:"MdxPage",name:"worldgen",route:"/cli/worldgen"}]},{kind:"Folder",name:"config",route:"/config",children:[{kind:"MdxPage",name:"reference",route:"/config/reference"},{kind:"Meta",data:{reference:"Reference"}}]},{kind:"MdxPage",name:"config",route:"/config"},{kind:"MdxPage",name:"contribute",route:"/contribute"},{kind:"Folder",name:"guides",route:"/guides",children:[{kind:"Meta",data:{"replicating-onchain-state":"Replicating onchain state","hello-world":"Hello World","extending-a-world":"Extending a World","adding-delegation":"Adding Delegation",emojimon:"Emojimon",testing:"Testing","best-practices":"Best Practices"}},{kind:"MdxPage",name:"adding-delegation",route:"/guides/adding-delegation"},{kind:"Folder",name:"best-practices",route:"/guides/best-practices",children:[{kind:"Meta",data:{"system-best-practices":"System Best Practices","deployment-settings":"Recommended Deployment Settings",kms:"Deploy production worlds using AWS KMS"}},{kind:"MdxPage",name:"deployment-settings",route:"/guides/best-practices/deployment-settings"},{kind:"MdxPage",name:"kms",route:"/guides/best-practices/kms"},{kind:"MdxPage",name:"system-best-practices",route:"/guides/best-practices/system-best-practices"}]},{kind:"Folder",name:"emojimon",route:"/guides/emojimon",children:[{kind:"MdxPage",name:"1-preface-the-ecs-model",route:"/guides/emojimon/1-preface-the-ecs-model"},{kind:"MdxPage",name:"2-getting-started",route:"/guides/emojimon/2-getting-started"},{kind:"MdxPage",name:"3-players-and-movement",route:"/guides/emojimon/3-players-and-movement"},{kind:"MdxPage",name:"4-map-and-terrain",route:"/guides/emojimon/4-map-and-terrain"},{kind:"MdxPage",name:"5-a-wild-emojimon-appears",route:"/guides/emojimon/5-a-wild-emojimon-appears"},{kind:"MdxPage",name:"6-advanced",route:"/guides/emojimon/6-advanced"},{kind:"Meta",data:{"1-preface-the-ecs-model":"Preface: the ECS model","2-getting-started":"Getting started","3-players-and-movement":"Players and movement","4-map-and-terrain":"Map and terrain","5-a-wild-emojimon-appears":"A wild Emojimon appears","6-advanced":"Advanced features"}}]},{kind:"MdxPage",name:"emojimon",route:"/guides/emojimon"},{kind:"Folder",name:"extending-a-world",route:"/guides/extending-a-world",children:[{kind:"Meta",data:{index:"Extending a World Permissionlessly"}},{kind:"MdxPage",name:"index",route:"/guides/extending-a-world"}]},{kind:"Folder",name:"hello-world",route:"/guides/hello-world",children:[{kind:"Meta",data:{"add-table":"Add a table","filter-sync":"Filter data synchronization","add-system":"Add a system",deploy:{title:"Deploy to a blockchain",href:"/cli/deploy"}}},{kind:"MdxPage",name:"add-system",route:"/guides/hello-world/add-system"},{kind:"MdxPage",name:"add-table",route:"/guides/hello-world/add-table"},{kind:"MdxPage",name:"filter-sync",route:"/guides/hello-world/filter-sync"}]},{kind:"MdxPage",name:"hello-world",route:"/guides/hello-world"},{kind:"MdxPage",name:"replicating-onchain-state",route:"/guides/replicating-onchain-state"},{kind:"MdxPage",name:"testing",route:"/guides/testing"}]},{kind:"MdxPage",name:"introduction",route:"/introduction"},{kind:"MdxPage",name:"quickstart",route:"/quickstart"},{kind:"Folder",name:"retrospectives",route:"/retrospectives",children:[{kind:"MdxPage",name:"2023-09-12-register-system-vulnerability",route:"/retrospectives/2023-09-12-register-system-vulnerability"},{kind:"MdxPage",name:"2024-04-17-storeread-getdynamicfieldlength-bug",route:"/retrospectives/2024-04-17-storeread-getdynamicfieldlength-bug"},{kind:"Meta",data:{"2024-04-17-storeread-getdynamicfieldlength-bug":"2024-04-17 StoreRead.getDynamicFieldLength bug","2023-09-12-register-system-vulnerability":"2023-09-12 registerSystem vulnerability"}}]},{kind:"Folder",name:"services",route:"/services",children:[{kind:"Meta",data:{indexer:"Indexer",faucet:"Faucet"}},{kind:"MdxPage",name:"faucet",route:"/services/faucet"},{kind:"MdxPage",name:"indexer",route:"/services/indexer"}]},{kind:"Folder",name:"state-query",route:"/state-query",children:[{kind:"Meta",data:{typescript:"TypeScript"}},{kind:"Folder",name:"typescript",route:"/state-query/typescript",children:[{kind:"Meta",data:{recs:"RECS",zustand:"Zustand"}},{kind:"MdxPage",name:"recs",route:"/state-query/typescript/recs"},{kind:"MdxPage",name:"zustand",route:"/state-query/typescript/zustand"}]}]},{kind:"Folder",name:"store",route:"/store",children:[{kind:"Meta",data:{introduction:"Introduction","data-model":"Data model",tables:"Tables","table-libraries":"Table libraries",encoding:"Encoding","store-hooks":"Store hooks",reference:"Reference"}},{kind:"MdxPage",name:"data-model",route:"/store/data-model"},{kind:"MdxPage",name:"encoding",route:"/store/encoding"},{kind:"MdxPage",name:"introduction",route:"/store/introduction"},{kind:"Folder",name:"reference",route:"/store/reference",children:[{kind:"Meta",data:{"store-core":"StoreCore (internal)",store:"IStore (external)","store-hook":"StoreHook",misc:"Miscellaneous"}},{kind:"MdxPage",name:"misc",route:"/store/reference/misc"},{kind:"MdxPage",name:"store-core",route:"/store/reference/store-core"},{kind:"MdxPage",name:"store-hook",route:"/store/reference/store-hook"},{kind:"MdxPage",name:"store",route:"/store/reference/store"}]},{kind:"MdxPage",name:"store-hooks",route:"/store/store-hooks"},{kind:"MdxPage",name:"table-libraries",route:"/store/table-libraries"},{kind:"MdxPage",name:"tables",route:"/store/tables"}]},{kind:"Folder",name:"templates",route:"/templates",children:[{kind:"Meta",data:{typescript:"TypeScript",godot:"Godot",pwa:"Progressive Web App (for mobile)",swift:"Swift",svelte:"Svelte",unity:"Unity"}},{kind:"MdxPage",name:"godot",route:"/templates/godot"},{kind:"MdxPage",name:"pwa",route:"/templates/pwa"},{kind:"MdxPage",name:"svelte",route:"/templates/svelte"},{kind:"MdxPage",name:"swift",route:"/templates/swift"},{kind:"Folder",name:"typescript",route:"/templates/typescript",children:[{kind:"Meta",data:{contracts:"Contracts",vanilla:"Vanilla","react-ecs":"React-ECS",threejs:"Three.js",vue:"Vue"}},{kind:"MdxPage",name:"contracts",route:"/templates/typescript/contracts"},{kind:"MdxPage",name:"react-ecs",route:"/templates/typescript/react-ecs"},{kind:"MdxPage",name:"threejs",route:"/templates/typescript/threejs"},{kind:"MdxPage",name:"vanilla",route:"/templates/typescript/vanilla"},{kind:"MdxPage",name:"vue",route:"/templates/typescript/vue"}]},{kind:"MdxPage",name:"unity",route:"/templates/unity"}]},{kind:"Folder",name:"world",route:"/world",children:[{kind:"Meta",data:{introduction:"Introduction","resource-ids":"Resource Identifiers","namespaces-access-control":"Namespaces & Access Control",tables:"Tables",systems:"Systems","system-hooks":"System Hooks","function-selectors":"Function Selectors",balance:"Balance","account-delegation":"Account Delegation","batch-calls":"Batch Calls",upgrades:"Upgrading",modules:"Modules",reference:"Reference"}},{kind:"MdxPage",name:"account-delegation",route:"/world/account-delegation"},{kind:"MdxPage",name:"balance",route:"/world/balance"},{kind:"MdxPage",name:"batch-calls",route:"/world/batch-calls"},{kind:"MdxPage",name:"function-selectors",route:"/world/function-selectors"},{kind:"MdxPage",name:"introduction",route:"/world/introduction"},{kind:"Folder",name:"modules",route:"/world/modules",children:[{kind:"Meta",data:{keyswithvalue:"Keys with Value"}},{kind:"MdxPage",name:"keyswithvalue",route:"/world/modules/keyswithvalue"}]},{kind:"MdxPage",name:"modules",route:"/world/modules"},{kind:"MdxPage",name:"namespaces-access-control",route:"/world/namespaces-access-control"},{kind:"Folder",name:"reference",route:"/world/reference",children:[{kind:"Meta",data:{"delegation-external":"Delegation (interface)",module:"Modules","module-external":"Modules (interface)",system:"Systems","system-external":"Systems (interface)",world:"World","world-external":"World (interfaces)","world-context":"World context","world-context-external":"World context (interface)","resource-ids":"Resource IDs",misc:"Miscellaneous",internal:"Internals"}},{kind:"MdxPage",name:"delegation-external",route:"/world/reference/delegation-external"},{kind:"Folder",name:"internal",route:"/world/reference/internal",children:[{kind:"Meta",data:{"access-control":"Access Control",create:"Create2",delegation:"Delegation",erc165:"ERC165","erc165-external":"ERC165 (interface)","init-module":"Init Module","init-module-implementation":"Init Module Implementation",systemcall:"SystemCall"}},{kind:"MdxPage",name:"access-control",route:"/world/reference/internal/access-control"},{kind:"MdxPage",name:"create",route:"/world/reference/internal/create"},{kind:"MdxPage",name:"delegation",route:"/world/reference/internal/delegation"},{kind:"MdxPage",name:"erc165-external",route:"/world/reference/internal/erc165-external"},{kind:"MdxPage",name:"erc165",route:"/world/reference/internal/erc165"},{kind:"MdxPage",name:"init-module-implementation",route:"/world/reference/internal/init-module-implementation"},{kind:"MdxPage",name:"init-module",route:"/world/reference/internal/init-module"},{kind:"MdxPage",name:"systemcall",route:"/world/reference/internal/systemcall"}]},{kind:"MdxPage",name:"misc",route:"/world/reference/misc"},{kind:"MdxPage",name:"module-external",route:"/world/reference/module-external"},{kind:"MdxPage",name:"module",route:"/world/reference/module"},{kind:"MdxPage",name:"resource-ids",route:"/world/reference/resource-ids"},{kind:"MdxPage",name:"system-external",route:"/world/reference/system-external"},{kind:"MdxPage",name:"system",route:"/world/reference/system"},{kind:"MdxPage",name:"world-context-external",route:"/world/reference/world-context-external"},{kind:"MdxPage",name:"world-context",route:"/world/reference/world-context"},{kind:"MdxPage",name:"world-external",route:"/world/reference/world-external"},{kind:"MdxPage",name:"world",route:"/world/reference/world"}]},{kind:"MdxPage",name:"resource-ids",route:"/world/resource-ids"},{kind:"MdxPage",name:"system-hooks",route:"/world/system-hooks"},{kind:"MdxPage",name:"systems",route:"/world/systems"},{kind:"MdxPage",name:"tables",route:"/world/tables"},{kind:"MdxPage",name:"upgrades",route:"/world/upgrades"}]}],flexsearch:{codeblocks:!0},title:"mud deploy"},pageNextRoute:"/cli/deploy",nextraLayout:i.ZP,themeConfig:d.Z};function c(e){let n=Object.assign({h1:"h1",p:"p",h2:"h2",code:"code",ul:"ul",li:"li",pre:"pre",span:"span",a:"a",table:"table",thead:"thead",tr:"tr",th:"th",tbody:"tbody",td:"td",h3:"h3",ol:"ol"},(0,o.ah)(),e.components);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n.h1,{children:"mud deploy"}),"\n",(0,r.jsx)(n.p,{children:"This command deploys a MUD app to a blockchain."}),"\n",(0,r.jsx)(n.h2,{id:"using-the-command",children:"Using the command"}),"\n",(0,r.jsxs)(n.p,{children:["Before you run ",(0,r.jsx)(n.code,{children:"mud deploy"})," you need to specify the private key of the deploying account.\nThere are several ways to do this:"]}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsx)(n.p,{children:"Export an environment variable."}),"\n",(0,r.jsx)(n.pre,{"data-language":"sh","data-theme":"default",hasCopyCode:!0,children:(0,r.jsx)(n.code,{"data-language":"sh","data-theme":"default",children:(0,r.jsxs)(n.span,{className:"line",children:[(0,r.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:"export"}),(0,r.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" PRIVATE_KEY"}),(0,r.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:"="}),(0,r.jsx)(n.span,{style:{color:"var(--shiki-token-constant)"},children:"0"}),(0,r.jsx)(n.span,{style:{color:"var(--shiki-token-string)"},children:"x"}),(0,r.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:"<"}),(0,r.jsx)(n.span,{style:{color:"var(--shiki-token-string)"},children:"key"}),(0,r.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,r.jsx)(n.span,{style:{color:"var(--shiki-token-function)"},children:"goes"}),(0,r.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,r.jsx)(n.span,{style:{color:"var(--shiki-token-string)"},children:"her"}),(0,r.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"e"}),(0,r.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:">"})]})})}),"\n"]}),"\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsxs)(n.p,{children:["Edit ",(0,r.jsx)(n.code,{children:".env"})," to specify the ",(0,r.jsx)(n.code,{children:"PRIVATE_KEY"})," value."]}),"\n",(0,r.jsx)(n.pre,{"data-language":"sh","data-theme":"default",hasCopyCode:!0,children:(0,r.jsxs)(n.code,{"data-language":"sh","data-theme":"default",children:[(0,r.jsx)(n.span,{className:"line",children:(0,r.jsx)(n.span,{style:{color:"var(--shiki-token-comment)"},children:"# This .env file is for demonstration purposes only."})}),"\n",(0,r.jsx)(n.span,{className:"line",children:(0,r.jsx)(n.span,{style:{color:"var(--shiki-token-comment)"},children:"#"})}),"\n",(0,r.jsx)(n.span,{className:"line",children:(0,r.jsx)(n.span,{style:{color:"var(--shiki-token-comment)"},children:"# This should usually be excluded via .gitignore and the env vars attached to"})}),"\n",(0,r.jsx)(n.span,{className:"line",children:(0,r.jsx)(n.span,{style:{color:"var(--shiki-token-comment)"},children:"# your deployment environment, but we're including this here for ease of local"})}),"\n",(0,r.jsx)(n.span,{className:"line",children:(0,r.jsx)(n.span,{style:{color:"var(--shiki-token-comment)"},children:"# development. Please do not commit changes to this file!"})}),"\n",(0,r.jsx)(n.span,{className:"line",children:(0,r.jsx)(n.span,{style:{color:"var(--shiki-token-comment)"},children:"#"})}),"\n",(0,r.jsx)(n.span,{className:"line",children:(0,r.jsx)(n.span,{style:{color:"var(--shiki-token-comment)"},children:"# Anvil default private key:"})}),"\n",(0,r.jsxs)(n.span,{className:"line",children:[(0,r.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"PRIVATE_KEY"}),(0,r.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:"="}),(0,r.jsx)(n.span,{style:{color:"var(--shiki-token-constant)"},children:"0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d"})]})]})}),"\n"]}),"\n"]}),"\n",(0,r.jsx)(n.p,{children:"You also need to specify a URL to the blockchain.\nAgain, there are several ways to do this:"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsxs)(n.li,{children:["Use the ",(0,r.jsx)(n.code,{children:"--rpc <url>"})," command line parameter."]}),"\n",(0,r.jsxs)(n.li,{children:["Specify the URL as the ",(0,r.jsx)(n.code,{children:"eth_rpc_url"})," value ",(0,r.jsxs)(n.a,{href:"https://book.getfoundry.sh/config/",children:["in a profile in ",(0,r.jsx)(n.code,{children:"foundry.toml"})]}),".\nIf the profile isn't the default, use ",(0,r.jsx)(n.code,{children:"--profile <profile name>"}),"."]}),"\n"]}),"\n",(0,r.jsxs)(n.p,{children:["These are the command line options you can specify on ",(0,r.jsx)(n.code,{children:"mud deploy"}),":"]}),"\n",(0,r.jsxs)(n.table,{children:[(0,r.jsx)(n.thead,{children:(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.th,{children:"Option"}),(0,r.jsx)(n.th,{children:"Meaning"}),(0,r.jsx)(n.th,{children:"Type"}),(0,r.jsx)(n.th,{children:"Default value"})]})}),(0,r.jsxs)(n.tbody,{children:[(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.td,{children:(0,r.jsx)(n.code,{children:"--configPath"})}),(0,r.jsx)(n.td,{children:"Path to the config file"}),(0,r.jsx)(n.td,{children:"string"}),(0,r.jsx)(n.td,{children:(0,r.jsx)(n.code,{children:"mud.config.ts"})})]}),(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.td,{children:(0,r.jsx)(n.code,{children:"--printConfig"})}),(0,r.jsx)(n.td,{children:"Print the resolved config"}),(0,r.jsx)(n.td,{children:"boolean"}),(0,r.jsx)(n.td,{children:(0,r.jsx)(n.code,{children:"false"})})]}),(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.td,{children:(0,r.jsx)(n.code,{children:"--saveDeployment"})}),(0,r.jsx)(n.td,{children:"Save the deployment info to a file"}),(0,r.jsx)(n.td,{children:"boolean"}),(0,r.jsx)(n.td,{children:(0,r.jsx)(n.code,{children:"true"})})]}),(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.td,{children:(0,r.jsx)(n.code,{children:"--profile"})}),(0,r.jsx)(n.td,{children:"The foundry profile to use"}),(0,r.jsx)(n.td,{children:"string"}),(0,r.jsx)(n.td,{children:(0,r.jsx)(n.code,{children:"local"})})]}),(0,r.jsxs)(n.tr,{children:[(0,r.jsxs)(n.td,{children:[(0,r.jsx)(n.code,{children:"--rpc"}),(0,r.jsx)("sup",{children:"1"})]}),(0,r.jsx)(n.td,{children:"The RPC URL to use"}),(0,r.jsx)(n.td,{children:"string"}),(0,r.jsxs)(n.td,{children:["RPC url from ",(0,r.jsx)(n.code,{children:"foundry.toml"})]})]}),(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.td,{children:(0,r.jsx)(n.code,{children:"--rpcBatch"})}),(0,r.jsx)(n.td,{children:"Enable batch processing of RPC requests"}),(0,r.jsx)(n.td,{children:"boolean"}),(0,r.jsx)(n.td,{children:(0,r.jsx)(n.code,{children:"false"})})]}),(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.td,{children:(0,r.jsx)(n.code,{children:"--worldAddress"})}),(0,r.jsx)(n.td,{children:"Deploy to an existing World at the given address"}),(0,r.jsx)(n.td,{children:"string"}),(0,r.jsxs)(n.td,{children:["Empty, deploy new ",(0,r.jsx)(n.code,{children:"World"})]})]}),(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.td,{children:(0,r.jsx)(n.code,{children:"--srcDir"})}),(0,r.jsx)(n.td,{children:"Source directory"}),(0,r.jsx)(n.td,{children:"string"}),(0,r.jsxs)(n.td,{children:["Foundry ",(0,r.jsx)(n.code,{children:"src"})," directory"]})]}),(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.td,{children:(0,r.jsx)(n.code,{children:"--skipBuild"})}),(0,r.jsx)(n.td,{children:"Skip rebuilding the contracts before deploying"}),(0,r.jsx)(n.td,{children:"boolean"}),(0,r.jsx)(n.td,{children:(0,r.jsx)(n.code,{children:"false"})})]}),(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.td,{children:(0,r.jsx)(n.code,{children:"--alwaysRunPostDeploy"})}),(0,r.jsxs)(n.td,{children:["Run ",(0,r.jsx)(n.code,{children:"PostDeploy.s.sol"})," after each deploy"]}),(0,r.jsx)(n.td,{children:"boolean"}),(0,r.jsxs)(n.td,{children:[(0,r.jsx)(n.code,{children:"false"})," (run the script only when deploying a new ",(0,r.jsx)(n.code,{children:"World"}),")"]})]}),(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.td,{children:(0,r.jsx)(n.code,{children:"--help"})}),(0,r.jsx)(n.td,{children:"Show help"}),(0,r.jsx)(n.td,{children:"boolean"}),(0,r.jsx)(n.td,{children:(0,r.jsx)(n.code,{children:"false"})})]}),(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.td,{children:(0,r.jsx)(n.code,{children:"--version"})}),(0,r.jsx)(n.td,{children:"Show version number"}),(0,r.jsx)(n.td,{children:"boolean"}),(0,r.jsx)(n.td,{children:(0,r.jsx)(n.code,{children:"false"})})]}),(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.td,{children:(0,r.jsx)(n.code,{children:"--forgeScriptOptions"})}),(0,r.jsx)(n.td,{children:"Command line options for forge"}),(0,r.jsx)(n.td,{children:"string"}),(0,r.jsx)(n.td,{children:"empty"})]})]})]}),"\n",(0,r.jsxs)(n.p,{children:["(1) The hostname ",(0,r.jsx)(n.code,{children:"localhost"})," may not work. If that is the case, use ",(0,r.jsx)(n.code,{children:"127.0.0.1"})," instead."]}),"\n",(0,r.jsx)(a.UW,{type:"info",emoji:"ℹ️",children:(0,r.jsxs)(n.p,{children:["If you want to ",(0,r.jsx)(n.a,{href:"./verify",children:"verify"})," the contracts that make up the ",(0,r.jsx)(n.code,{children:"World"}),", do it right after deployment. Verification\nonly works with the original source code, compiler options, and compiled artifacts. Otherwise, the generated bytecode\nis different and therefore verification fails."]})}),"\n",(0,r.jsx)(n.h3,{id:"interaction-with-the-templates",children:"Interaction with the templates"}),"\n",(0,r.jsxs)(n.p,{children:["The ",(0,r.jsx)(n.a,{href:"/quickstart#using-the-templates",children:"TypeScript templates"})," provided by Lattice all include two packages:"]}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsxs)(n.li,{children:[(0,r.jsx)(n.code,{children:"contracts"}),", which contain the onchain components: contracts, call to start ",(0,r.jsx)(n.code,{children:"anvil"})," to have a local blockchain, etc."]}),"\n",(0,r.jsxs)(n.li,{children:[(0,r.jsx)(n.code,{children:"client"}),", which contains the offchain components: the ",(0,r.jsx)(n.code,{children:"vite"})," HTTP server, the TypeScript code, etc."]}),"\n"]}),"\n",(0,r.jsxs)(n.p,{children:["When you develop locally, you run ",(0,r.jsx)(n.code,{children:"pnpm dev"})," from the root of the template and that runs both packages.\nHowever, when you deploy to a different blockchain you don't need ",(0,r.jsx)(n.code,{children:"anvil"})," running anymore, so instead you:"]}),"\n",(0,r.jsxs)(n.ol,{children:["\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsxs)(n.p,{children:["Use ",(0,r.jsx)(n.code,{children:"pnpm mud deploy"})," in the ",(0,r.jsx)(n.code,{children:"packages/contracts"})," directory to deploy to the appropriate blockchain."]}),"\n"]}),"\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsxs)(n.p,{children:["Specify the chain on which you installed the contracts in the ",(0,r.jsx)(n.code,{children:"VITE_CHAIN_ID"})," environment variable.\nFor example, if you installed on ",(0,r.jsx)(n.a,{href:"https://garnetchain.com/docs/network-info",children:"Garnet"}),", run this command."]}),"\n",(0,r.jsx)(n.pre,{"data-language":"sh","data-theme":"default",hasCopyCode:!0,children:(0,r.jsx)(n.code,{"data-language":"sh","data-theme":"default",children:(0,r.jsxs)(n.span,{className:"line",children:[(0,r.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:"export"}),(0,r.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" VITE_CHAIN_ID"}),(0,r.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:"="}),(0,r.jsx)(n.span,{style:{color:"var(--shiki-token-constant)"},children:"17069"})]})})}),"\n"]}),"\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsxs)(n.p,{children:["Run ",(0,r.jsx)(n.code,{children:"pnpm vite"})," in the ",(0,r.jsx)(n.code,{children:"packages/clients"})," directory to start the user interface.\nIf you want to use a different chain ID than the one specified for vite, use the ",(0,r.jsx)(n.code,{children:"chainId"})," URL parameter.\nFor example, if you deployed both to Garnet and a local ",(0,r.jsx)(n.code,{children:"anvil"})," instance, you can use ",(0,r.jsx)(n.a,{href:"http://localhost:3000/?chainId=31337",children:(0,r.jsx)(n.code,{children:"http://localhost:3000/?chainId=31337"})})," to get to the local instance regardless of the ",(0,r.jsx)(n.code,{children:"VITE_CHAIN_ID"})," value."]}),"\n"]}),"\n"]}),"\n",(0,r.jsx)(n.h2,{id:"examples",children:"Examples"}),"\n",(0,r.jsxs)(n.h3,{id:"new-world",children:["New ",(0,r.jsx)(n.code,{children:"World"})]}),"\n",(0,r.jsxs)(n.p,{children:["To create a new ",(0,r.jsx)(n.code,{children:"World"})," you can use this command line:"]}),"\n",(0,r.jsx)(n.pre,{"data-language":"sh","data-theme":"default",hasCopyCode:!0,children:(0,r.jsx)(n.code,{"data-language":"sh","data-theme":"default",children:(0,r.jsxs)(n.span,{className:"line",children:[(0,r.jsx)(n.span,{style:{color:"var(--shiki-token-function)"},children:"pnpm"}),(0,r.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,r.jsx)(n.span,{style:{color:"var(--shiki-token-string)"},children:"mud"}),(0,r.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,r.jsx)(n.span,{style:{color:"var(--shiki-token-string)"},children:"deploy"}),(0,r.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,r.jsx)(n.span,{style:{color:"var(--shiki-token-string)"},children:"--rpc"}),(0,r.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,r.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:"<"}),(0,r.jsx)(n.span,{style:{color:"var(--shiki-token-string)"},children:"ur"}),(0,r.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"l"}),(0,r.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:">"})]})})}),"\n",(0,r.jsxs)(n.p,{children:["This command also writes the ",(0,r.jsx)(n.code,{children:"World"}),"'s address to ",(0,r.jsx)(n.code,{children:"worlds.json"}),"."]}),"\n",(0,r.jsxs)(n.h3,{id:"upgrading-a-world",children:["Upgrading a ",(0,r.jsx)(n.code,{children:"World"})]}),"\n",(0,r.jsxs)(n.p,{children:["To upgrade a ",(0,r.jsx)(n.code,{children:"World"}),"'s ",(0,r.jsx)(n.code,{children:"System"}),"s and tables, you can use this command line:"]}),"\n",(0,r.jsx)(n.pre,{"data-language":"sh","data-theme":"default",hasCopyCode:!0,children:(0,r.jsx)(n.code,{"data-language":"sh","data-theme":"default",children:(0,r.jsxs)(n.span,{className:"line",children:[(0,r.jsx)(n.span,{style:{color:"var(--shiki-token-function)"},children:"pnpm"}),(0,r.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,r.jsx)(n.span,{style:{color:"var(--shiki-token-string)"},children:"mud"}),(0,r.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,r.jsx)(n.span,{style:{color:"var(--shiki-token-string)"},children:"deploy"}),(0,r.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,r.jsx)(n.span,{style:{color:"var(--shiki-token-string)"},children:"--rpc"}),(0,r.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,r.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:"<"}),(0,r.jsx)(n.span,{style:{color:"var(--shiki-token-string)"},children:"ur"}),(0,r.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"l"}),(0,r.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:">"}),(0,r.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,r.jsx)(n.span,{style:{color:"var(--shiki-token-string)"},children:"--worldAddress"}),(0,r.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,r.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:"<"}),(0,r.jsx)(n.span,{style:{color:"var(--shiki-token-string)"},children:"addres"}),(0,r.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"s"}),(0,r.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:">"})]})})}),"\n",(0,r.jsxs)(n.p,{children:["If properly configured, ",(0,r.jsx)(n.a,{href:"/world/upgrades",children:"there is also a way to upgrade the core MUD contracts"}),"."]}),"\n",(0,r.jsx)(n.h2,{id:"debugging",children:"Debugging"}),"\n",(0,r.jsx)(n.p,{children:"To generate debug messages, use this command:"}),"\n",(0,r.jsx)(n.pre,{"data-language":"sh","data-theme":"default",hasCopyCode:!0,children:(0,r.jsx)(n.code,{"data-language":"sh","data-theme":"default",children:(0,r.jsxs)(n.span,{className:"line",children:[(0,r.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:"export"}),(0,r.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" DEBUG"}),(0,r.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:"="}),(0,r.jsx)(n.span,{style:{color:"var(--shiki-token-string)"},children:"mud:cli:deploy"})]})})}),"\n",(0,r.jsx)(n.h2,{id:"known-issues",children:"Known issues"}),"\n",(0,r.jsx)(n.h3,{id:"out-of-gas",children:"Out of gas"}),"\n",(0,r.jsx)(n.p,{children:"When deploying to a blockchain, you might get an error due to the post-deploy script being out of gas:"}),"\n",(0,r.jsx)(n.pre,{"data-language":"text","data-theme":"default",children:(0,r.jsxs)(n.code,{"data-language":"text","data-theme":"default",children:[(0,r.jsx)(n.span,{className:"line",children:(0,r.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"Error: Error:"})}),"\n",(0,r.jsx)(n.span,{className:"line",children:(0,r.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"Transaction Failure: <transaction hash>"})}),"\n",(0,r.jsx)(n.span,{className:"line",children:(0,r.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:'Error running "forge script PostDeploy --broadcast --sig run(address) <world address> --rpc-url <conduit URL> -vvv --legacy --no-gas-limit"'})}),"\n",(0,r.jsx)(n.span,{className:"line",children:(0,r.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"    at o (file:/// < directory > /tutorial3/node_modules/.pnpm/@latticexyz+common@2.0.12_@aws-sdk+client-kms@3.598.0_asn1.js@5.4.1_typescript@5.4.2_zod@3.23.8/node_modules/@latticexyz/common/dist/foundry.js:2:23)"})}),"\n",(0,r.jsx)(n.span,{className:"line",children:(0,r.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)"})}),"\n",(0,r.jsx)(n.span,{className:"line",children:(0,r.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"    (...)"})})]})}),"\n",(0,r.jsxs)(n.p,{children:["In some cases, ",(0,r.jsx)(n.code,{children:"forge"}),"'s default gas estimates are too low, so the transaction runs out of gas."]}),"\n",(0,r.jsxs)(n.p,{children:["Until ",(0,r.jsx)(n.a,{href:"https://github.com/latticexyz/mud/issues/2907",children:"the issue is fixed upstream"}),", you can get around it by using the ",(0,r.jsx)(n.code,{children:"--forgeScriptOptions"})," command line parameter to specify ",(0,r.jsx)(n.a,{href:"https://book.getfoundry.sh/reference/forge/forge-script?highlight=gas-estimate-multiplier#options",children:"the gas estimate multiplier"})," ",(0,r.jsx)(n.code,{children:"forge script"})," will use."]}),"\n",(0,r.jsx)(n.pre,{"data-language":"text","data-theme":"default",children:(0,r.jsx)(n.code,{"data-language":"text","data-theme":"default",children:(0,r.jsx)(n.span,{className:"line",children:(0,r.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"pnpm mud deploy --rpc $RPC_URL --forgeScriptOptions '\\-\\-gas-estimate-multiplier 200'"})})})})]})}n.default=(0,s.j)(l)}},function(e){e.O(0,[3720,2888,179],function(){return e(e.s=18563)}),_N_E=e.O()}]);