I am new in ethereum blockchain technologies. I have some question that

  1. Is possible to use ethereum blockchain to store data (Like MySQL)..???
  2. If yes... (for first question) have any documentation available regarding this topic..???
  3. I already learned the solidity language is a contract based language. Is have any way to get api(Like Rest api) for front end app devoloping...???

Thanks in advance....


yes you can use Smart contracts to store data, but they are not an alternative to classic DBs.

Keep in mind that EVERY time you update the state of a contract (i.e. storing data inside that contract) you are going to pay Gas because the Ethereum protocol works in that way. In that case storing many records as a DB does is very very costly and may not worth it.

I do this thinking when I want to write something on a PUBLIC Blockchain:

  • Is this data sensitive? Because data on PUBLIC Blockchain is indeed public;
  • Does this data need the features of Persistency and Immutability that the Blockchain protocol offers?

If the data I need don't require these property then a Blockchain is not worth it.

Then think about: Why do I need a PRIVATE Blockchain? Why isn't a private DB ok? What does a PRIVATE blockchain offer more? Because if in your private Blockchain there are only 1-2 miners then it cannot hold the properties of Immutability and Persistency because the network is too small.

Finally, here a Javascript framework to interact with Ethereum: Truffle. https://truffleframework.com/ It has a lot of tools to compile/migrate/test contracts. The framework is Javascript and thus you can add javascript utilities for your REST service. There are plenty of tutorials concerning Truffle.

Hope it helps

  • Hey.. Thanks for answering. Can you provide any documentation about to create api service for deployed contract... Jan 17 '19 at 12:06
  • Explore Truffle's page, there are plenty of tutorials how to interact with deployed contracts, i.e. using web3 library or, even better, the TruffleContract library that is a web3 wrapper.
    – 0Alic
    Jan 17 '19 at 14:55
  1. Using ethereum as a database is putting a database in a database. Is it possible? Yes. Is it optimal? No.

Just like bitcoin you can put extra data in every transaction. The nice part about Ethereum's state, you can change the value of an account. This means that you can have a smart contract that keeps information such as a tuple and then make a call to that contract to change that tuple.

One change Ethereum has made over bitcoin is that they recognize storing data and will charge you accordingly to the amount of data you put in. This means putting something as simple as a string to a smart contract can be very costly and sometimes hard to push to the network.

So if you choose to use ethereum please know you are accepting slower access times, exposing information and be more costly.

  1. Check out storing data here

  2. You can use rest for frontend development (I have used react before in truffle's react example). How you would do it is inject a web3 interface from your browser provided by metamask.

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