Skip to content

ATTRIBUTE

Overview

ATTRIBUTE is the user attribute storage library. It manages key-value attributes for users identified by Soul ID, supporting both generic attributes and address/Bao aliases.

  • Inherits: DYSNOMIA
  • License: Sharia
  • Solidity: ^0.8.21

What This Means For Players

Plain English Summary: ATTRIBUTE is your player profile storage - it saves your username, aliases, and other settings. When you set your username or create nicknames for addresses, ATTRIBUTE stores them permanently linked to your Soul ID.

Real-World Analogy: Think of ATTRIBUTE like the settings menu in a video game. You can set your display name, create shortcuts for frequently-used addresses (like saving contacts in your phone), and the game remembers all your preferences.

How It Affects Your Gameplay: - Username storage - Your display name is stored here - Address aliases - Give nicknames to addresses like "My Wallet" or "Bob's LAU" - Soul-linked - All data is tied to your Soul ID, not your wallet address - Length limits - Usernames max 64 chars, aliases max 32 chars

State Variables

Variable Type Visibility Description
Void VOID public Reference to session manager
_attributes mapping(string => bool) private Valid attribute names
_userAttributes mapping(uint64 => mapping(string => string)) private User attribute values
_userGrades mapping(uint64 => mapping(address => string)) private Address aliases per user

Read Functions

Get

function Get(uint64 Soul, string memory name) public view returns (string memory)
- Parameters: - Soul: User's Soul ID - name: Attribute name - Returns: Attribute value - Description: Retrieves a user's attribute value - In Plain English: Read one of a player's saved settings. Pass their Soul ID and the setting name (like "Username") to get the value.

Alias (address)

function Alias(uint64 Soul, address name) public view returns (string memory)
- Parameters: - Soul: User's Soul ID - name: Address to look up - Returns: Alias for the address - Description: Gets a user's alias for an address - In Plain English: Look up the nickname you've given to a blockchain address. Like checking what name you saved a contact under in your phone.

Alias (Bao)

function Alias(uint64 Soul, Bao memory Theta) public view returns (string memory)
- Parameters: - Soul: User's Soul ID - Theta: Bao to look up - Returns: Alias for the Bao's Phi address - Description: Gets a user's alias for a Bao - In Plain English: Look up the nickname you've given to a Bao's address. Convenient way to find your label for a specific game entity.

Write Functions

addAttribute

function addAttribute(string memory name, uint8 maxLength) public onlyOwners
- Access: onlyOwners - Parameters: - name (string): Name of the attribute to register (e.g., "Username", "Bio") - maxLength (uint8): Maximum byte length for values (0-255) - Description: Registers a new attribute type that can be set on users. - Logic Flow: 1. Store attribute with max length: _attributes[name] = maxLength 2. Mint to cap: _mintToCap() - Side Effects: Updates _attributes mapping; mints tokens - In Plain English: Create a new attribute type that players can set. Only admins can add new attribute categories like "Username" or "Bio". The maxLength limits how long values can be.

removeAttribute

function removeAttribute(string memory name) public onlyOwners
- Access: onlyOwners - Parameters: - name (string): Attribute name to deactivate - Description: Deactivates an attribute by setting its maxLength to 0. - Logic Flow: 1. Set max length to zero: _attributes[name] = 0 2. Mint to cap: _mintToCap() - Side Effects: Updates _attributes mapping; mints tokens - In Plain English: Delete an attribute type from the system. After removal (maxLength = 0), players can no longer set values for that attribute category.

Set

function Set(uint64 Soul, string memory name, string memory value) public onlyOwners
- Access: onlyOwners - Parameters: - Soul (uint64): User's Soul ID - name (string): Attribute name (must be registered) - value (string): Value to store (must not exceed attribute's maxLength) - Description: Sets a user's attribute value with length validation. - Logic Flow: 1. Get max length: maxLen = _attributes[name] 2. Validate: if(bytes(value).length > maxLen) revert MaximumLength 3. Store: _userAttributes[Soul][name] = value - Side Effects: Updates _userAttributes mapping - In Plain English: Save a setting for a player. Used to store usernames and other player preferences. Value length is validated against the attribute's defined maximum.

Alias (set address)

function Alias(uint64 Soul, address name, string memory value) public onlyOwners
- Access: onlyOwners - Parameters: - Soul (uint64): User's Soul ID - name (address): Address to create alias for - value (string): Alias string (max 32 bytes) - Description: Sets a user's alias for an address. - Logic Flow: 1. Validate: if(bytes(value).length > 32) revert MaximumLength 2. Store: _userGrades[Soul][name] = value - Side Effects: Updates _userGrades mapping - In Plain English: Save a nickname for a blockchain address. Like saving a contact in your phone - instead of remembering "0x1234...", you can call it "Bob's Wallet". Max 32 bytes.

Alias (set Bao)

function Alias(uint64 Soul, Bao memory entity, string memory value) public onlyOwners
- Access: onlyOwners - Parameters: - Soul (uint64): User's Soul ID - entity (Bao): Bao whose Phi address to alias - value (string): Alias string (max 32 bytes) - Description: Sets a user's alias for a Bao's Phi address. - Logic Flow: 1. Extract address: key = entity.Phi 2. Validate: if(bytes(value).length > 32) revert MaximumLength 3. Store: _userGrades[Soul][key] = value - Side Effects: Updates _userGrades mapping - In Plain English: Save a nickname for a Bao's address. The alias is stored under the Bao's Phi address, making it easy to label game entities you interact with.

Errors

Error Parameters Description
MaximumLength max, value Value exceeds max length
AttributeNotFound name Attribute name not registered

Contract Interactions

Depends On

Registered In

  • VOID library registry as "libattribute"

Used By

  • VOID - User attribute operations

Constructor

constructor(VoidAddress) {
    Void = VOID(VoidAddress);
    addOwner(VoidAddress);
    Void.AddLibrary("libattribute", address(this));

    // Register default attributes
    addAttribute("Username");
    addAttribute("TestAttribute");
}

Special Mechanisms

Attribute Validation

Only registered attribute names can be used:

if(!_attributes[name]) revert AttributeNotFound(name);

Length Limits

  • Attributes: 64 character maximum
  • Aliases: 32 character maximum
if(bytes(value).length > 64) revert MaximumLength(64, value);
if(bytes(value).length > 32) revert MaximumLength(32, value);

Default Attributes

Constructor registers: - "Username" - User's display name - "TestAttribute" - For testing

Soul-Indexed Storage

All data is indexed by Soul ID (uint64), not by address:

_userAttributes[Soul][name] = value;
_userGrades[Soul][address] = alias;

Usage Pattern

// Via VOID (user context)
void.SetAttribute("Username", "Alice");
string memory name = void.GetAttribute("Username");
void.Alias(someAddress, "Bob's Wallet");

// Direct (admin context)
attribute.addAttribute("CustomField");
attribute.Set(soul, "CustomField", "CustomValue");

Storage Structure

_attributes:
├── "Username" → true
├── "TestAttribute" → true
└── "CustomField" → true

_userAttributes:
├── Soul123:
│   ├── "Username" → "Alice"
│   └── "TestAttribute" → "hello"
└── Soul456:
    └── "Username" → "Bob"

_userGrades:
├── Soul123:
│   └── 0x1234... → "My Wallet"
└── Soul456:
    └── 0xABCD... → "Treasury"

Contract Verification

Property Value
Keccak256 Hash 0xf999af65b81710496e2a8c6cfba3d2794539b54bd0fe4481b4b56b5e5a44efa1
Source URL https://raw.githubusercontent.com/busytoby/atropa_pulsechain/main/solidity/dysnomia/lib/attribute.sol
Hash Generated 2026-02-08T00:29:08Z