1

I am following Plutus-pioneer-program to learn smart contract development in Cardano. I have tried the onchain and offchain code, compiled and tested in Plutus playground and also in emulator trace. Now i want to know how can i use these smart contracts and deploy on blockchain. Some of the methods which i know are

  1. By Cardano-cli, but I think it will be having a lot of .sh commands which is not easy to code every time.
  2. By PAB, I tried to run PAB along with cardano-node, chain-index, plutus-pab-examples. But it's quite hectic to wait for days for their syncing. Also I was not able to proceed PAB as the process got killed due to out of memory.
  3. By Alonzo testnet, I am also trying alonzo testnet tutorial, but its full of dependency errors. Also I don't know

Now I need to clear up my mind by having some clear steps of the smart contract compilation, testing, deployment and interaction. How can we do these all with the most recommended and practical way.

Also I need the tutorial/guidance to do deployment of smart contract on Cardano testnet, other than these or with the suitable and most used way.

I have explored many more stuff on Cardano, but I think everything has got quite messed up due to lack of proper guidance on that. Please guide we with a recommendable way and a proper flow of how to do all these stuff.

1 Answer 1

3

There are two steps you need to follow in order to create a dApp on Cardano.

  1. Create the script itself - the on-chain code
  2. Create the transaction which will make use of that script, ideally make it abstract enough so that any user can interact with you app - this is called the off-chain code

OnChain code

For step 1, your end goal is to have your script compiled into Plutus-core, whose hex representation you can see here, for example.

In order to produce this code, you will probably want some kind of high-level language. You don't write assembly every time you want to create an API, instead you usually write it in C or some language that can be compiled to Assembly.

Currently we have three languages, two of which are still in early stages of development (Aiken and Eopsin):

  1. PlutusTx
  2. Helios
  3. Aiken
  4. Eopsin

If you are doing the Plutus Pioneers Program, you probably learned PlutusTx. The advantage of PlutusTx is that it was developed by IOG so it will probably always have the most up-to-date code. In the sense that if we have a new feature added to Cardano (like reference inputs were recently), they will most likely be the first to have it implemented.

In the other hand, as you might have found out already, it is a language extremely difficult to understand, develop and test and I still occasionally scream in my sleep when I remember nix-shell and cabal.

Worst of all, it was not very well-designed in the sense that all other languages mentioned above have significant performance and script size improvements (50% above).

So, honestly, I would suggest you to rewrite whatever script you made using PlutusTx in another language (they are quite easy to understand), because it will keep you from turning mad in the long term.

I have used Helios before and it was very easy to use. You can take this repository as a guide to write and compile the script. I think Aiken will be better in the future, but I have not tried it yet and it is very likely to have bugs since it's earlier in its development phase than Helios.

OffChain code

Finally, for your off-chain code, you will need to create two transactions. The first is the one which sends some amount of tokens to the script with a specific datum and the second is the one which will try to spend that script, providing some redeemer.

Every dApp in Cardano needs to revolve around those two types of transaction. Some more complex ones, however, might mix both types by spending a script and sending some tokens back to that script with a new datum.

The theory behind it is out of scope, but there are currently multiple libraries which you can use to build this off-chain code. Some of which are the following:

  1. Lucid
  2. PyCardano
  3. Mesh

Each one is well documented and have their own guides and examples, my advice you would be to use Lucid. PyCardano is great and I have personally used it even more often than lucid, but it builds the transactions in the back-end so you will still need to create a client interface to sign it and submit it. It can be good, however, if you simply want to see your script in the chain and want to test it quickly and easily.

6
  • Really? Can i make the smart contract using Helios. Like I did certain RnD on cardano smart contracts, and the only thing i get to know that cardano only supports haskell and plutus, which is truly a language giving you headache. So point is, can i really make any smart contracts like staking etc with helios??
    – duaa azhar
    Commented Jan 24, 2023 at 13:25
  • @duaaazhar Yes and there are examples of it already deployed on-chain, I made some my self
    – Mateus
    Commented Jan 24, 2023 at 15:10
  • @duaaazhar But take a look at Aiken, it looks really easy to use, just maybe not ready for production yet aiken-lang.org/getting-started/hello-world
    – Mateus
    Commented Jan 24, 2023 at 17:55
  • Yah Aiken is seeming bit easy to understand but i also have to go for production environment, so i think i should take start with a mature language like helios right?
    – duaa azhar
    Commented Jan 25, 2023 at 11:08
  • I’m a huge Helios fan, so much so I wrote a book on it amazon.com/Cardano-Smart-Contracts-Helios-Lawrence-ebook/dp/… I’ve also released an open source repo of examples from the book as well. github.com/lley154/helios-examples I also share similar nightmares of nix-shell/cabal hell….thank God I don’t have to do that anymore.
    – lley154
    Commented Feb 9, 2023 at 0:59

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.