World
Reference
World (interfaces)

IBaseWorld

Git Source (opens in a new tab)

Inherits: IStore, IWorldKernel, IRegistrationSystem, IAccessManagementSystem, IBalanceTransferSystem, IBatchCallSystem, IModuleInstallationSystem, IWorldRegistrationSystem

This interface integrates all systems and associated function selectors that are dynamically registered in the World during deployment.

.

IWorldCall

Git Source (opens in a new tab)

This interface defines the contract for executing calls on the World's systems.

Functions

call

Usage Sample

Call the system at the given system ID.

If the system is not public, the caller must have access to the namespace or name (encoded in the system ID).

function call(ResourceId systemId, bytes memory callData) external payable returns (bytes memory);

Parameters

NameTypeDescription
systemIdResourceIdThe ID of the system to be called.
callDatabytesThe data to pass with the call, function selector (4 bytes) followed by the ABI encoded parameters.

Returns

NameTypeDescription
<none>bytesThe abi encoded return data from the called system.

callFrom

Call the system at the given system ID on behalf of the given delegator.

If the system is not public, the delegator must have access to the namespace or name (encoded in the system ID).

function callFrom(
  address delegator,
  ResourceId systemId,
  bytes memory callData
) external payable returns (bytes memory);

Parameters

NameTypeDescription
delegatoraddressThe address on whose behalf the call is made.
systemIdResourceIdThe ID of the system to be called.
callDatabytesThe data to pass with the call, function selector (4 bytes) followed by the ABI encoded parameters.

Returns

NameTypeDescription
<none>bytesThe abi encoded return data from the called system.

IWorldKernel

Git Source (opens in a new tab)

Inherits: IWorldModuleInstallation, IWorldCall, IWorldErrors, IWorldEvents, IModuleErrors

The IWorldKernel interface includes all methods that are part of the World contract's internal bytecode. Consumers should use the IBaseWorld interface instead, which includes dynamically registered functions selectors from the InitModule.

The IWorldKernel interface inherits IModuleErrors because the world can be delegatecalled with module code, so it's ABI should include these errors.

Functions

worldVersion

Retrieve the protocol version of the World.

function worldVersion() external view returns (bytes32);

Returns

NameTypeDescription
<none>bytes32The protocol version of the World.

creator

Retrieve the immutable original deployer of the World.

function creator() external view returns (address);

Returns

NameTypeDescription
<none>addressThe address of the World's creator.

initialize

Initializes the World.

Can only be called once by the creator.

function initialize(IModule initModule) external;

Parameters

NameTypeDescription
initModuleIModuleThe InitModule to be installed during initialization.

IWorldModuleInstallation

Git Source (opens in a new tab)

This interface defines the contract responsible for managing root modules installation.

Functions

installRootModule

Install the given root module in the World.

Requires the caller to own the root namespace. The module is delegatecalled and installed in the root namespace.

function installRootModule(IModule module, bytes memory encodedArgs) external;

Parameters

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

IWorldErrors

Git Source (opens in a new tab)

This interface contains custom error types for the World contract. These errors provide more informative messages for certain operations within the World contract.

Errors

World_AlreadyInitialized

Raised when trying to initialize an already initialized World.

error World_AlreadyInitialized();

World_ResourceAlreadyExists

Raised when trying to register a resource that already exists.

error World_ResourceAlreadyExists(ResourceId resourceId, string resourceIdString);

Parameters

NameTypeDescription
resourceIdResourceIdThe ID of the resource.
resourceIdStringstringThe string representation of the resource ID.

World_ResourceNotFound

Raised when the specified resource is not found.

error World_ResourceNotFound(ResourceId resourceId, string resourceIdString);

Parameters

NameTypeDescription
resourceIdResourceIdThe ID of the resource.
resourceIdStringstringThe string representation of the resource ID.

World_AccessDenied

Raised when a user tries to access a resource they don't have permission for.

error World_AccessDenied(string resource, address caller);

Parameters

NameTypeDescription
resourcestringThe resource's identifier.
calleraddressThe address of the user trying to access the resource.

World_InvalidResourceId

Raised when an invalid resource ID is provided.

error World_InvalidResourceId(ResourceId resourceId, string resourceIdString);

Parameters

NameTypeDescription
resourceIdResourceIdThe ID of the resource.
resourceIdStringstringThe string representation of the resource ID.

World_InvalidNamespace

Raised when an namespace contains an invalid sequence of characters ("__").

error World_InvalidNamespace(bytes14 namespace);

Parameters

NameTypeDescription
namespacebytes14The invalid namespace.

World_SystemAlreadyExists

Raised when trying to register a system that already exists.

error World_SystemAlreadyExists(address system);

Parameters

NameTypeDescription
systemaddressThe address of the system.

World_FunctionSelectorAlreadyExists

Raised when trying to register a function selector that already exists.

error World_FunctionSelectorAlreadyExists(bytes4 functionSelector);

Parameters

NameTypeDescription
functionSelectorbytes4The function selector in question.

World_FunctionSelectorNotFound

Raised when the specified function selector is not found.

error World_FunctionSelectorNotFound(bytes4 functionSelector);

Parameters

NameTypeDescription
functionSelectorbytes4The function selector in question.

World_DelegationNotFound

Raised when the specified delegation is not found.

error World_DelegationNotFound(address delegator, address delegatee);

Parameters

NameTypeDescription
delegatoraddressThe address of the delegator.
delegateeaddressThe address of the delegatee.

World_UnlimitedDelegationNotAllowed

Raised when trying to create an unlimited delegation in a context where it is not allowed, e.g. when registering a namespace fallback delegation.

error World_UnlimitedDelegationNotAllowed();

World_InsufficientBalance

Raised when there's an insufficient balance for a particular operation.

error World_InsufficientBalance(uint256 balance, uint256 amount);

Parameters

NameTypeDescription
balanceuint256The current balance.
amountuint256The amount needed.

World_InterfaceNotSupported

Raised when the specified interface is not supported by the contract.

error World_InterfaceNotSupported(address contractAddress, bytes4 interfaceId);

Parameters

NameTypeDescription
contractAddressaddressThe address of the contract in question.
interfaceIdbytes4The ID of the interface.

World_InvalidResourceType

Raised when an invalid resource type is provided.

error World_InvalidResourceType(bytes2 expected, ResourceId resourceId, string resourceIdString);

Parameters

NameTypeDescription
expectedbytes2The expected resource type.
resourceIdResourceIdThe ID of the resource.
resourceIdStringstringThe string representation of the resource ID.

World_CallbackNotAllowed

Raised when the World is calling itself via an external call.

error World_CallbackNotAllowed(bytes4 functionSelector);

Parameters

NameTypeDescription
functionSelectorbytes4The function selector of the disallowed callback.

IWorldEvents

Git Source (opens in a new tab)

We bundle these events in an interface (instead of at the file-level or in their corresponding library) so they can be inherited by IWorldKernel. This ensures that all events are included in the IWorldKernel ABI for proper decoding in the frontend.

Events

HelloWorld

Emitted when the World is created.

event HelloWorld(bytes32 indexed worldVersion);

Parameters

NameTypeDescription
worldVersionbytes32The protocol version of the World.

IRegistrationSystem

Git Source (opens in a new tab)

IAccessManagementSystem

Git Source (opens in a new tab)

Functions

grantAccess

Usage Sample

function grantAccess(ResourceId resourceId, address grantee) external;

revokeAccess

Usage Sample

function revokeAccess(ResourceId resourceId, address grantee) external;

transferOwnership

function transferOwnership(ResourceId namespaceId, address newOwner) external;

renounceOwnership

function renounceOwnership(ResourceId namespaceId) external;

IBalanceTransferSystem

Git Source (opens in a new tab)

Functions

transferBalanceToNamespace

function transferBalanceToNamespace(ResourceId fromNamespaceId, ResourceId toNamespaceId, uint256 amount) external;

transferBalanceToAddress

Usage Sample

function transferBalanceToAddress(ResourceId fromNamespaceId, address toAddress, uint256 amount) external;

IBatchCallSystem

Git Source (opens in a new tab)

Functions

batchCall

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

batchCallFrom

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

IModuleInstallationSystem

Git Source (opens in a new tab)

Functions

installModule

function installModule(IModule module, bytes memory encodedArgs) external;

IStoreRegistrationSystem

Git Source (opens in a new tab)

Functions

registerTable

Usage Sample

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

registerStoreHook

function registerStoreHook(ResourceId tableId, IStoreHook hookAddress, uint8 enabledHooksBitmap) external;

unregisterStoreHook

function unregisterStoreHook(ResourceId tableId, IStoreHook hookAddress) external;

IWorldRegistrationSystem

Git Source (opens in a new tab)

Functions

registerNamespace

Usage Sample

function registerNamespace(ResourceId namespaceId) external;

registerSystemHook

function registerSystemHook(ResourceId systemId, ISystemHook hookAddress, uint8 enabledHooksBitmap) external;

unregisterSystemHook

function unregisterSystemHook(ResourceId systemId, ISystemHook hookAddress) external;

registerSystem

Usage Sample

function registerSystem(ResourceId systemId, System system, bool publicAccess) external;

registerFunctionSelector

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

registerRootFunctionSelector

Usage Sample

function registerRootFunctionSelector(
  ResourceId systemId,
  string memory worldFunctionSignature,
  string memory systemFunctionSignature
) external returns (bytes4 worldFunctionSelector);

registerDelegation

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

unregisterDelegation

function unregisterDelegation(address delegatee) external;

registerNamespaceDelegation

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

unregisterNamespaceDelegation

function unregisterNamespaceDelegation(ResourceId namespaceId) external;