# Can plutus contract store large data onchain alike to Ethereum's solidity?

**URL:** <https://forum.cardano.org/t/can-plutus-contract-store-large-data-onchain-alike-to-ethereums-solidity/97241>\
**Category:** Smart Contracts\
**Tags:** plutus\
**Created:** [9 March 2022 03:51 UTC](https://forum.cardano.org/t/can-plutus-contract-store-large-data-onchain-alike-to-ethereums-solidity/97241 "2022-03-09T03:51:33Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![brooze](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.cardano.org/brooze/32/27929_2.png) [@brooze](https://forum.cardano.org/u/brooze)\
**Post date:** [9 March 2022 03:51 UTC](https://forum.cardano.org/t/can-plutus-contract-store-large-data-onchain-alike-to-ethereums-solidity/97241/1 "2022-03-09T03:51:34Z")

</div>

We would like to implement plutus contract to peform the same function as our existing solidity contract , that is to store large merkle tree onchain. It seem we want to use Cardano as a database, that’s what we plan to do.

I’am doing research on the official site, have no conclusion yet.

Any advice or suggestion are welcome.

Thanks.

---

<div class="post-metadata">

**Author:** ![micah](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.cardano.org/micah/32/52044_2.png) [@micah](https://forum.cardano.org/u/micah)\
**Post date:** [9 March 2022 04:27 UTC](https://forum.cardano.org/t/can-plutus-contract-store-large-data-onchain-alike-to-ethereums-solidity/97241/2 "2022-03-09T04:27:35Z")

</div>

Cardano has small size limits for block data. What specifically are you trying to do while storing that data on-chain?

---

<div class="post-metadata">

**Author:** ![brooze](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.cardano.org/brooze/32/27929_2.png) [@brooze](https://forum.cardano.org/u/brooze)\
**Post date:** [9 March 2022 04:32 UTC](https://forum.cardano.org/t/can-plutus-contract-store-large-data-onchain-alike-to-ethereums-solidity/97241/4 "2022-03-09T04:32:47Z")

</div>

My goal is to provide an serivce for other contract to call.

This service has the ability to store, update merkle tree as time move. The consumer of this serice receive the verify path and target hash by way of off-chain channel, then use the path to invoke Cardano contract(that is my service) to verify that input hash is correct.

Currently the requirement is that verification should be done on-chain, not off-chain.

---

<div class="post-metadata">

**Author:** ![micah](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.cardano.org/micah/32/52044_2.png) [@micah](https://forum.cardano.org/u/micah)\
**Post date:** [9 March 2022 04:37 UTC](https://forum.cardano.org/t/can-plutus-contract-store-large-data-onchain-alike-to-ethereums-solidity/97241/5 "2022-03-09T04:37:49Z")

</div>

You’d do verification off-chain using on-chain data. Probably only store the top hash and then have the rest of the tree on IPFS. It’s hard to understand from your description though.

---

<div class="post-metadata">

**Author:** ![brooze](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.cardano.org/brooze/32/27929_2.png) [@brooze](https://forum.cardano.org/u/brooze)\
**Post date:** [9 March 2022 05:00 UTC](https://forum.cardano.org/t/can-plutus-contract-store-large-data-onchain-alike-to-ethereums-solidity/97241/6 "2022-03-09T05:00:55Z")

</div>

Thanks for your reply. Sorry for poor description.

I know we can do verification off-chain, but this not the consumer side want.

It function is similar to sidechain. From the viewpoint of consumer, they expect to invoke my contract from their contract, so they can do something if pass verification. That is why I should do verify on-chain.

From the docs, I knew Cardano contract compose of on-chain and off-chain parts. From technical view, maybe my consumer can implement functionality inside off-chain code, not on-chain code, then I can choose to implement verification off-chain.

---

<div class="post-metadata">

**Author:** ![micah](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.cardano.org/micah/32/52044_2.png) [@micah](https://forum.cardano.org/u/micah)\
**Post date:** [9 March 2022 05:23 UTC](https://forum.cardano.org/t/can-plutus-contract-store-large-data-onchain-alike-to-ethereums-solidity/97241/7 "2022-03-09T05:23:55Z")

</div>

It sounds like what your trying to create is a general service contract for verifying changes to a piece of data. What’s unclear is the structure of this data and whether it all needs to be on-chain, or only parts of it. This is an issue since you can’t really provide a general solution for many different requirements with one contract.

---

<div class="post-metadata">

**Author:** ![DinoDude](https://avatars.discourse-cdn.com/v4/letter/d/f4b2a3/32.png) [@DinoDude](https://forum.cardano.org/u/DinoDude)\
**Post date:** [9 March 2022 07:18 UTC](https://forum.cardano.org/t/can-plutus-contract-store-large-data-onchain-alike-to-ethereums-solidity/97241/8 "2022-03-09T07:18:53Z")

</div>

Updating a merkle-patricia (MP) trie is **NOT** conducive to on-chain data or smart contracts in Cardano. Period.

Whatever SC you are porting from Ethereum needs to be re-imagined or re-factored entirely. Generally trie data structures are excellent for indexing known data. The MP “enhancement” as implemented by ETH storage layer adds verification via hashes and other integrity checks etc. These kinds of complex and error-prone algorithmic extensions placing the onus of dynamic validation onto the smart contract implementation is presumably why Plutus and Cardano smart contracts where designed to be deterministic and functional.

Back to the drawing board my friend, our preconceived notions are just that!

---

<div class="post-metadata">

**Author:** ![brooze](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.cardano.org/brooze/32/27929_2.png) [@brooze](https://forum.cardano.org/u/brooze)\
**Post date:** [9 March 2022 08:17 UTC](https://forum.cardano.org/t/can-plutus-contract-store-large-data-onchain-alike-to-ethereums-solidity/97241/9 "2022-03-09T08:17:27Z")

</div>

Thanks.  
I admit that we should not put the method of thinking from ETH to Cardano. But the module/system I’m trying to implement do have relation to transactions on ETH-like chain,and need to hook up the Cardano and this ETH-like chain. Just like side-chain or layer two of ETH. That is why there is the need to store merkle tree on Cardano, maybe on-chain or off-chain.  
If save large data on-chain is impossible, I had to found a work-around solution.  
I’m learning Plutus now, but need to set a direction on how to design and implement this system ahead.

---

<div class="post-metadata">

**Author:** ![brooze](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.cardano.org/brooze/32/27929_2.png) [@brooze](https://forum.cardano.org/u/brooze)\
**Post date:** [9 March 2022 08:28 UTC](https://forum.cardano.org/t/can-plutus-contract-store-large-data-onchain-alike-to-ethereums-solidity/97241/10 "2022-03-09T08:28:11Z")

</div>

Maybe my requirement is due to our intuition that saving data on-chain will make the user trust our smart contract.

---

<div class="post-metadata">

**Author:** ![DinoDude](https://avatars.discourse-cdn.com/v4/letter/d/f4b2a3/32.png) [@DinoDude](https://forum.cardano.org/u/DinoDude)\
**Post date:** [10 March 2022 16:52 UTC](https://forum.cardano.org/t/can-plutus-contract-store-large-data-onchain-alike-to-ethereums-solidity/97241/11 "2022-03-10T16:52:28Z")

</div>

I would store the trie off-chain and use the hash in phase 1 validation. The idea with a deterministic system is validate first and only then execute. There should be no branches of control flow that can do this or maybe that depending on something mutable during runtime. The general idea with Plutus is if everything checked out and looks good in the off-chain portion then it should be guaranteed to succeed with a provable outcome on-chain.

---

<div class="post-metadata">

**Author:** ![Neo\_Spank](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.cardano.org/neo_spank/32/35544_2.png) [@Neo\_Spank](https://forum.cardano.org/u/Neo_Spank)\
**Post date:** [10 March 2022 21:27 UTC](https://forum.cardano.org/t/can-plutus-contract-store-large-data-onchain-alike-to-ethereums-solidity/97241/12 "2022-03-10T21:27:34Z")

</div>

Hello @brooze

> [@brooze](#):
>
> need to hook up the Cardano and this ETH-like chain.

There is a company that provides a EVM like sidechains that can run Solidity as well (if that’s what you want) on Cardano already. Did you try reaching out to:

> **[Milkomeda • Cross-blockchain DApp creation made simple](https://www.milkomeda.com/)**
>
> Milkomeda brings the most used smart-contract programming language across blockchains. Develop once, deploy everywhere.

---

<div class="post-metadata">

**Author:** ![Jack7E](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.cardano.org/jack7e/32/44610_2.png) [@Jack7E](https://forum.cardano.org/u/Jack7E)\
**Post date:** [26 June 2022 21:56 UTC](https://forum.cardano.org/t/can-plutus-contract-store-large-data-onchain-alike-to-ethereums-solidity/97241/13 "2022-06-26T21:56:02Z")

</div>

My CIP for extended 721 metadata might prove to be somewhat relevant. The goal here is to store data onchain using references. This can be quite powerful and allow for certain data structures, combined with contract use could be quite interesting.

> [@CIP extended 721](https://forum.cardano.org/t/cip-extended-721/99646):
>
> CIP extended 721 Hello, I have been working on a new extended standard for the informational CIP 25. I would love to get some feedback! Abstract This standard proposes a fully on chain method to store and access metadata via the use of references or pointers to data. This would allow users of 721 to increase or reduce the amount of data stored on chain. Motivation Large token mints that duplicated data could be dramatically reduced in size by pointing to one transaction payload that conta…

---

<div class="post-metadata">

**Author:** ![fermat](https://avatars.discourse-cdn.com/v4/letter/f/848f3c/32.png) [@fermat](https://forum.cardano.org/u/fermat)\
**Post date:** [22 August 2022 10:09 UTC](https://forum.cardano.org/t/can-plutus-contract-store-large-data-onchain-alike-to-ethereums-solidity/97241/14 "2022-08-22T10:09:48Z")

</div>

This is perfectly possible, see this post [(1)](https://cardano.stackexchange.com/questions/8918/committing-a-database-to-the-ledger-without-storing-it-on-the-ledger). The Merkle tree lib is already made as well (see post).

I think people misunderstood your question, you are not storing the data onchain, you are committing to it onchain via a hash (a low storage impact solution).
