Architecture

On-chain program structure, account layout, and instruction flow.

Program Instructions

InstructionAccountsAccessDescription
initialize2Admin (once)Create GuardConfig PDA
commit_intent4Any userCommit intent hash with TTL
verify_intent4Intent ownerVerify hash match, close PDA, collect fee
revoke_intent2Intent ownerCancel intent, refund rent
pause_protocol2AdminBlock commit + verify
unpause_protocol2AdminResume protocol
transfer_admin2AdminTransfer admin authority
update_config2AdminUpdate min_balance
update_fee2AdminSet verify fee (max 0.1 SOL)
withdraw_fees2AdminWithdraw accumulated fees
migrate_config2AdminRealloc config for schema upgrade

Account Layout: IntentCommit (121 bytes)

FieldOffsetSizeType
discriminator08u8[8]
user832Pubkey
app_id4032Pubkey
intent_hash7232u8[32]
committed_at1048i64
expires_at1128i64
bump1201u8

PDA seeds: [b"intent", user.key(), app_id.key()]

Account Layout: GuardConfig (82 bytes)

FieldOffsetSizeType
discriminator08u8[8]
admin832Pubkey
is_paused401bool
total_commits418u64
total_verifies498u64
min_balance578u64
verify_fee658u64
total_fees_collected738u64
bump811u8

PDA seeds: [b"config"] — singleton per program

Verification Flow

Mobile (Trusted)         Solana          Browser (Untrusted)
     |                      |                    |
     |  commit_intent       |                    |
     |--------------------->|                    |
     |                      | IntentCommit PDA   |
     |                      |  created           |
     |                      |                    |
     |                      |   verify_intent   |
     |                      |<-------------------|
     |                      |                    |
     |                      | hash match?        |
     |                      |  YES -> close PDA  |
     |                      |  NO  -> TX reverts |
     |                      |                    |

Project Structure

intentguard/
  programs/intent-guard/src/   # On-chain Rust program
    lib.rs                     # Instruction router
    state.rs                   # IntentCommit, GuardConfig
    errors.rs                  # Error codes (11 variants)
    instructions/              # Handlers
  packages/sdk/src/            # TypeScript SDK (npm)
  packages/cpi/src/            # Rust CPI crate
  extension/src/               # Chrome extension
  app/                         # React Native mobile app
  examples/                    # Integration examples
  scripts/                     # Admin tools, API server
  tests/                       # Integration + unit tests
  landing/                     # GitHub Pages site + docs

Constants

ConstantValueDescription
DEFAULT_TTL300s5 minute default expiry
MIN_TTL30sMinimum allowed TTL
MAX_TTL3600sMaximum allowed TTL (1 hour)
DEFAULT_MIN_BALANCE0.01 SOLSpam protection threshold
MAX_MIN_BALANCE1 SOLAdmin can't set higher
MAX_VERIFY_FEE0.1 SOLFee cap per verify