spacebudz / lucid

Lucid is a library, which allows you to create Cardano transactions and off-chain code for your Plutus contracts in JavaScript, Deno and Node.js.
https://lucid.spacebudz.io
MIT License
341 stars 142 forks source link

Help with local development #251

Closed kozer closed 4 hours ago

kozer commented 5 months ago

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:

Code Structure:

Environment:

Local machine with YACI running ( Archlinux )

  1. Is there a known compatibility issue between Lucid, YACI, and Next.js API routes?
  2. Are there any specific considerations for using WebSocket-based providers (like Ogmios/Kupmios) in a serverless environment like Next.js API routes?
  3. How can I properly debug the Kupmios provider initialization in this setup?
  4. 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?
  5. 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.​​​​​​​​​​​​​​​​
Vortecsmaster commented 4 months ago

You might want to check out Lucid Evolution from Anastasia Labs