Skip to content

Frontend User Flows

This document describes the main user flows in the Iyup frontend application.

Document Registration Flow

Step-by-Step Process

  1. Navigate to Upload Page
    • User clicks "Register Document" or navigates to /upload
    • Wallet must be connected
  2. Select Token
    • User selects or enters RWA token address
    • System verifies token ownership
  3. Upload Document
    • User selects document file (PDF, image, etc.)
    • File validated (size, type)
  4. Choose Encryption Mode
    • Regular Mode: Document hash stored on-chain
    • ZK Mode: Zero-knowledge commitment stored on-chain
    • Optional: Enable threshold encryption (Mysten Seal)
  5. Client-Side Encryption
    • Document encrypted using Web Crypto API
    • Key derived from token address + owner address + secret salt
    • Encryption: AES-256-GCM
  6. Upload to Walrus
    • Encrypted document uploaded to Walrus network
    • Returns blob ID and object ID
  7. Compute Hash/Commitment
    • Regular Mode: SHA-256 hash computed
    • ZK Mode: Poseidon commitment generated
  8. Register On-Chain
    • Transaction built with all metadata
    • User signs transaction
    • Document registered on Sui blockchain
  9. Confirmation
    • Transaction confirmed
    • Document metadata available in indexer
    • Access key stored securely

Marketplace Trading Flow

List Token for Sale

  1. Navigate to Marketplace
    • User goes to /marketplace
    • Views active listings
  2. Create Listing
    • User selects token to list
    • Sets price in SUI
    • Reviews gas estimate
  3. Submit Listing
    • Transaction built (moves token to escrow)
    • User signs transaction
    • Token locked in marketplace
  4. Listing Active
    • Listing appears in marketplace
    • Other users can see and purchase
    • Seller can update price or cancel

Purchase Token

  1. Browse Listings
    • User browses active listings
    • Views listing details (token, price, seller)
  2. Select Listing
    • User clicks on listing
    • Reviews token and document details
  3. Purchase
    • User clicks "Buy" button
    • System checks SUI balance
    • Transaction built (SUI for token swap)
  4. Execute Purchase
    • User signs transaction
    • Token transferred to buyer
    • SUI transferred to seller (minus fees)
    • Listing removed
  5. Access Transfer
    • New owner automatically has access
    • Can retrieve access key from "My Tokens"
    • Document decryption available

Document Verification Flow

Regular Vault Documents

  1. Navigate to Verify Page
    • User goes to /verify
    • Or uses "My Tokens" page
  2. Enter Token Address
    • User enters RWA token address
    • System fetches document metadata
  3. Retrieve Access Key
    • System verifies token ownership
    • Calls get_access_key() on-chain
    • Returns encrypted access key
  4. Download Document
    • System retrieves blob ID from on-chain registry
    • Downloads encrypted document from Walrus
  5. Decrypt Document
    • Document decrypted using access key
    • Decryption happens client-side
  6. Verify Hash
    • Computes hash of decrypted document
    • Compares with on-chain hash
    • Verifies integrity
  7. View/Download
    • Verified document displayed
    • User can download verified document

ZK Vault Documents

  1. Navigate to Verify Page
    • User enters token address
    • System checks if ZK commitment exists
  2. Retrieve Commitment
    • System fetches ZK commitment from chain
    • Retrieves witness data (if available)
  3. Generate Proof (if needed)

    • System generates ZK proof off-chain
    • Uses witness data and commitment
  4. Verify Proof On-Chain
    • Transaction built to verify proof
    • User signs transaction
    • Proof verified using Groth16 verifier
  5. Access Document
    • After proof verification
    • Retrieve access key
    • Decrypt and verify document

Access Key Management Flow

Retrieve Access Key

  1. Navigate to My Tokens
    • User goes to /my-tokens
    • System fetches owned tokens
  2. Select Token
    • User selects token from list
    • Or enters token address
  3. Ownership Verification
    • Frontend checks token ownership
    • Verifies user owns the token
  4. Retrieve Key
    • Calls get_access_key() on-chain
    • Returns encrypted access key
    • Key decrypted if needed
  5. Use Key
    • Key can be used for document access
    • Key copied to clipboard or used directly
    • Used in verification flow

After Token Purchase

  1. Token Transferred
    • Purchase transaction confirms
    • Token ownership changes
  2. Access Available
    • New owner can immediately access
    • No additional steps needed
    • Access key retrieval works immediately

ZK Commitment Flow

Register ZK Commitment

  1. Select ZK Mode
    • User selects "ZK Mode" during upload
    • Privacy-preserving option
  2. Generate Commitment
    • System generates Poseidon commitment
    • Commitment = Hash(documentHash || ownerAddress || nonce)
  3. Store Witness Data
    • Witness data stored off-chain (indexer)
    • Needed for future proof generation
  4. Register Commitment
    • Transaction built with commitment
    • Commitment registered on-chain
    • No document hash stored

Verify ZK Commitment

  1. View Commitments
    • User goes to /zk-commitments
    • Views registered commitments
  2. Generate Proof
    • System retrieves witness data
    • Generates Groth16 proof off-chain
  3. Verify On-Chain
    • Transaction built to verify proof
    • User signs transaction
    • Proof verified using Sui's native verifier
  4. Confirmation
    • Proof verification result
    • Commitment verified without revealing content

Error Handling

Common Error Scenarios

  1. Wallet Not Connected
    • Prompt user to connect wallet
    • Block actions requiring wallet
  2. Insufficient Balance
    • Check SUI balance before transactions
    • Show clear error messages
  3. Ownership Verification Failed
    • Verify token ownership before access
    • Show appropriate error messages
  4. Transaction Failed
    • Parse error messages
    • Provide helpful feedback
    • Allow retry
  5. Document Not Found
    • Check if document exists
    • Provide clear feedback
    • Guide user to register document

State Management

Transaction States

  • Pending: Transaction submitted, awaiting confirmation
  • Confirmed: Transaction confirmed on-chain
  • Failed: Transaction failed, error displayed

Document States

  • Uploading: Document uploading to Walrus
  • Registering: Registering on-chain
  • Registered: Document registered and available
  • Verifying: Verifying document integrity

Listing States

  • Active: Listing is live and available
  • Sold: Token purchased, listing closed
  • Cancelled: Listing cancelled by seller

Next Steps