Create Extension Tables
Primodium Tables store data in on-chain tables (opens in a new tab) as defined in the open MUD standard.
Primodium Tables exist both in the core Primodium contracts and in world
extensions. When defining a new table, you must first declare it in the
mud.config.ts
file. This file is used to generate the Solidity contracts that
handle setters, getters, and the decoding of each table.
In the ReadDemo, this code can be found in packages/contracts/mud.config.ts
.
Every plugin will need a defineWorld
, which is stored in mud.config.ts
.
Plugins must exist in a Namespace
. Multiple Systems
and Tables
can exist
in a namespace.
Since this demo only deploys a system for reading data, we will not need any new
Tables
, but we will need to declare a Namespace
and System
.
import { defineWorld } from "@latticexyz/world";
export default defineWorld({
namespace: "PluginExamples",
systems: {
ReadDemoSystem: {
name: "ReadDemoSystem",
openAccess: true,
},
},
tables: {},
});
The Namespace
is where the System
will live. They can be up to 16 characters
long, and every namespace must be unique. If you run into a collision, choose a
different name. The collision revert will say World_ResourceAlreadyExists()
,
indicating the namespace already exists and you are not the owner.
More details on MUD Config can be found here (opens in a new tab).