Sol.College

Full lesson

XiaoLee

XiaoLee: The AI Ops Layer & Copilot bridging social media to Solana. Empowering creators to onboard and reward communities via DMs. Natural language transactions powered by LLMs, PDAs, and Jupiter CPI. Turning social engagement into secure on-chain utility.

What it does

From the project README:

Expected response (`402 Payment Required`) — network/asset are nested inside `payment`:
Original
ParaDevs-Brasil/XiaoLee
SuperStack fork
Blockchains/XiaoLee @ 178f2c7
Stars
0
Last push (original)
2026-08-10
Languages
Python, TypeScript, JavaScript, HTML, CSS, Makefile
Detected stack
AnchorNext.jssolana-pyweb3.js
Categories
AI & AgentsDeFi
Licence
MIT

Architecture

295 source files. By extension: .py ×181, .tsx ×69, .ts ×34, .js ×10, .rs ×1.

Top-level directorySource files
backend185
frontend100
solana-program4
qa3
scripts2
load_tests1

On-chain programs: solana-program/xiaolee_core/programs/xiaolee_core

Dapp: devnet deploy pending

⏳ Devnet deploy pending — goes live when the devnet wallet is topped up. This fork's own dapp is not deployed yet, so there is no program address or transaction to show. It is queued in dapp-queue.txt; once devnet SOL is available it is deployed, exercised with real devnet transactions, and this section switches to the live dapp at /dapps/xiaolee/. Until then, the lesson and step-by-step guide below are complete, and you can run it locally with the commands below.

Key code, explained

Excerpts chosen automatically where the code uses the most Solana concepts, pinned to the fork's commit.

ParaDevs-Brasil/XiaoLee · solana-program/xiaolee_core/programs/xiaolee_core/src/lib.rs L37–59 @ 178f2c7 · MIT · original
    pub fn initialize_user(ctx: Context<InitializeUser>, twitter_id: String) -> Result<()> {        // Sanitização de input: twitter_id limitado a 50 chars        require!(twitter_id.len() <= 50, ErrorCode::StringTooLong);         // Protocolo não pode estar pausado para novos usuários        require!(!ctx.accounts.global_config.paused, ErrorCode::ProtocolPaused);         let user_state = &mut ctx.accounts.user_state;        user_state.twitter_id = twitter_id;        user_state.swap_count = 0;        user_state.total_volume = 0;        user_state.bump = ctx.bumps.user_state;         msg!("User {} initialized successfully!", user_state.twitter_id);        Ok(())    }     /// Registra um swap confirmado on-chain — chamado APENAS pelo admin.    /// O constraint has_one = admin garante que apenas o admin assina.    /// Best-effort: chamado pelo backend após confirmação via Helius webhook.    pub fn record_swap(ctx: Context<RecordSwap>, volume: u64) -> Result<()> {        // Protocolo deve estar ativo        require!(!ctx.accounts.global_config.paused, ErrorCode::ProtocolPaused);
  1. Line 39 require!(twitter_id.len() <= 50, ErrorCode::StringTooLong);: An explicit validation that aborts the instruction with an error.
  2. Line 48 user_state.bump = ctx.bumps.user_state;: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve.
  3. Line 50 msg!("User {} initialized successfully!", user_state.twitter_id);: Logs to the program log, which is visible in explorers and the test output.
  4. Line 55 /// O constraint has_one = admin garante que apenas o admin assina.: Checks that a stored pubkey field matches the passed account.
ParaDevs-Brasil/XiaoLee · solana-program/xiaolee_core/scripts/create_token2022.ts L1–24 @ 178f2c7 · MIT · original
import {  Connection,  Keypair,  SystemProgram,  Transaction,  clusterApiUrl,  sendAndConfirmTransaction,} from '@solana/web3.js';import {  ExtensionType,  TOKEN_2022_PROGRAM_ID,  createInitializeMintInstruction,  getMintLen,  createInitializeTransferFeeConfigInstruction,} from '@solana/spl-token';import * as fs from 'fs'; async function main() {  // Connect to devnet  const connection = new Connection(clusterApiUrl('devnet'), 'confirmed');   // Load wallet from standard location  const secretKeyString = fs.readFileSync(process.env.HOME + '/.config/solana/id.json', 'utf8');  const secretKey = Uint8Array.from(JSON.parse(secretKeyString));
  1. Line 7 sendAndConfirmTransaction,: Submits the signed transaction to the cluster.
  2. Line 11 TOKEN_2022_PROGRAM_ID,: Targets the Token-2022 program instead of the original Token Program.
ParaDevs-Brasil/XiaoLee · frontend/src/hooks/useXiaoLeeProgram.ts L133–156 @ 178f2c7 · MIT · original
          { name: 'bump', type: 'u8' },        ],      },    },  ],} as unknown as Idl; // ─── Tipos ───────────────────────────────────────────────────────────────────── export interface XiaoLeeUserState {  twitterId: string;  swapCount: number;  totalVolume: number; // em lamports (9 casas decimais para SOL, 6 para USDC)  bump: number;} // ─── Utilitários ─────────────────────────────────────────────────────────────── /** * Deriva o endereço PDA de um usuário dado seu twitter_id. * Seed: ["user", twitter_id_bytes] */export function deriveUserStatePda(twitterId: string): PublicKey {  const [pda] = PublicKey.findProgramAddressSync(
  1. Line 133 { name: 'bump', type: 'u8' },: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve.
  2. Line 156 const [pda] = PublicKey.findProgramAddressSync(: Derives a PDA from seeds and the program ID and returns the address with its canonical bump.
ParaDevs-Brasil/XiaoLee · backend/server/integrations/solana_cctp.py L205–228 @ 178f2c7 · MIT · original
    def _event_cpi_accounts(self, program_id_str: str):        """        Contas injetadas pelo macro #[event_cpi] da Anchor em cada instrução anotada:        event_authority (PDA, seeds=[b"__event_authority"]) + o próprio program_id.        VALIDADO em 03/07/2026 contra deposit_for_burn real na devnet        (tx 61gJyeUshdt3wB9KN3fMaewdikXDSGdQYzwnm99djNCRD72D5NdorRPtS2obhtYMmxxkSyqQZyXJuTUyFESz7yN3,        destino domain 26/Arc): as 18 contas batem posição a posição com burn_usdc(),        incluindo event_authority=6TCCnJ9R1m1RXFzyoH7GYH2J6NJDtZaUvfipPuLWxHNd.        """        Pubkey, *_, AccountMeta, _, _ = _import_solders()        event_authority = self._pda([_SEED_EVENT_AUTHORITY], program_id_str)        program_id = Pubkey.from_string(program_id_str)        return [            AccountMeta(pubkey=event_authority, is_signer=False, is_writable=False),            AccountMeta(pubkey=program_id, is_signer=False, is_writable=False),        ]     def derive_associated_token_address(self, owner_pubkey, mint_pubkey):        Pubkey, *_ = _import_solders()        ata_program = Pubkey.from_string(ASSOCIATED_TOKEN_PROGRAM_ID)        token_program = Pubkey.from_string(SPL_TOKEN_PROGRAM_ID)        pda, _bump = Pubkey.find_program_address(            [bytes(owner_pubkey), bytes(token_program), bytes(mint_pubkey)],            ata_program,
  1. Line 208 event_authority (PDA, seeds=[b"__event_authority"]) + o próprio program_id.: Declares the PDA seeds. Anchor re-derives the address and rejects the account if it doesn't match.
  2. Line 226 pda, _bump = Pubkey.find_program_address(: Derives a PDA from seeds and the program ID and returns the address with its canonical bump.

How to run, build and test

These commands come from the repo's own manifests (package.json scripts, Anchor.toml, Cargo, go.mod, Makefile). Check the README for prerequisites and environment variables.

DirectoryCommandRuns
solana-program/xiaolee_corenpm run lintprettier */*.js "*/**/*{.js,.ts}" --check
frontendnpm run devnext dev
frontendnpm run startnext start
frontendnpm run buildnext build
frontendnpm run testvitest run
frontendnpm run lintnext lint
solana-program/xiaolee_coreanchor buildcompile programs and generate IDLs
solana-program/xiaolee_coreanchor testlocal validator + test suite
solana-program/xiaolee_coreanchor run testyarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts
.make helpMakefile target
.make initMakefile target
.make init-checkMakefile target
.make init-backendMakefile target
.make init-frontendMakefile target
.make devMakefile target
.make dev-backendMakefile target

What you could build from it

Used in lessons