메인 콘텐츠로 건너뛰기
World Program은 통합 프레임워크 안에서 world instance 생성, entities 추가, components 부착, systems 실행을 담당하는 진입점입니다.

클라이언트 개발

현재는 여러 클라이언트 SDK와 통합 기능을 제공하기 위한 개발이 진행 중입니다. World Program은 표준 Anchor program이며, 원활한 상호작용을 위해 Interface Definition Language(IDL)를 온체인에 게시합니다.

TypeScript SDK 설치

Bolt SDK를 설치하려면 다음 명령을 실행하세요.
npm install @magicblock-labs/bolt-sdk
bolt init으로 프로젝트를 시작하면 bolt-sdk 사용 예제가 자동으로 생성됩니다.

새 World Instance 만들기

다음과 같이 새 world instance를 생성합니다.
const initializeNewWorld = await InitializeNewWorld({
  payer: provider.wallet.publicKey,
  connection: provider.connection,
});
const signature = await provider.sendAndConfirm(initializeNewWorld.transaction);
const worldPda = initializeNewWorld.worldPda; // 나중에 사용할 수 있습니다

새 Entity 추가하기

새 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; // 나중에 사용할 수 있습니다

Entity에 Components 부착하기

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; // 상태 조회에 사용할 수 있습니다

Systems 적용하기

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);