World
Reference
Internals
Init Module Implementation

AccessManagementSystem

Git Source (opens in a new tab)

Inherits: System, LimitedCallContext

This contract manages the granting and revoking of access from/to resources.

Functions

grantAccess

Grant access to the resource at the given resource ID.

Requires the caller to own the namespace.

function grantAccess(ResourceId resourceId, address grantee) public virtual onlyDelegatecall;

Parameters

NameTypeDescription
resourceIdResourceIdThe ID of the resource to grant access to.
granteeaddressThe address to which access should be granted.

revokeAccess

Revoke access from the resource at the given resource ID.

Requires the caller to own the namespace.

function revokeAccess(ResourceId resourceId, address grantee) public virtual onlyDelegatecall;

Parameters

NameTypeDescription
resourceIdResourceIdThe ID of the resource to revoke access from.
granteeaddressThe address from which access should be revoked.

transferOwnership

Transfer ownership of the given namespace to newOwner and manages the access.

Requires the caller to own the namespace. Revoke ResourceAccess for previous owner and grant to newOwner.

function transferOwnership(ResourceId namespaceId, address newOwner) public virtual onlyDelegatecall;

Parameters

NameTypeDescription
namespaceIdResourceIdThe ID of the namespace to transfer ownership.
newOwneraddressThe address to which ownership should be transferred.

renounceOwnership

Renounces ownership of the given namespace

Requires the caller to own the namespace. Revoke ResourceAccess for previous owner

function renounceOwnership(ResourceId namespaceId) public virtual onlyDelegatecall;

Parameters

NameTypeDescription
namespaceIdResourceIdThe ID of the namespace to transfer ownership.

ModuleInstallationSystem

Git Source (opens in a new tab)

Inherits: System, LimitedCallContext

A system contract to handle the installation of (non-root) modules in the World.

Functions

installModule

Installs a module into the World under a specified namespace.

Validates the given module against the IModule interface and delegates the installation process. The module is then registered in the InstalledModules table.

function installModule(IModule module, bytes memory encodedArgs) public onlyDelegatecall;

Parameters

NameTypeDescription
moduleIModuleThe module to be installed.
encodedArgsbytesThe ABI encoded arguments for module installation.

BalanceTransferSystem

Git Source (opens in a new tab)

Inherits: System, IWorldErrors, LimitedCallContext

A system contract that facilitates balance transfers in the World and outside of the World.

Functions

transferBalanceToNamespace

Transfer balance to another namespace in the World.

Requires the caller to have access to the source namespace and ensures the destination namespace type is valid.

function transferBalanceToNamespace(
  ResourceId fromNamespaceId,
  ResourceId toNamespaceId,
  uint256 amount
) public virtual onlyDelegatecall;

Parameters

NameTypeDescription
fromNamespaceIdResourceIdThe source namespace from which the balance will be deducted.
toNamespaceIdResourceIdThe target namespace where the balance will be added.
amountuint256The amount to transfer.

transferBalanceToAddress

Usage Sample

Transfer balance out of the World to a specific address.

Requires the caller to have access to the source namespace and ensures sufficient balance before transfer.

function transferBalanceToAddress(
  ResourceId fromNamespaceId,
  address toAddress,
  uint256 amount
) public virtual onlyDelegatecall;

Parameters

NameTypeDescription
fromNamespaceIdResourceIdThe source namespace from which the balance will be deducted.
toAddressaddressThe target address where the balance will be sent.
amountuint256The amount to transfer.

StoreRegistrationSystem

Git Source (opens in a new tab)

Inherits: System, IWorldErrors, LimitedCallContext

This contract provides functionality for the registration of store-related resources within the World framework.

Functions

registerTable

Register a table within the World framework.

Registers a table with the specified configuration. If the namespace for the table does not exist, it's created. Existing namespaces require the caller to be the owner for table registration.

function registerTable(
  ResourceId tableId,
  FieldLayout fieldLayout,
  Schema keySchema,
  Schema valueSchema,
  string[] calldata keyNames,
  string[] calldata fieldNames
) public virtual onlyDelegatecall;

Parameters

NameTypeDescription
tableIdResourceIdThe resource ID of the table.
fieldLayoutFieldLayoutThe field layout structure for the table.
keySchemaSchemaThe schema for the keys of the table.
valueSchemaSchemaThe schema for the values within the table.
keyNamesstring[]The names associated with the keys in the table.
fieldNamesstring[]The names of the fields in the table.

registerStoreHook

Register a storage hook for a specified table.

The caller must be the owner of the namespace to which the table belongs. The hook must conform to the IStoreHook interface.

function registerStoreHook(
  ResourceId tableId,
  IStoreHook hookAddress,
  uint8 enabledHooksBitmap
) public virtual onlyDelegatecall;

Parameters

NameTypeDescription
tableIdResourceIdThe resource ID of the table for which the hook is being registered.
hookAddressIStoreHookThe address of the storage hook contract.
enabledHooksBitmapuint8A bitmap indicating which hook functionalities are enabled.

unregisterStoreHook

Unregister a previously registered storage hook for a specified table.

The caller must be the owner of the namespace to which the table belongs.

function unregisterStoreHook(ResourceId tableId, IStoreHook hookAddress) public virtual onlyDelegatecall;

Parameters

NameTypeDescription
tableIdResourceIdThe resource ID of the table from which the hook is being unregistered.
hookAddressIStoreHookThe address of the storage hook contract.

BatchCallSystem

Git Source (opens in a new tab)

Inherits: System, LimitedCallContext

A system contract that facilitates batching of calls to various systems in a single transaction.

Functions

batchCall

Make batch calls to multiple systems into a single transaction.

Iterates through an array of system calls, executes them, and returns an array of return data.

function batchCall(SystemCallData[] calldata systemCalls) public onlyDelegatecall returns (bytes[] memory returnDatas);

Parameters

NameTypeDescription
systemCallsSystemCallData[]An array of SystemCallData that contains systemId and callData for each call.

Returns

NameTypeDescription
returnDatasbytes[]An array of bytes containing the return data for each system call.

batchCallFrom

Make batch calls from specific addresses to multiple systems in a single transaction.

Iterates through an array of system calls with specified 'from' addresses, executes them, and returns an array of return data.

function batchCallFrom(
  SystemCallFromData[] calldata systemCalls
) public onlyDelegatecall returns (bytes[] memory returnDatas);

Parameters

NameTypeDescription
systemCallsSystemCallFromData[]An array of SystemCallFromData that contains from, systemId, and callData for each call.

Returns

NameTypeDescription
returnDatasbytes[]An array of bytes containing the return data for each system call.

WorldRegistrationSystem

Git Source (opens in a new tab)

Inherits: System, IWorldErrors, LimitedCallContext

This contract provides functions related to registering resources other than tables in the World.

Functions

registerNamespace

Usage Sample

Registers a new namespace

Creates a new namespace resource with the given ID

function registerNamespace(ResourceId namespaceId) public virtual onlyDelegatecall;

Parameters

NameTypeDescription
namespaceIdResourceIdThe unique identifier for the new namespace

registerSystemHook

Registers a new system hook

Adds a new hook for the system at the provided system ID

function registerSystemHook(
  ResourceId systemId,
  ISystemHook hookAddress,
  uint8 enabledHooksBitmap
) public virtual onlyDelegatecall;

Parameters

NameTypeDescription
systemIdResourceIdThe ID of the system
hookAddressISystemHookThe address of the hook being registered
enabledHooksBitmapuint8Bitmap indicating which hooks are enabled

unregisterSystemHook

Unregisters a system hook

Removes a hook for the system at the provided system ID

function unregisterSystemHook(ResourceId systemId, ISystemHook hookAddress) public virtual onlyDelegatecall;

Parameters

NameTypeDescription
systemIdResourceIdThe ID of the system
hookAddressISystemHookThe address of the hook being unregistered

registerSystem

Usage Sample

Registers a system

Registers or upgrades a system at the given ID If the namespace doesn't exist yet, it is registered. The system is granted access to its namespace, so it can write to any table in the same namespace. If publicAccess is true, no access control check is performed for calling the system. This function doesn't check whether a system already exists at the given selector, making it possible to upgrade systems.

function registerSystem(ResourceId systemId, System system, bool publicAccess) public virtual onlyDelegatecall;

Parameters

NameTypeDescription
systemIdResourceIdThe unique identifier for the system
systemSystemThe system being registered
publicAccessboolFlag indicating if access control check is bypassed

registerFunctionSelector

Usage Sample

Registers a new World function selector

Creates a mapping between a World function and its associated system function

function registerFunctionSelector(
  ResourceId systemId,
  string memory systemFunctionSignature
) public onlyDelegatecall returns (bytes4 worldFunctionSelector);

Parameters

NameTypeDescription
systemIdResourceIdThe system ID
systemFunctionSignaturestringThe signature of the system function

Returns

NameTypeDescription
worldFunctionSelectorbytes4The selector of the World function

registerRootFunctionSelector

Usage Sample

Registers a root World function selector

Creates a mapping for a root World function without namespace or name prefix

function registerRootFunctionSelector(
  ResourceId systemId,
  string memory worldFunctionSignature,
  bytes4 systemFunctionSelector
) public onlyDelegatecall returns (bytes4 worldFunctionSelector);

Parameters

NameTypeDescription
systemIdResourceIdThe system ID
worldFunctionSignaturestringThe signature of the World function
systemFunctionSelectorbytes4The selector of the system function

Returns

NameTypeDescription
worldFunctionSelectorbytes4The selector of the World function

registerDelegation

Registers a delegation for the caller

Creates a new delegation from the caller to the specified delegatee

function registerDelegation(
  address delegatee,
  ResourceId delegationControlId,
  bytes memory initCallData
) public onlyDelegatecall;

Parameters

NameTypeDescription
delegateeaddressThe address of the delegatee
delegationControlIdResourceIdThe ID controlling the delegation
initCallDatabytesThe initialization data for the delegation

unregisterDelegation

Unregisters a delegation

Deletes the new delegation from the caller to the specified delegatee

function unregisterDelegation(address delegatee) public onlyDelegatecall;

Parameters

NameTypeDescription
delegateeaddressThe address of the delegatee

registerNamespaceDelegation

Registers a delegation for a namespace

Sets up a new delegation control for a specific namespace

function registerNamespaceDelegation(
  ResourceId namespaceId,
  ResourceId delegationControlId,
  bytes memory initCallData
) public onlyDelegatecall;

Parameters

NameTypeDescription
namespaceIdResourceIdThe ID of the namespace
delegationControlIdResourceIdThe ID controlling the delegation
initCallDatabytesThe initialization data for the delegation

unregisterNamespaceDelegation

Unregisters a delegation for a namespace

Deletes the delegation control for a specific namespace

function unregisterNamespaceDelegation(ResourceId namespaceId) public onlyDelegatecall;

Parameters

NameTypeDescription
namespaceIdResourceIdThe ID of the namespace