Carbon Player Profile Decoder
Rust decoder for the Star Atlas Player Profile program on Solana, generated using Carbon CLI.
Program Information
- Program ID:
pprofELXjL5Kck7Jn5hCpwAL82DpTkSYBENzahVtbc9 - Network: Solana Mainnet
- Description: Star Atlas Player Profile program for managing player identities, permissions, and role-based access control within the Star Atlas ecosystem.
Features
- Decodes all Player Profile account types
- Full instruction parsing support
- Integration with Carbon indexing framework
- Permission bitflags support for ergonomic permission checking
- Helper methods for key expiration and authorization checks
Usage
Add this crate to your Cargo.toml:
[]
= "0.12.0"
Decoding Accounts
use ;
use AccountDecoder;
let decoder = PlayerProfileDecoder;
let decoded_account = decoder.decode_account;
if let Some = decoded_account
Decoding Instructions
The decoder supports parsing all Player Profile instructions with full account resolution:
use ;
use InstructionDecoder;
let decoder = PlayerProfileDecoder;
let decoded_ix = decoder.decode_instruction;
if let Some = decoded_ix
Note: The AddKeys and CreateProfile instructions include both:
- Instruction data (
keys_to_add,key_permissions) - Contains permission scopes and metadata - Account lists (
keys_to_add_accounts,init_keys_accounts) - Contains the actual pubkeys of the keys being added
Working with Permissions
The decoder includes ergonomic permission handling with bitflags:
use ;
// Check if a key has specific permissions
let key: ProfileKey = /* ... */;
if key.is_auth
if key.has_permission
// Check if a key has expired
let current_time = /* current unix timestamp */;
if key.is_expired
// Get permission flags
let flags = key.permissions_flags;
if flags.contains
Account Types
This decoder supports all Player Profile account types:
Profile- Player profile with keys and metadataPlayerName- Player name registrationRole- Role definition with permissionsProfileRoleMembership- Membership relationship between profiles and roles
Account Fields (RemainingData)
All account types include dynamically-sized fields deserialized from RemainingData:
Profile
profile_keys: Vec<ProfileKey>- List of all keys associated with this profile- Each key includes: public key, scope, expiration time, and permissions
- Maximum of 65,535 keys (u16 length prefix)
PlayerName
name: Vec<u8>- UTF-8 encoded player name bytes- Variable length, stored as raw bytes without length prefix
- Example:
String::from_utf8_lossy(&player_name.name)
Role
members: Vec<RoleMembership>- List of all members in this role- Each membership includes: member key and status (Active/Inactive)
- Maximum of 256 members (u32 length prefix, enforced by MAX_MEMBERSHIPS)
ProfileRoleMembership
memberships: Vec<RoleMembership>- List of all roles this profile belongs to- Each membership includes: role key and status (Active/Inactive)
- Maximum of 256 memberships (u32 length prefix, enforced by MAX_MEMBERSHIPS)
Permission Flags
The ProfilePermissions bitflags type includes:
AUTH- Auth key with full profile controlADD_KEYS- Can add non-auth keysREMOVE_KEYS- Can remove non-auth keysCHANGE_NAME- Can change player nameCREATE_ROLE- Can create new rolesREMOVE_ROLE- Can remove rolesSET_AUTHORIZER- Can set role authorizerJOIN_ROLE- Can add profile to a roleLEAVE_ROLE- Can remove profile from a roleTOGGLE_ACCEPTING_NEW_MEMBERS- Can toggle accepting new membersADD_MEMBER- Can add members to rolesREMOVE_MEMBER- Can remove members from rolesDRAIN_SOL_VAULT- Can withdraw from SOL vault (scope-agnostic)
Documentation
Full documentation is available at docs.rs.
Repository
See the main repository for build instructions and contribution guidelines.
License
Licensed under the Apache-2.0 license.