x/brahma Module
The x/brahma module is Bitplanet's core attribution and reward distribution system. It tracks AI contributions through a multi-dimensional tensor matrix and automatically distributes inflation rewards to creators, Application operators, and contributors.
Overview
The module implements two primary functions:
Contribution Attribution: Records who contributed what to each AI via Request for Core (RfC) messages
Reward Distribution: Automatically distributes inflation rewards every block based on AI market capitalization
Key Features:
Multi-dimensional contribution tracking (6 types: TRAIN, REFER, CREATE, PROMPT, REVENUE, MARKET_CAP)
Market cap-weighted reward distribution
Three-way reward split: Creator (50%), Application (30%), Contributors (20%)
Governance-controlled parameters (12 total)
Claimable reward system for deferred distribution
Core Concepts
Contribution Attribution System
Bitplanet tracks contributions through a two-phase system:
Phase 1: Authorization (Core Grant Application)
Requester submits governance proposal to obtain core issuance permission
Community votes on proposal
If approved, requester receives core allocation quota
Phase 2: Attribution (Request for Core)
Approved requester submits contribution tensors
System validates tensors and deducts from quota
Contributions recorded immutably at block height
Cores minted via EVM contract
Complete Transaction Flow
The following diagram shows the complete lifecycle of Core tokens from governance approval to user claims:
This flow encompasses:
Governance proposal and voting for Core Grant Applications
Request for Core submission with contribution matrix
Smart contract interactions via GemCoreNFT
Core token minting and Gem NFT creation
Inflation rewards distribution and claiming mechanisms
AI Tensor Matrix
The tensor matrix is a 2D structure tracking contributions:
Example: AI Tensor for "genie-ai" at Block 1000
cosmos1abc...
100
50
1
25
cosmos1xyz...
200
0
0
10
cosmos1def...
75
100
0
50
Each cell represents the quantity of a specific contribution type by a contributor.
Data Structures
AITensor
Records contribution state for an AI at a specific block height:
Key Properties:
Immutable once stored (historical record)
Multiple RfCs in same block are merged by summing contribution values
Array indices match ContributionTypes parameter order
Tensor merging ensures atomic updates when multiple requesters submit in same block
AI Entity
Metadata for registered AIs:
Core Grant Application
Permission to issue cores:
Lifecycle:
Submitted via governance proposal
Expires after
CoreGrantApplicationExpiryHeightblocksCan be increased by submitting additional proposals
Can be removed via
MsgRemoveCoreGrantApplication
Contribution Types
Governance-managed list defining contribution categories:
Default Types:
TRAIN - Training data or model improvements
REFER - Referrals and community growth
CREATE - AI creation (required, cannot be deactivated)
PROMPT - Prompt engineering and testing
REVENUE - Revenue generation contributions
MARKET_CAP - Market capitalization increase
Critical Constraints:
Append-only: New types can only be added at the end
Immutable order: Existing types cannot be reordered
Immutable names: Type names cannot be changed
CREATE required: Must always remain active
These constraints prevent corruption of historical contribution data stored as position-indexed arrays.
Message Types
MsgRequestForCore (RfC)
Submits contribution data and mints cores:
Requirements:
Requester must have approved CGA with sufficient allocation
CGA must not be expired
Factory contract must be configured
All contribution types must be active
Application address must match requester (authorization check)
Processing Flow:
Validate CGA exists and is not expired
Validate tensors and filter invalid AI references
Calculate total cores needed with overflow protection
Check sufficient allocation remaining
Deduct from requester's allocation
Create new AIs if needed (first contribution must include CREATE)
Merge with existing tensors at current height (concurrent RfCs are combined)
Store updated tensors
Mint cores via EVM contract in batches of 100 addresses to prevent gas limits
MsgCoreGrantApplication
Creates or updates core grant allocations:
Features:
Authority-only (governance module)
Increases existing allocation if CGA already exists
Resets expiry timer on update
Validates against
MaxCoreGrantAllocationparameter
MsgRemoveCoreGrantApplication
Administratively removes core grant:
MsgClaimRewards
Claims accumulated rewards:
Transfers claimable balance from brahma module to user account.
Reward Distribution
The x/brahma module implements an automatic reward distribution system that runs every block via the BeginBlock hook.
High-Level Process:
Siphon percentage = 50% of inflation from distribution module (remaining 50% continues through standard staking distribution). This distribution ratio is adjustable via governance.
Query AI market cap metrics from EVM contracts (30-90 day rolling average). Currently uses gem supply; future implementation will use
(W1 × gem_supply) + (W2 × gem_market_cap)with governance-adjustable weights.Distribute proportionally: Creator (50%), Application (30%), Contributors (20%)
Accumulate rewards in claimable balances
Remaining 50% Distribution: The tokens remaining in the distribution module after siphoning flow through standard BitSDK mechanisms:
Community tax (~5%) → Community pool for ecosystem development
Staking rewards (~95%) → Validators earn commission, delegators earn majority proportional to stake
Key Features:
Market cap-weighted distribution across AIs
Bounded processing to prevent blockchain halting
Two-step allocation and claiming for safety
Historical tensor processing for contributor rewards
For detailed technical implementation including algorithms, data structures, security considerations, and parameter configuration, see Inflation Mechanism.
State Storage
Storage Prefixes
The AIIDOrdered and AIIDOrderedCount prefixes enable efficient iteration over AIs in the order they were created, which is crucial for reward distribution performance.
Key Encoding
AITensor keys use length-prefix encoding for collision resistance:
Example:
Benefits:
Prevents collisions between different AI IDs
Enables efficient range queries
Deterministic ordering across validators
Module Parameters
max_core_grant_allocation
100
Max cores per CGA
core_grant_application_expiry_height
1000
Blocks before CGA expires
contribution_types
[TRAIN, REFER, CREATE, PROMPT, REVENUE, MARKET_CAP]
Contribution type definitions
creator_split
0.5 (50%)
Creator reward share
application_split
0.3 (30%)
Application reward share
contributor_split
0.2 (20%)
Contributor reward share
siphon_percentage
0.5 (50%)
% of inflation to siphon
evm_gas_limit
25M
EVM call gas limit
evm_gas_cap
25M
EVM call gas cap
max_ais_for_rewards
500
Max AIs eligible for rewards
max_ai_block_heights
1000
Max historical blocks per AI
max_tensor_rows_per_block
1000
Max tensor rows per block
Validation Rules:
Split percentages must sum to 1.0 (100%)
All percentages must be between 0 and 1
Processing limits capped at 10,000
At least one contribution type must be active
CREATE contribution type is mandatory
All parameters are governance-controlled and can be updated via proposals.
Query Endpoints
Attribution Queries:
AITensorByBlockHeight- Get tensor for AI at specific heightContributionByWalletAddress- Get contributor's specific contributionsGetAllBlockHeightsByAIID- List all heights with tensors for AI
Grant Queries:
QueryCoreGrantApplication- Get CGA status by requesterQueryCore- Get Core token contract addressesQueryAITokens- Get Gem token addresses for AI
Reward Queries:
QueryClaimableRewards- Get pending rewards for addressQueryClaimStatistics- Get aggregate statistics
Parameter Queries:
Params- Get all module parameters
Security Features
Overflow Protection:
Safe math operations throughout (math.Int, sdk.Dec)
Overflow checks before allocation updates
Bounded processing prevents infinite loops
Authorization:
Governance-only controls for sensitive operations
Application-only authorization for RfC submissions
Mandatory audit trails (reason fields)
Data Integrity:
Append-only contribution types
Length-prefixed keys prevent collisions
Tensor merging for concurrent submissions
Immutable historical records
Performance:
Bounded iteration (max AIs, max heights, max rows)
Batch core minting (100 addresses per call)
Fixed-size rolling averages (30 entries)
AI insertion order tracking for efficient queries
Integration with EVM
The module interacts with EVM contracts for:
Core Minting:
Calls
mintCoremethod on GemCoreNFT factory contractBatch processes up to 100 addresses per transaction
Uses module account as caller
Market Cap Queries:
Queries Gem ERC1155 total supply
Uses precompile addresses for contract interaction
Stores results in 30-90 day rolling average
Last updated