πAttaching Modules
Token Creation
// Create a character that can equip items
operation create_character(name: text) {
val account = ft4.auth.authenticate();
// Create token with character module
val spec = yours.token_specification(
project = yours.project_info("Game Example", chain_context.blockchain_rid),
collection = "Characters",
name,
modules = ["characters"] // Specify modules at creation
);
val token = yours.create_token(spec);
characters.attach(token, name); // Initialize character data
}
// Create an equippable item
operation create_item(name: text, power: integer) {
val account = ft4.auth.authenticate();
// Create token with item module
val spec = yours.token_specification(
project = yours.project_info("Game Example", chain_context.blockchain_rid),
collection = "Items",
name,
modules = ["items"] // Specify modules at creation
);
val token = yours.create_token(spec);
items.attach(token, power); // Initialize item data
}Adding Modules Later
Best Practices
Attachment
Declaring Module
Last updated