<blockquote>
<p>I guess [the off-chain code] is in the blockchain too[?]</p>
</blockquote>
<p>No. Actually. They mean it when they call it &quot;off-chain&quot; :).</p>
<p><strong>Background:</strong></p>
<p>Generally speaking, you want to minimize the amount of code you put on-chain because that code is expensive. For Plutus smart contracts, the role of on-chain code is simply to look at a transaction and say &quot;yes&quot; or &quot;no&quot;.</p>
<p>There are two uses for the off-chain code:</p>
<ol>
<li>Compile and submit the on-chain scripts</li>
<li>Create transactions that will be validated by the on-chain scripts</li>
</ol>
<p>But as I mention in this <a href="https://cardano.stackexchange.com/a/914/1130">other question's answer</a>, there is nothing keeping someone from writing their own off-chain code to interact with the on-chain script. This is important for a smart-contract writer to understand when thinking about the security of the on-chain validation.</p>
<p><strong>Answer:</strong></p>
<blockquote>
<p>Where is stored off-chain code?</p>
</blockquote>
<p>There is nothing binding the on-chain code to a singular off-chain code. So there is no correct answer.</p>
<blockquote>
<p>How does the user wallet get it?</p>
</blockquote>
<p>From what I understand, there will be options. It could be stored in a repo by the SC writer where you could download it, or perhaps hosted on a website where your wallet can access it (similar to how Metamask works on Uniswap or other Ethereum sites), or you could write it yourself in an attempt to exploit the contract.</p>
<p>As a SC creator, it will be your responsibility to make your off-chain code available to consumers so they can interact with your contract in your intended way.</p>

CC BY-SA 4.0
2021-08-01T11:34:13.593Z
Also, I imagine a central repository similar to what we have for tokens metadata will be ran by the Cardano Foundation.
Marek Mahut - StakeNuts
CC BY-SA 4.0
2021-08-01T15:11:49.737Z
This. I imagine at some point there could be a dApp browser of sorts. As we’ve seen with the Plutus Playground, the endpoints interface can be used auto-generate a UI. This could help lower the barrier to entry for dApp writers so they don’t need to build a UI themselves. If you can get your SC onto the registry then anyone can find it and use it.
Mitchell Turner
CC BY-SA 4.0
2021-08-01T03:05:05.480Z
2021-08-01T08:06:02.233Z
2021-08-01T08:06:02.233Z
Mitchell Turner
<p>As I understand, a smart contract in Cardano contains on-chain code and off-chain code.</p>
<ul>
<li>On-chain code is executed by cardano nodes in order to validate transaction.</li>
<li>Off-chain code builds a transaction in the user wallet then submit it to the blockchain.</li>
</ul>
<p>On-chain code is stored in the blockchain, but what about off-chain code if this is executed on user wallet. Where is this code stored?</p>
<p>I guess is in the blockchain too, but how does the user wallet get it?</p>

<smart-contract>
Where is stored off-chain code?
# Where is stored off-chain code?

(Asked by: username_0 on 2021-08-01)

As I understand, a smart contract in Cardano contains on-chain code and off-chain code.

* On-chain code is executed by cardano nodes in order to validate transaction.
* Off-chain code builds a transaction in the user wallet then submit it to the blockchain.

On-chain code is stored in the blockchain, but what about off-chain code if this is executed on user wallet. Where is this code stored?

I guess is in the blockchain too, but how does the user wallet get it?

**Tags:** smart-contract

---

## 1 answers

### Answer by username_1 on 2021-08-01. Score: 12 | Accepted answer

> I guess [the off-chain code] is in the blockchain too[?]

No. Actually. They mean it when they call it "off-chain" :).

**Background:**

Generally speaking, you want to minimize the amount of code you put on-chain because that code is expensive. For Plutus smart contracts, the role of on-chain code is simply to look at a transaction and say "yes" or "no".

There are two uses for the off-chain code:

1. Compile and submit the on-chain scripts
2. Create transactions that will be validated by the on-chain scripts

But as I mention in this [other question's answer](https://cardano.stackexchange.com/a/914/1130), there is nothing keeping someone from writing their own off-chain code to interact with the on-chain script. This is important for a smart-contract writer to understand when thinking about the security of the on-chain validation.

**Answer:**

> Where is stored off-chain code?

There is nothing binding the on-chain code to a singular off-chain code. So there is no correct answer.

> How does the user wallet get it?

From what I understand, there will be options. It could be stored in a repo by the SC writer where you could download it, or perhaps hosted on a website where your wallet can access it (similar to how Metamask works on Uniswap or other Ethereum sites), or you could write it yourself in an attempt to exploit the contract.

As a SC creator, it will be your responsibility to make your off-chain code available to consumers so they can interact with your contract in your intended way.

> **Comments:**
> **username_2**: Also, I imagine a central repository similar to what we have for tokens metadata will be ran by the Cardano Foundation.  
> **username_1**: This. I imagine at some point there could be a dApp browser of sorts. As we’ve seen with the Plutus Playground, the endpoints interface can be used auto-generate a UI. This could help lower the barrier to entry for dApp writers so they don’t need to build a UI themselves. If you can get your SC onto the registry then anyone can find it and use it.  

---

