Skip to content

Latest commit

 

History

History
190 lines (142 loc) · 5.26 KB

File metadata and controls

190 lines (142 loc) · 5.26 KB

Production Blockchain Transaction Issue

Current Status

Development Mode: Real blockchain transactions work perfectly ❌ Production Build: Lucid-cardano library fails to load

The Problem

Lucid-cardano has dependencies (WASM modules, Node.js polyfills) that don't bundle well with Vite for production builds. This is a known limitation of using Lucid in browser-based applications.

Error Message

Failed to import lucid-cardano: TypeError: Failed to resolve module specifier 'lucid-cardano'

Solutions

Option 1: Use Development Mode (Current Recommendation)

For real blockchain transactions, run the app in development mode:

# Clone the repository
git clone https://github.com/Campverse/TrustlessTask.git
cd TrustlessTask

# Install dependencies
npm install

# Run in development mode
npm run dev

Then access at http://localhost:5173

Why this works:

  • Vite's dev server handles ES modules correctly
  • WASM modules load properly
  • All Cardano wallet integrations function
  • Real blockchain transactions execute successfully

Option 2: Alternative Cardano Libraries

Consider migrating to production-friendly alternatives:

  1. @meshsdk/core - Better production build support

    npm install @meshsdk/core @meshsdk/react
  2. cardano-serialization-lib - Direct use without Lucid wrapper

    npm install @emurgo/cardano-serialization-lib-browser
  3. Backend Transaction Building - Move transaction logic to Node.js backend

    • Frontend only handles wallet connection
    • Backend builds and submits transactions
    • More secure and production-ready

Option 3: Demo Mode (Current Vercel Deployment)

The Vercel deployment runs in demo mode:

  • ✅ Full UI/UX works
  • ✅ Wallet detection works
  • ✅ All pages responsive and functional
  • ❌ Real transactions disabled
  • ℹ️ Shows informative error messages

Recommended Path Forward

Short Term (Current)

  • Use development mode for testing real transactions
  • Vercel deployment showcases UI/UX
  • Document the limitation clearly

Long Term (Future Enhancement)

  1. Migrate to MeshSDK

    • Better Vite/production support
    • Active maintenance
    • Similar API to Lucid
  2. Backend Transaction Service

    • More secure (private keys never in browser)
    • Better error handling
    • Production-ready architecture
  3. Hybrid Approach

    • Frontend: Wallet connection + signing
    • Backend: Transaction building + submission
    • Best of both worlds

Current Workarounds Attempted

❌ Vite Configuration Changes

  • Tried various rollup options
  • Attempted manual chunking
  • Added polyfills
  • Result: Build still fails

❌ Dependency Aliasing

  • Aliased stream-browserify
  • Added readable-stream
  • Result: Circular dependency issues

❌ External Dependencies

  • Marked lucid as external
  • Result: Module not found in browser

Development vs Production Comparison

Feature Development Production (Vercel)
UI/UX ✅ Works ✅ Works
Wallet Detection ✅ Works ✅ Works
Wallet Connection ✅ Works ✅ Works
Transaction Building ✅ Works ❌ Fails
Transaction Submission ✅ Works ❌ Fails
Mobile Responsive ✅ Works ✅ Works

How to Test Real Transactions

  1. Clone and run locally:

    git clone https://github.com/Campverse/TrustlessTask.git
    cd TrustlessTask
    npm install
    npm run dev
  2. Install a Cardano wallet:

  3. Get testnet ADA:

  4. Test transactions:

    • Create a project
    • Mark milestone complete (sends 1 ADA)
    • Approve and release funds (sends milestone amount)

Technical Details

Why Lucid Fails in Production

  1. WASM Modules: Lucid uses WebAssembly that Vite struggles to bundle
  2. Node.js Dependencies: Requires fs, path, crypto polyfills
  3. Dynamic Imports: Module resolution fails in bundled code
  4. ESM/CommonJS Mix: Dependency tree has mixed module formats

Build Error Chain

lucid-cardano
  ├── @emurgo/cardano-serialization-lib-browser (WASM)
  ├── node-fetch (Node.js APIs)
  ├── fetch-blob
  │   └── stream-browserify/web (doesn't exist)
  └── Various other Node.js dependencies

Conclusion

For Production Use:

  • Migrate to MeshSDK or backend transaction service
  • Current Vercel deployment is UI/UX showcase only

For Development/Testing:

  • Use npm run dev for full functionality
  • All blockchain features work perfectly

Current Status:

  • ✅ Mobile responsive design complete
  • ✅ All UI components working
  • ✅ Wallet integration functional
  • ⚠️ Real transactions require development mode
  • 📋 Production blockchain solution pending migration

Resources

Contact

For questions about implementing production blockchain transactions, please open an issue on GitHub.