(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4439],{87120:function(e,s,n){(window.__NEXT_P=window.__NEXT_P||[]).push(["/world/namespaces-access-control",function(){return n(23719)}])},48986:function(e,s,n){"use strict";n.d(s,{C:function(){return i}});var t=n(7505),r=n(7765),o=n(24737),a=n.n(o);function i(e){let{children:s}=e,n=(0,r.useRef)(null),[o,i]=(0,r.useState)(!0);return(0,r.useEffect)(()=>{if(!n.current)return;let e=Array.from(n.current.querySelectorAll(".line")),s=[];e.forEach((e,n)=>{e.matches(".highlighted")&&s.push(n),/^\s+$/g.test(e.innerHTML)&&e.setAttribute("data-empty","")}),s.length&&e.forEach((e,n)=>{let t=s.reduce((e,s)=>Math.min(e,Math.abs(s-n)),1/0);e.setAttribute("data-highlight-distance",Math.min(t,4).toString())})},[o]),(0,t.jsx)("div",{ref:n,style:{marginTop:"1.5rem"},className:o?a().collapsed:a().expanded,onClick:e=>{e.target instanceof Element&&e.target.closest(".line")&&i(!o)},children:s})}},73307:function(e,s,n){"use strict";n.d(s,{Z:function(){return a}});var t=n(7505),r=n(11689);let o={logo:function(){return(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"0.25em",fontSize:"32px",fontFamily:"PP Supply Mono",textTransform:"uppercase"},children:[(0,t.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,r.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,t.jsx)(t.Fragment,{children:(0,t.jsx)("meta",{property:"title",content:"MUD documentation"})}),darkMode:!1,nextThemes:{defaultTheme:"dark"},footer:{text:"MIT 2023 \xa9 MUD"},primaryHue:28,sidebar:{defaultMenuCollapseLevel:1}};var a=o},23719:function(e,s,n){"use strict";n.r(s);var t=n(7505),r=n(42585),o=n(38288),a=n(73307);n(54693);var i=n(26736);n(98823);var l=n(48986);let c={MDXContent:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{wrapper:s}=Object.assign({},(0,i.ah)(),e.components);return s?(0,t.jsx)(s,{...e,children:(0,t.jsx)(d,{...e})}):d(e)},pageOpts:{filePath:"pages/world/namespaces-access-control.mdx",route:"/world/namespaces-access-control",headings:[{depth:1,value:"Namespaces and Access Control",id:"namespaces-and-access-control"},{depth:2,value:"Access control levels",id:"access-control-levels"},{depth:3,value:'"No" access',id:"no-access"},{depth:3,value:"Access",id:"access"},{depth:3,value:"Ownership",id:"ownership"},{depth:2,value:"Modifying access control",id:"modifying-access-control"}],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.1",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",modules:"Writing MUD Modules",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:{"dividing-into-systems":"Dividing Code into Systems","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:"dividing-into-systems",route:"/guides/best-practices/dividing-into-systems"},{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"},"add-chain-client":"Add chains to the client"}},{kind:"MdxPage",name:"add-chain-client",route:"/guides/hello-world/add-chain-client"},{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:"modules",route:"/guides/modules"},{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:"Folder",name:"indexer",route:"/services/indexer",children:[{kind:"Meta",data:{"using-indexer":"Using the Indexer","sqlite-indexer":"SQLite Indexer","postgres-event-only":"PostgreSQL for events","postgres-decoded":"PostgreSQL for data (and events)"}},{kind:"MdxPage",name:"postgres-decoded",route:"/services/indexer/postgres-decoded"},{kind:"MdxPage",name:"postgres-event-only",route:"/services/indexer/postgres-event-only"},{kind:"MdxPage",name:"sqlite-indexer",route:"/services/indexer/sqlite-indexer"},{kind:"MdxPage",name:"using-indexer",route:"/services/indexer/using-indexer"}]},{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",nethereum:"Nethereum"}},{kind:"MdxPage",name:"godot",route:"/templates/godot"},{kind:"MdxPage",name:"nethereum",route:"/templates/nethereum"},{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",erc721:"ERC-721 (NFT)"}},{kind:"MdxPage",name:"erc721",route:"/world/modules/erc721"},{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:"Namespaces and Access Control"},pageNextRoute:"/world/namespaces-access-control",nextraLayout:o.ZP,themeConfig:a.Z};function d(e){let s=Object.assign({h1:"h1",p:"p",code:"code",a:"a",h2:"h2",h3:"h3",ul:"ul",li:"li",pre:"pre",span:"span"},(0,i.ah)(),e.components);return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(s.h1,{children:"Namespaces and Access Control"}),"\n",(0,t.jsxs)(s.p,{children:["Access control in a ",(0,t.jsx)(s.code,{children:"World"})," is based on namespaces.\nEvery resource is part of a namespace (a blank namespace refers to the ",(0,t.jsx)(s.code,{children:"root"})," namespace).\nAccess to resources is managed by the owner of the namespace."]}),"\n",(0,t.jsxs)(s.p,{children:["Access control can be attached to ",(0,t.jsx)(s.a,{href:"/world/resource-ids",children:"any resource"}),"."]}),"\n",(0,t.jsx)(s.h2,{id:"access-control-levels",children:"Access control levels"}),"\n",(0,t.jsx)(s.p,{children:"There are three access levels in MUD."}),"\n",(0,t.jsx)(s.h3,{id:"no-access",children:'"No" access'}),"\n",(0,t.jsx)(s.p,{children:"This is the level that most users of a MUD application have for all resources.\nUsers on this level are allowed to do the following:"}),"\n",(0,t.jsxs)(s.ul,{children:["\n",(0,t.jsx)(s.li,{children:"Read data from tables.\nAny information posted or created on the blockchain is public, so this information is available anyway."}),"\n",(0,t.jsxs)(s.li,{children:["Call functions on ",(0,t.jsxs)(s.a,{href:"./systems",children:["public ",(0,t.jsx)(s.code,{children:"System"}),"s"]}),"."]}),"\n"]}),"\n",(0,t.jsx)(s.h3,{id:"access",children:"Access"}),"\n",(0,t.jsx)(s.p,{children:"This level of access is often required for software that is part of the application.\nAccess can be granted either on a namespace basis (access to the namespace gives access to all the resources inside it) or on an individual resource."}),"\n",(0,t.jsx)(s.p,{children:'Entities with this level of access can do anything that "no" access allows, and also:'}),"\n",(0,t.jsxs)(s.ul,{children:["\n",(0,t.jsxs)(s.li,{children:["Write directly to tables.\nThis is as opposed to users with no access, who can only modify table information by going through a public ",(0,t.jsx)(s.code,{children:"System"})," (by default, a ",(0,t.jsx)(s.code,{children:"System"})," has access to its own namespace, which includes all of the namespace's tables)."]}),"\n",(0,t.jsxs)(s.li,{children:["Call functions on ",(0,t.jsxs)(s.a,{href:"./systems",children:["private ",(0,t.jsx)(s.code,{children:"System"}),"s"]}),"."]}),"\n",(0,t.jsx)(s.li,{children:"In the case of access to a namespace, withdraw from the ETH balance of the namespace.\nTo avoid giving this permission, you can give an address access to every resource in the namespace, rather than to the namespace itself."}),"\n"]}),"\n",(0,t.jsx)(s.h3,{id:"ownership",children:"Ownership"}),"\n",(0,t.jsxs)(s.p,{children:[(0,t.jsx)(s.code,{children:"Namespace"})," is the only resource type that has an owner.\nThe owner is a single account (but by using multi-sig accounts ownership can be shared)."]}),"\n",(0,t.jsx)(s.p,{children:"The owner is an administrative account, a superuser.\nWhen you change ownership, the new owner gets access to the namespace, and the old owner loses it.\nTherefore, owners can do anything an address with access can.\nAdditionally, owners can also:"}),"\n",(0,t.jsxs)(s.ul,{children:["\n",(0,t.jsx)(s.li,{children:"Grant and revoke access within the namespace (either to the namespace itself or to resources inside it)."}),"\n",(0,t.jsx)(s.li,{children:"Transfer namespace ownership."}),"\n",(0,t.jsxs)(s.li,{children:["Register a ",(0,t.jsx)(s.a,{href:"/world/account-delegation",children:"namespace delegation control"}),"."]}),"\n",(0,t.jsxs)(s.li,{children:["Register new ",(0,t.jsx)(s.a,{href:"/store/tables",children:"tables"}),"."]}),"\n",(0,t.jsxs)(s.li,{children:["Register ",(0,t.jsx)(s.a,{href:"/store/store-hooks",children:"store hooks"})," for tables in the namespace."]}),"\n",(0,t.jsxs)(s.li,{children:["Register new ",(0,t.jsx)(s.a,{href:"/world/systems",children:"systems"}),"."]}),"\n",(0,t.jsx)(s.li,{children:"Upgrade existing systems."}),"\n",(0,t.jsxs)(s.li,{children:["Register ",(0,t.jsx)(s.a,{href:"/world/system-hooks",children:"system hooks"})," for systems in the namespace."]}),"\n",(0,t.jsxs)(s.li,{children:["Register ",(0,t.jsx)(s.a,{href:"/world/function-selectors",children:"function selectors"})," for systems in the namespace."]}),"\n"]}),"\n",(0,t.jsxs)(s.p,{children:["Owners can modify which contract a ",(0,t.jsx)(s.code,{children:"World"})," uses for each ",(0,t.jsx)(s.code,{children:"System"}),".\nNote: once ownership of a namespace is burned (i.e. transferred to ",(0,t.jsx)(s.code,{children:"address(0)"}),"), no new access can be granted or revoked, ownership can't be transferred again, and ",(0,t.jsx)(s.code,{children:"System"}),"s can't be added, removed, or upgraded (unless the ",(0,t.jsx)(s.code,{children:"System"})," is itself a ",(0,t.jsx)(s.a,{href:"https://blog.openzeppelin.com/proxy-patterns",children:"proxy"}),")."]}),"\n",(0,t.jsx)(s.h2,{id:"modifying-access-control",children:"Modifying access control"}),"\n",(0,t.jsx)(s.p,{children:"By default access to a namespace is granted to:"}),"\n",(0,t.jsxs)(s.ul,{children:["\n",(0,t.jsx)(s.li,{children:"The namespace owner"}),"\n",(0,t.jsxs)(s.li,{children:["The ",(0,t.jsx)(s.code,{children:"System"}),"s of that namespace"]}),"\n"]}),"\n",(0,t.jsx)(s.p,{children:"Namespace access provides access to all the resources within the namespace, so there is no need, by default, for access to the resources within the namespace."}),"\n",(0,t.jsxs)(s.p,{children:["If that is insufficient, ",(0,t.jsx)(s.a,{href:"https://github.com/latticexyz/mud/blob/main/packages/world/src/modules/init/implementations/AccessManagementSystem.sol",children:(0,t.jsx)(s.code,{children:"AccessManagementSystem"})})," lets you ",(0,t.jsx)(s.a,{href:"https://github.com/latticexyz/mud/blob/main/packages/world/src/modules/init/implementations/AccessManagementSystem.sol#L18-L33",children:(0,t.jsx)(s.code,{children:"grantAccess"})}),", ",(0,t.jsx)(s.a,{href:"https://github.com/latticexyz/mud/blob/main/packages/world/src/modules/init/implementations/AccessManagementSystem.sol#L35-L47",children:(0,t.jsx)(s.code,{children:"revokeAccess"})}),", and ",(0,t.jsx)(s.a,{href:"https://github.com/latticexyz/mud/blob/main/packages/world/src/modules/init/implementations/AccessManagementSystem.sol#L49-L73",children:(0,t.jsx)(s.code,{children:"transferOwnership"})})," of a namespace."]}),"\n",(0,t.jsxs)(s.p,{children:["For example, here is a script that grants access to the ",(0,t.jsx)(s.code,{children:"Counter"})," table to one address and revokes it for another."]}),"\n",(0,t.jsx)(l.C,{children:(0,t.jsx)(s.pre,{"data-language":"solidity","data-theme":"default",filename:"Permissions.s.sol",hasCopyCode:!0,children:(0,t.jsxs)(s.code,{"data-language":"solidity","data-theme":"default",children:[(0,t.jsxs)(s.span,{className:"line",children:[(0,t.jsx)(s.span,{style:{color:"var(--shiki-token-keyword)"},children:"pragma"}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-token-string-expression)"},children:"solidity"}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" >=0.8.21;"})]}),"\n",(0,t.jsx)(s.span,{className:"line",children:" "}),"\n",(0,t.jsxs)(s.span,{className:"line",children:[(0,t.jsx)(s.span,{style:{color:"var(--shiki-token-keyword)"},children:"import"}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" { "}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-token-function)"},children:"Script"}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" } "}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-token-keyword)"},children:"from"}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"forge-std/Script.sol"'}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:";"})]}),"\n",(0,t.jsxs)(s.span,{className:"line",children:[(0,t.jsx)(s.span,{style:{color:"var(--shiki-token-keyword)"},children:"import"}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" { "}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-token-function)"},children:"console"}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" } "}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-token-keyword)"},children:"from"}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"forge-std/console.sol"'}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:";"})]}),"\n",(0,t.jsxs)(s.span,{className:"line",children:[(0,t.jsx)(s.span,{style:{color:"var(--shiki-token-keyword)"},children:"import"}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" { "}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-token-function)"},children:"StoreSwitch"}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" } "}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-token-keyword)"},children:"from"}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"@latticexyz/store/src/StoreSwitch.sol"'}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:";"})]}),"\n",(0,t.jsx)(s.span,{className:"line",children:" "}),"\n",(0,t.jsxs)(s.span,{className:"line highlighted",children:[(0,t.jsx)(s.span,{style:{color:"var(--shiki-token-keyword)"},children:"import"}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" { "}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-token-function)"},children:"IWorld"}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" } "}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-token-keyword)"},children:"from"}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"../src/codegen/world/IWorld.sol"'}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:";"})]}),"\n",(0,t.jsxs)(s.span,{className:"line highlighted",children:[(0,t.jsx)(s.span,{style:{color:"var(--shiki-token-keyword)"},children:"import"}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" { "}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-token-function)"},children:"Counter"}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" } "}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-token-keyword)"},children:"from"}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"../src/codegen/index.sol"'}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:";"})]}),"\n",(0,t.jsx)(s.span,{className:"line",children:" "}),"\n",(0,t.jsxs)(s.span,{className:"line",children:[(0,t.jsx)(s.span,{style:{color:"var(--shiki-token-keyword)"},children:"contract"}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-token-function)"},children:"Permissions"}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-token-keyword)"},children:"is"}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-token-function)"},children:"Script"}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" {"})]}),"\n",(0,t.jsxs)(s.span,{className:"line",children:[(0,t.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:"  "}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-token-keyword)"},children:"function"}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-token-function)"},children:"run"}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:"() "}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-token-keyword)"},children:"external"}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" {"})]}),"\n",(0,t.jsxs)(s.span,{className:"line",children:[(0,t.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:"    "}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-token-constant)"},children:"address"}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" worldAddress "}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-token-keyword)"},children:"="}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-token-constant)"},children:"0xC14fBdb7808D9e2a37c1a45b635C8C3fF64a1cc1"}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:";"})]}),"\n",(0,t.jsx)(s.span,{className:"line",children:" "}),"\n",(0,t.jsxs)(s.span,{className:"line",children:[(0,t.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:"    "}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-token-comment)"},children:"// Load the private key from the `PRIVATE_KEY` environment variable (in .env)"})]}),"\n",(0,t.jsxs)(s.span,{className:"line",children:[(0,t.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:"    "}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-token-constant)"},children:"uint256"}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" namespaceOwnerPrivateKey "}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-token-keyword)"},children:"="}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" vm."}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-token-function)"},children:"envUint"}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:"("}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"PRIVATE_KEY"'}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:");"})]}),"\n",(0,t.jsx)(s.span,{className:"line",children:" "}),"\n",(0,t.jsxs)(s.span,{className:"line",children:[(0,t.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:"    "}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-token-comment)"},children:"// Start broadcasting transactions from the account owning the namespace"})]}),"\n",(0,t.jsxs)(s.span,{className:"line",children:[(0,t.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:"    vm."}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-token-function)"},children:"startBroadcast"}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:"(namespaceOwnerPrivateKey);"})]}),"\n",(0,t.jsx)(s.span,{className:"line",children:" "}),"\n",(0,t.jsxs)(s.span,{className:"line highlighted",children:[(0,t.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:"    "}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-token-function)"},children:"IWorld"}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:"(worldAddress)."}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-token-function)"},children:"grantAccess"}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:"(Counter._tableId"}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-token-punctuation)"},children:","}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-token-constant)"},children:"address"}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:"("}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-token-constant)"},children:"0"}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:"));"})]}),"\n",(0,t.jsxs)(s.span,{className:"line highlighted",children:[(0,t.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:"    "}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-token-function)"},children:"IWorld"}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:"(worldAddress)."}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-token-function)"},children:"revokeAccess"}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:"(Counter._tableId"}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-token-punctuation)"},children:","}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-token-constant)"},children:"address"}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:"("}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-token-constant)"},children:"1"}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:"));"})]}),"\n",(0,t.jsx)(s.span,{className:"line",children:" "}),"\n",(0,t.jsxs)(s.span,{className:"line",children:[(0,t.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:"    vm."}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-token-function)"},children:"stopBroadcast"}),(0,t.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:"();"})]}),"\n",(0,t.jsx)(s.span,{className:"line",children:(0,t.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:"  }"})}),"\n",(0,t.jsx)(s.span,{className:"line",children:(0,t.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:"}"})})]})})})]})}s.default=(0,r.j)(c)},24737:function(e){e.exports={collapsed:"CollapseCode_collapsed__D1CXB",expanded:"CollapseCode_expanded__x1xKU"}}},function(e){e.O(0,[3720,2888,179],function(){return e(e.s=87120)}),_N_E=e.O()}]);