immortal-bnb/BUN-COMPATIBILITY-FIX.md
2025-11-21 05:05:57 +03:00

2.2 KiB

๐Ÿ”ง Bun/ethers v6 Compatibility Issue - Solution

โŒ Problem

Bun has a compatibility issue with ethers v6's bigint handling in the @noble/curves library. This causes:

error: Expected valid bigint: 0 < bigint < curve.n

This happens when creating wallets with new ethers.Wallet(privateKey).

โœ… Solution: Use Node.js

The application works perfectly with Node.js. Use the Node.js startup script:

cd /Users/arhansubasi/immortal-bnb-1
./start-all-node.sh

๐Ÿ“‹ Quick Start (Node.js)

1. Install tsx (TypeScript runner for Node.js)

npm install -g tsx
# or
bun add -g tsx

2. Run with Node.js

cd /Users/arhansubasi/immortal-bnb-1
./start-all-node.sh

๐Ÿ”„ Alternative: Manual Start with Node.js

If the script doesn't work, start manually:

Terminal 1: Backend

cd /Users/arhansubasi/immortal-bnb-1
npx tsx src/index.ts

Terminal 2: Frontend

cd /Users/arhansubasi/immortal-bnb-1/frontend
bun run dev
# or
npm run dev

๐ŸŽฏ What's Fixed

โœ… Frontend package.json: start now uses next dev (development mode)
โœ… Startup scripts: Both Bun and Node.js versions available
โœ… Greenfield SDK: Made optional to avoid blocking startup
โœ… Wallet initialization: Better error handling

๐Ÿ“Š Expected Output

When running successfully, you'll see:

==================================================
๐ŸŽ‰ All Services Started Successfully!
==================================================

๐Ÿ“Š Access Points:
   Frontend:  http://localhost:3000
   Backend:   http://localhost:3001
   WebSocket: ws://localhost:3001/ws
   Health:    http://localhost:3001/health

๐Ÿ› If Still Having Issues

  1. Check Node.js version: node --version (should be 18+)
  2. Install dependencies: npm install in root and npm install in frontend
  3. Check .env: Make sure WALLET_PRIVATE_KEY is set
  4. Check ports: Make sure 3000 and 3001 are free

๐Ÿ“ Notes

  • Bun works for frontend (Next.js)
  • Node.js required for backend (ethers v6 compatibility)
  • The Node.js script handles both automatically
  • All services integrate the same way regardless of runtime