Smart Character

A Smart Character is the on-chain representation of an in-game character. It serves as the player's identity on-chain and the owner of all assemblies they create.

Overview

When a player creates a character in-game, a corresponding Character object is created on-chain with the same character ID. The character is associated with a tribe and mapped to the player's wallet address.

Character as Capability Holder

The character object acts as a keychain — it holds the OwnerCap for every object the player owns (network nodes, gates, storage units, etc.). See Ownership Model for details on the borrow-use-return pattern.

Creation

Characters are created by the game server (admin) with a deterministic object ID derived from the in-game character ID.

Access Control

Only the wallet address stored in character_address can borrow OwnerCaps from the character. This is enforced in the borrow_owner_cap function:

public fun borrow_owner_cap<T: key>(
    character: &mut Character,
    owner_cap_ticket: Receiving<OwnerCap<T>>,
    ctx: &TxContext,
): (OwnerCap<T>, ReturnOwnerCapReceipt) {
    assert!(character.character_address == ctx.sender(), ESenderCannotAccessCharacter);
    // ...
}

Reference:

Last updated