Account Classification
SphereNet implements persistent account classification through a dedicated Account Type Program that acts as a verifier in the Badge Program system. This program allows accounts to be permanently classified with specific types that can be easily verified on-chain.
Account Type Badge Account
The Account Type Program creates Associated Badge Accounts (ABAs) to store type classifications for wallets:
For example, a Badge Account would contain:
BadgeAccount {
verifier: Pubkey::from_str("Type1234...").unwrap(),
wallet: Pubkey::from_str("Alice1234...").unwrap(),
is_verified: true,
metadata: vec![
("type".to_string(), "<accounttype>".to_string()),
("sub_account".to_string(), "<true|false>".to_string())
]
}
Key features:
- Uses Badge Program's ABA structure for easy lookup
- No expiration slot (classifications are permanent)
- Classification is immutable once set
- Verifier is a PDA of the Account Type Program
Metadata Format
The metadata vector contains key-value pairs for classification:
[
("type", "<account_type>"), // Primary classification (bank, broker, etc)
("sub_account", "true|false") // Whether this is a sub-account
]
Classification Process
When an account wishes to be classified:
- Account owner initiates classification by calling the Account Type Program
- Owner specifies their desired account type
- Program creates an ABA with:
- Itself as the verifier
- The owner's specified type in metadata
- Once set, the classification is permanent and immutable
Other programs can verify an account's type by:
- Deriving the ABA address using the account and Account Type Program
- Reading the type from metadata
- Verifying the ABA's verifier is the Account Type Program
Looking Up Account Types
To find an account's type, derive and check its Badge Account:
ABA_pubkey = Pubkey::find_program_address(
&[
Pubkey::from_str("Alice1234...").unwrap().to_bytes(),
Pubkey::from_str(BADGE_PROGRAM_ID).unwrap().to_bytes(),
Pubkey::from_str("Type1234...").unwrap().to_bytes(),
],
ABA_PROGRAM_ID,
);
// Get the Badge Account data
let badge_account = rpc_client.get_account(&ABA_pubkey)?;
let badge_data = BadgeAccount::unpack(&badge_account.data)?;
// Get the account type from metadata
let account_type = badge_data.metadata.iter()
.find(|(key, _)| key == "type")
.map(|(_, value)| value)
.unwrap();
Account Types
Available account types:
- Bank
- Broker
- Exchange
- Corporate
- Institution
- Customer
- Market-Maker
- Custodian
- Payment-Provider
- Treasury
- Protocol
This list represents common financial account types, but is not exhaustive. The Account Type Program allows any account type string to be specified, enabling users to create new classifications as needed. The only constraint is that once set, an account's type cannot be changed.
Each classification can have additional subtypes and metadata specified in the badge account.