The World Program is the entrypoint for creating world instances, entities, attaching components, and executing systems within a unified framework.

Client Development

Ongoing development efforts are focused on delivering multiple client SDKs and integrations.

The World Program, a standard Anchor program, expose its Interface Definition Language (IDL) published on-chain for seamless interaction.

TypeScript SDK Installation

To install the Bolt SDK, execute the following command:

npm install @magicblock-labs/bolt-sdk

Initiating a project with bolt init automatically generates a simple usage example of the bolt-sdk.

Creating a New World Instance

Create a new world instance as demonstrated below:

const initializeNewWorld = await InitializeNewWorld({
  payer: provider.wallet.publicKey,
  connection: provider.connection,
});
const signature = await provider.sendAndConfirm(initializeNewWorld.transaction);
const worldPda = initializeNewWorld.worldPda; // we can use this later

Adding a New Entity

To add a new entity:

const addEntity = await AddEntity({
  payer: provider.wallet.publicKey,
  world: worldPda,
  connection: provider.connection,
});
const signature = await provider.sendAndConfirm(addEntity.transaction);
const entityPda = addEntity.entityPda; // we can use this later

Attaching Components to an Entity

For attaching components:

const initializeComponent = await InitializeComponent({
  payer: provider.wallet.publicKey,
  entity: entityPda,
  componentId: positionComponent.programId,
});
const signature = await provider.sendAndConfirm(initializeComponent.transaction);
const componentPda = initializeComponent.componentPda; // We can use this to fetch the state

Applying Systems

To apply a system:

const applySystem = await ApplySystem({
  authority: provider.wallet.publicKey,
  systemId: systemMovement.programId,
  entities: [{
    entity: entityPda,
    components: [{ componentId: positionComponent.programId }],
  }]
});
const signature = await provider.sendAndConfirm(applySystem.transaction);