5

Let's say I have a Plutus contract written up. How do I actually submit it to the blockchain and start interacting with it?

2 Answers 2

7

The plutus contract that you have written is in template haskell. Now to convert this to something that can be used on chain one needs to compiled it to plutus core.

From an educational point of view I'll explain how this is done with a concrete example. Take for example the lobster smart contract's used in naming the lobster [1]. Note that this project folder structure contains at least the following 3 files,

  1. A .cabal file in ./
  2. A main.hs residing in ./app/
  3. A smart contract residing in ./src/Cardano/PlutusLobster/

Now what are those files? The .cabal file is a configuration file that tells the compiler how to build the general haskell program at hand. If you look in it you will see all the dependencies listed for building something to plutus core. Also in the end of this file there are three executable defines, that of the 3 yet to build contracts. Now in this file is also a reference to the smart contact in the ./src/... path. Lastly the .cabal file also references the main.hs files for each of those 3 to build contract. If we look into that main.hs file it is some general format that tells the compiler exactly how to compile the plutus script to plutus core (and the serialization of that).

So now you can test it out! Git clone this repo and type cabal run all to build all 3 contracts or cabal run "a name of a executable" as defined at the end of the .cabal file. This will result in 3 contracts in the /scripts/ directory. Note that building this has to be done with ghc version 8.10.4.

Hopes this helps.

1
  • Makes sense! Appreciate the detailed response. I totally missed the lobster challenge when it came out, I'll give it a go right now. Commented Oct 25, 2021 at 22:25
6

As Fermat said, you can follow the lobster example.

Another option is the Exercise 4 of Alonzo-testnet. Exercise 4 - Solution

There you can find:

  1. Compile hs file
  2. Build script address
  3. Build transactions to interact with the validator script
  4. Sign transactions
  5. Submit transactions
1
  • Got it, thank you very much! Commented Oct 25, 2021 at 22:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.