Storing and Retrieving Data in Ethereum Blockchain

2019-04-16 05:29发布

问题:

I am a beginner in blockchian and I want to store a personal demographics data in a ethereum blockchain via solidity.I have some basic questions regarding that:

  1. Do I have to store the data in a smart contract ?
  2. Say I store multiple personal data in the blockchain , in that case would each personal data get stored in separate blocks using the same instance of the smart contract ?
  3. Are there any open source tools through which I can view the blocks in my local ethereum block chain?

回答1:

I will try to answer this in easy terms.

Do I have to store the data in a smart contract ?

Yes you need to store the data by calling smart contract functions.

Say I store multiple personal data in the blockchain.....

In most cases that data will be in different blocks, but if two consecutive transactions are too fast they might get into same block. It will have different transaction id, but same block header. The data you store to the blockchain, to retrieve that you need to call functions from the same smart contract. Think of the smart contract as only door to enter the building. Whether to store or to retrieve you need to come through that door (smart contract).

Are there any open source tools...

To retrieve the data you need to use smart contract function calls, you can use nodejs with web3 package to call smart contracts.

And for block explorer for public chain check etherscan

For private block explorer etherparty explorer



回答2:

Ethereum blockchain is not intended to allocate a large amount of data. If you are looking for a decentralized storage solution a good and strong alternative is IPFS + Swarm.

How that works? IPFS generates an unique HASH_ID which refers to the file content. Once a file is added to IPFS its content is encoded into a Merkel tree structure and IPFS bootstrap nodes(provided by IPFS team) are informed of the presence of that file in the network. From that exact moment, anyone who knows the existence of that HASH_ID will be able to pull the content of your local running ipfs node. Once the file is pulled by another node, that node becomes another source for your file.

As you see the disadvantage of that model is that you lose control over the files you upload into IPFS very easily. That is why my team, Lightstreams, we implemented an ACL layer on top of IPFS which implement the functionality of allowing or denying accounts to access your files. You can see some of the documentation about how you could do it using our technology in our wiki. You can also play around our technology without running a local node by the https api we provide for that.

Moreover, our team is working on building an ethereum compatible blockchain replacing PoW by PoA using Tendermint BTF. Every DApp currently running over the Ethereum network can easily migrate to our network. We decided to implement our own blockchain due to the limitation of running over Ethereum regarding transaction approval time and txs cost which is our case reach a ~100tx/s and a cost of ~2.5c$/tx.

Our project was open-source a few weeks ago. Our testnet has been running for over 3 months and we are launching our mainnet by the end of March. We are happy to support developers to join us in our discuss forum and we have an open bounty program for developers who want to develop Dapps over our network.