0

I am starting a project that I need to build a solution to track products (ex: from farm until it gets to the supermarket)

Basically, I need to set up a blockchain structure for my company(private) and put values in there.

Problems: In my research time (about 1 week) I could not found a variety of examples using the blockchain to store objects, the vast majority is about coins. I am studying about Solidity syntax, EVM, web3-js, Ethereum in general with a lot of tutorials.

In other words: I want to insert objects in the blockchain, like company1, company2, person1, person2. Where is it stored? If this is possible, how can I do a SELECT * FROM Persons table Companies and list all companies?

Could any of you guys help me out pointing me to some straightforward tutorial or something helpful?

Ref to tutorials done:

Ethereum Tutorial: Sending Transaction via NodeJS Backend

Get started with Ethereum & Solidity on Windows – Wesley van Heije – Medium

Understanding contracts

Interacting with a Smart Contract through Web3.js (Tutorial)

Understanding Solidity:

Understanding contracts

- now - Building A Private Blockchain Network

Among others... Thanks in advance!

  • 1
    Check this question about patterns in solidity to solve common problems. With the blockchain the approach to solve a problem has to be different, you need to know the limitations and find a solution within those limits. For example ethereum is not good at storing large amounts of data, or resolving complex queries. – Ismael Jan 31 at 4:09
  • ok, I see that I can model my data in a way that it will be possible to be listed and referenced inside the structure. But I still have this question: is it possible to store the data in a structure similarly to tables inside the structures in solidity? Like, one "space" for Companies, other for Persons and etc. – LAT94 Jan 31 at 13:36
  • Yes, is possible but is not suggested and can be annoying to manage, you will see if you read the link provided by Ismael. Moreover, as Isamel stated " ethereum is not good at storing large amounts of data, or resolving complex queries". It is gas and time consuming. Finally, you need to think about the privacy issues concerning the data you want to store on the Blockchain because data is transparent. – 0Alic Jan 31 at 13:44
  • I want a private(enterprise) network, so privacy should not be a problem. – LAT94 Jan 31 at 16:57
  • Is there any tutorial or link to build it? I am reading this now: Private Blockchain hope this reveals a solution to my problem because I am almost giving up and using IBM Blockchain to solve my problem. – LAT94 Jan 31 at 17:05
0

Problems: In my research time (about 1 week) I could not found a variety of examples using the blockchain to store objects, the vast majority is about coins. I am studying about Solidity syntax, EVM, web3-js, Ethereum in general with a lot of tutorials.

The closest to "objects" you are searching for is "structs" in Ethereum that may be stored in a contract.

In other words: I want to insert objects in the blockchain, like company1, company2, person1, person2. Where is it stored? If this is possible, how can I do a SELECT * FROM Persons table Companies and list all companies?

"Objects" or data, in general, will not be stored as in a database, that is a wrong mental model. You won't be able to just query like in SQL. Read through this to understand Ethereum better: https://hackernoon.com/getting-deep-into-ethereum-how-data-is-stored-in-ethereum-e3f669d96033

If you want to achieve some sort of querying for "objects/structs" of a general type, have a look at events in Solidity. You can emit events on a certain topic to then retrieve them again, e.g. with a DApp or a commandline watcher script that is subscribed on a topic of your choice.

0

I'm not an expert in BlockChain and Ethereum. But I provide my thoughts, let me know if it solves the problem and correct me if I'm wrong.

Blockchain is typically meant for tracking the transactions with transparency. The high computational part and the other parts that do not require any transparency such as the master/look up details for the application, are not necessarily be a part of Blockchain. Hence, I suggest the partly-decentralized approach in which you keep all the master information such as the companies, persons and all other parties involved in your business (from farm until it goes to the supermarket) into a typical centralized network with a RDBMS.

Additionally, you can record all other transactions that are happening between all the parties into the decentralized network in the form of Blockchain (using Smart Contract) as they require transparency.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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