Compiling validator scripts

If you haven’t already studied Alonzo-testnet/README.md at main · input-output-hk/Alonzo-testnet · GitHub, you might find some answers there.

Regarding cabal.project, the Cardano and Plutus package dependencies are rather complex, so it is best to start with a copy of that file that is known to have compatible dependencies for generating Plutus that runs on cardano-node-1.29.0. If the additional packages that you’re using are all on Hackage, then you probably won’t need to edit cabal.project further, since the Hackage packages will resolve during cabal configure or cabal build. If the additional packages aren’t in Hackage, then you’ll need to add entries to cabal.project.

An idealized version of my typical workflow for a new Plutus project is:

  1. Run cabal init and edit the .cabal file for the project if needed.
  2. Grab cabal.project for the appropriate tag on the cardano-node repository, and then add an entry to that for cardano-node itself.
  3. Write the Haskell code.
  4. Add dependencies for any new import statements to the .cabal files. If those dependencies aren’t in Hackage, then also add them to cabal.project.
  5. Build with cabal build.
  6. Run the executable directly or use cabal run to compile and serialize the Plutus script.
  7. Use cardano-cli to use the script on testnet.
  8. Iterate steps 3-7.

I say “idealized” because I’ll typically add the dependencies before writing any code so then my IDE (VIM+HLS+hlint+…) assists. Also, I generally use haskell.nix and nix-shell to create a releases and/or a development environment. I’ll also use off-chain Haskell instead of cardano-cli.

3 Likes