<p>As Fermat said, you can follow the lobster example.</p>
<p>Another option is the Exercise 4 of Alonzo-testnet.
<a href="https://github.com/input-output-hk/Alonzo-testnet/blob/main/Alonzo-solutions/exercise4/Exercise4-solution.md" rel="noreferrer">Exercise 4 - Solution</a></p>
<p>There you can find:</p>
<ol>
<li>Compile hs file</li>
<li>Build script address</li>
<li>Build transactions to interact with the validator script</li>
<li>Sign transactions</li>
<li>Submit transactions</li>
</ol>

CC BY-SA 4.0
2021-10-25T22:24:39.843Z
Got it, thank you very much!
Blake Brown
CC BY-SA 4.0
2021-10-25T15:26:10.893Z
2021-10-25T15:26:10.893Z
georgeos
<p>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.</p>
<p>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 [<a href="https://github.com/input-output-hk/lobster-challenge" rel="nofollow noreferrer">1</a>]. Note that this project folder structure contains at least the following 3 files,</p>
<ol>
<li>A <code>.cabal</code> file in <code>./</code></li>
<li>A main.hs residing in <code>./app/</code></li>
<li>A smart contract residing in <code>./src/Cardano/PlutusLobster/</code></li>
</ol>
<p>Now what are those files? The <code>.cabal</code> 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 <code>./src/...</code> path. Lastly the <code>.cabal</code> file also references the <code>main.hs</code> files for each of those 3 to build contract. If we look into that <code>main.hs</code> 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).</p>
<p>So now you can test it out! Git clone this repo and type <code>cabal run all</code> to build all 3 contracts or <code>cabal run &quot;a name of a executable&quot;</code> 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.</p>
<p>Hopes this helps.</p>

CC BY-SA 4.0
2021-10-25T22:25:54.543Z
Makes sense! Appreciate the detailed response. I totally missed the lobster challenge when it came out, I'll give it a go right now.
Blake Brown
CC BY-SA 4.0
2021-10-25T13:30:02.083Z
2021-10-27T11:43:52.010Z
2021-10-27T11:43:52.010Z
Fermat
<p>Let's say I have a Plutus contract written up. How do I actually submit it to the blockchain and start interacting with it?</p>

<plutus><smart-contract><blockchain>
How to publish a smart contract on the blockchain?
# How to publish a smart contract on the blockchain?

(Asked by: username_0 on 2021-10-25)

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

**Tags:** plutus, smart-contract, blockchain

---

## 2 answers

### Answer by username_2 on 2021-10-25. Score: 7 | Accepted answer

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](https://github.com/input-output-hk/lobster-challenge)]. 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.

> **Comments:**
> **username_0**: Makes sense! Appreciate the detailed response. I totally missed the lobster challenge when it came out, I'll give it a go right now.  

---

### Answer by username_1 on 2021-10-25. Score: 6

As Fermat said, you can follow the lobster example.

Another option is the Exercise 4 of Alonzo-testnet.
[Exercise 4 - Solution](https://github.com/input-output-hk/Alonzo-testnet/blob/main/Alonzo-solutions/exercise4/Exercise4-solution.md)

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

> **Comments:**
> **username_0**: Got it, thank you very much!  

---

