Architecture
On-chain program structure, account layout, and instruction flow.
Program Instructions
| Instruction | Accounts | Access | Description |
initialize | 2 | Admin (once) | Create GuardConfig PDA |
commit_intent | 4 | Any user | Commit intent hash with TTL |
verify_intent | 4 | Intent owner | Verify hash match, close PDA, collect fee |
revoke_intent | 2 | Intent owner | Cancel intent, refund rent |
pause_protocol | 2 | Admin | Block commit + verify |
unpause_protocol | 2 | Admin | Resume protocol |
transfer_admin | 2 | Admin | Transfer admin authority |
update_config | 2 | Admin | Update min_balance |
update_fee | 2 | Admin | Set verify fee (max 0.1 SOL) |
withdraw_fees | 2 | Admin | Withdraw accumulated fees |
migrate_config | 2 | Admin | Realloc config for schema upgrade |
Account Layout: IntentCommit (121 bytes)
| Field | Offset | Size | Type |
| discriminator | 0 | 8 | u8[8] |
| user | 8 | 32 | Pubkey |
| app_id | 40 | 32 | Pubkey |
| intent_hash | 72 | 32 | u8[32] |
| committed_at | 104 | 8 | i64 |
| expires_at | 112 | 8 | i64 |
| bump | 120 | 1 | u8 |
PDA seeds: [b"intent", user.key(), app_id.key()]
Account Layout: GuardConfig (82 bytes)
| Field | Offset | Size | Type |
| discriminator | 0 | 8 | u8[8] |
| admin | 8 | 32 | Pubkey |
| is_paused | 40 | 1 | bool |
| total_commits | 41 | 8 | u64 |
| total_verifies | 49 | 8 | u64 |
| min_balance | 57 | 8 | u64 |
| verify_fee | 65 | 8 | u64 |
| total_fees_collected | 73 | 8 | u64 |
| bump | 81 | 1 | u8 |
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
| Constant | Value | Description |
| DEFAULT_TTL | 300s | 5 minute default expiry |
| MIN_TTL | 30s | Minimum allowed TTL |
| MAX_TTL | 3600s | Maximum allowed TTL (1 hour) |
| DEFAULT_MIN_BALANCE | 0.01 SOL | Spam protection threshold |
| MAX_MIN_BALANCE | 1 SOL | Admin can't set higher |
| MAX_VERIFY_FEE | 0.1 SOL | Fee cap per verify |