I'm developing a Cardano application using nextjs setup with MeshJS template project. I'm using MeshJS in the frontend for its better React hooks etc. Although it's possible to use it fully, for the backend (Next.js API routes), I'm trying to use Lucid, as it is suggested by Aiken, which I use for the contract development. Also note that I'm using YACI with Kupos, and I'm trying to make lucid use Kupmios Provider to connect to YACI. However, I encounter the following error:
Error: TypeError: Cannot read properties of undefined (reading 'costModels')
at client.addEventListener.once (file:///mnt/BACKUP/programming-free-time/blockchain/cardano/cofeemonks/frontend/node_modules/lucid-cardano/esm/src/provider/kupmios.js:34:40)
Development Stack:
Next.js for both frontend and API routes
MeshJS for frontend Cardano interactions (used for its better React support)
Lucid-cardano library for backend Cardano interactions (in Next.js API routes)
YACI (Yet Another Cardano Index) as the local Cardano node and indexer for development
Kupmios provider in Lucid to connect to YACI
Blockfrost provider planned for production environment
Code Structure:
Project structure based on the MeshJS Next.js template
Frontend: Using MeshJS for Cardano interactions
Backend (API routes): Attempting to use Lucid for Cardano operations
Using a LucidService class to manage Lucid initialization in API routes
Attempting to use different providers (Kupmios for development, Blockfrost for production)
Environment:
Local machine with YACI running ( Archlinux )
Is there a known compatibility issue between Lucid, YACI, and Next.js API routes?
Are there any specific considerations for using WebSocket-based providers (like Ogmios/Kupmios) in a serverless environment like Next.js API routes?
How can I properly debug the Kupmios provider initialization in this setup?
Are there any recommended best practices for using Lucid in Next.js API routes while using MeshJS in the frontend?
Are there potential issues in using different libraries (MeshJS and Lucid) for frontend and backend Cardano interactions in the same project?
Any insights or suggestions on resolving this error and setting up a robust Cardano development environment with this specific setup (MeshJS for frontend, Lucid for backend in Next.js) would be greatly appreciated. Additionally, any advice on best practices for this dual-library approach would be very helpful.
I'm developing a Cardano application using nextjs setup with MeshJS template project. I'm using MeshJS in the frontend for its better React hooks etc. Although it's possible to use it fully, for the backend (Next.js API routes), I'm trying to use Lucid, as it is suggested by Aiken, which I use for the contract development. Also note that I'm using YACI with Kupos, and I'm trying to make lucid use Kupmios Provider to connect to YACI. However, I encounter the following error:
Development Stack:
Code Structure:
Environment:
Local machine with YACI running ( Archlinux )