> ## Documentation Index
> Fetch the complete documentation index at: https://docs.musterbox.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Godot

> Integrate the MusterBox SDK with Godot 4.2+ via the GDExtension.

The Godot adapter (`musterbox-godot`, addon `musterbox`) is a GDExtension
implemented in Rust. Min Godot version **4.2**.

## Install

Copy the packaged addon into your project and enable it in **Project >
Project Settings > Plugins**:

```bash theme={"dark"}
# extract dist/godot/musterbox-godot-1.0.0.zip into your Godot project
```

The extension builds for desktop (macOS, Linux, Windows), Android, and iOS.

## Initialize

```gdscript theme={"dark"}
var config = MusterBoxConfig.new()
config.game_id = "my-arena-game"
config.game_key = "gk_..."
config.environment = "sandbox"
config.offline_buffering = true

var sdk = MusterBoxSdk.new()
sdk.initialize(config)
sdk.start()
```

## Authenticate and open a session

```gdscript theme={"dark"}
sdk.authenticate("player@example.com", "secret")
var ctx = sdk.open_session("sandbox", 1042)
# ctx.session_id, ctx.token, ctx.expires_at, ctx.context...
```

## Events and updates

```gdscript theme={"dark"}
sdk.submit_event("match.start", { "mode": "arena" })
var updates = sdk.poll_wallet_updates(64)
for u in updates:
    print(u)
```

## Threaded purchase bridge

The Godot adapter drives PIN mint/verify from `std::thread` workers. The
`PurchaseClient` blocking variants are expressly designed to be safe from
engine worker threads:

```gdscript theme={"dark"}
var preflight = sdk.purchase_mint_pin_session("item-arena-bundle", 9.99, "purchase-1")
if preflight.kind == "Ready":
    var session = preflight.session
    var outcome = sdk.purchase_verify_pin(session.session_id, session.session_token, pin, verify)
```

Blocking variants must not be called from inside another async runtime
context (e.g. a Tokio worker in a Rust plugin).

## Support matrix

| Godot | SDK   | Targets                                     |
| ----- | ----- | ------------------------------------------- |
| 4.2+  | 1.0.0 | Desktop (macOS/Linux/Windows), Android, iOS |

Next: [Unreal Engine](/engines/unreal).
