Tables
World uses the store tables, but adds access control.
For onchain tables, the data is stored by the World contract, which is also a StoreData (opens in a new tab).
When a System reads or writes storage via table libraries, the request goes into StoreSwitch (opens in a new tab). This library decides which approach to use:
-
If the
Systemis in the root namespace, then it was called withdelegatecall(opens in a new tab). This means it inherits theWorldstorage and can write directly to storage usingStoreCore(opens in a new tab). These calls bypass access control. -
If the
Systemis in any other namespace, then it was called withcall(opens in a new tab) and has to call back into theWorldusingIStore(opens in a new tab). These calls go through access control. They are only permitted if theSystemhas access to the table in question. By default aSystemhas access to its own namespace and therefore to all the tables inside it. Additional access can be granted by the namespace owner.
-
An account calls a function called
namespace_system_functionvia theWorld. This function was registered by the owner of thenamespacenamespace and points to thefunctionfunction in thesystemsystem in thenamespacenamespace. -
The
Worldverifies that access is permitted (for example, becausenamespace:systemis publicly accessible) and if so callsfunctionon thenamespace:systemcontract with the provided parameters. -
At some point in its execution
functiondecides to update the data in the tablenamespace:table. As with all other tables, this table is stored in theWorld's storage. To modify it,functioncalls a function on theWorldcontract. -
The
Worldverifies that access is permitted (by default it would be, becausenamespace:systemhas access to thenamespacenamespace). If so, it modifies the data in thenamespace:tabletable.