Is it possible to store data about arbitrary objects on the blockchain using smart contracts

+1 vote

 And if not what are the ways to use Blockchain to achieve it. (I did some research, and people are using Blockchain in SCM industry. They must have stored these kind of datas).

Mar 25, 2018 in Blockchain by aryya
• 7,450 points

recategorized Aug 30, 2018 by Omkar 1,218 views

3 answers to this question.

+2 votes
Best answer

Basically you implement requested logic on by leveraging chaincodes, you will have to implement following golang interface:

// Chaincode interface must be implemented by all chaincodes. The fabric runs
// the transactions by calling these functions as specified.
type Chaincode interface {
    // Init is called during Instantiate transaction after the chaincode container
    // has been established for the first time, allowing the chaincode to
    // initialize its internal data
    Init(stub ChaincodeStubInterface) pb.Response

    // Invoke is called to update or query the ledger in a proposal transaction.
    // Updated state variables are not committed to the ledger until the
    // transaction is committed.
    Invoke(stub ChaincodeStubInterface) pb.Response
}

For example something similar to this:

type myStoreChaincode struct {
}

func (cc *myStoreChaincode) Init(stub ChaincodeStubInterface) pb.Response {
    return shim.Success(nil)
}

func (cc *myStoreChaincode) Invoke(stub ChaincodeStubInterface) pb.Response {
    action, params = stub.GetFunctionAndParameters()
    if action == "storeItem" {
        cc.StoreItem(stub, params)
    }

    // Handle here other cases and possible parameters combinations
    return shim.Success(nil)
}

func (cc *myStoreChaincode) StoreItem(stub ChaincodeStubInterface, params []string) {
      // Store item on ledger, where params[0] is a key and params[1] actual value
      stub.PutState(params[0], params[1])
}

answered Aug 30, 2018 by Artem

selected Aug 30, 2018 by Omkar
0 votes
yeah it's very much possible to store information relating to any arbitrary object on the blockchain using smart contracts. Good examples would include ethereum smart contracts and hyperledger fabric smart contracts
answered Mar 25, 2018 by charlie_brown
• 7,720 points
0 votes

Yes, you can store what you want using contracts but you have to take care of the encryption.

answered Aug 30, 2018 by Kuro

Related Questions In Blockchain

+1 vote
1 answer

Is it possible to store images on the Ethereum blockchain?

This is possible for your information but, ...READ MORE

answered Feb 24, 2022 in Blockchain by Aditya
• 7,680 points
1,575 views
+1 vote
1 answer

I would like to create a blockchain network which will stay at the same level of complexity, is it possible?

You can very easily create a cryptocurrency having a ...READ MORE

answered Apr 4, 2018 in Blockchain by Christine
• 15,790 points
638 views
+1 vote
1 answer

How is it possible to achieve privacy and confidentiality in smart contracts??

Any contract code written on the blockchain ...READ MORE

answered Apr 18, 2018 in Blockchain by Shashank
• 10,400 points

edited Aug 7, 2018 by Omkar 698 views
+1 vote
1 answer

Is it possible to store blockchain in a sql or no-sql database?

Currently, following are the options to store ...READ MORE

answered Apr 21, 2018 in Blockchain by Perry
• 17,100 points

edited Aug 9, 2018 by Omkar 793 views
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
1,663 views
+1 vote
3 answers

Removing double quotes from a string from JSON response in PHP

Just remove the json_encode call, and it should work: $resp ...READ MORE

answered Sep 12, 2018 in Blockchain by digger
• 26,740 points
43,812 views
0 votes
1 answer

Hyperledger Sawtooth vs Quorum in concurrency and speed Ask

Summary: Both should provide similar reliability of ...READ MORE

answered Sep 26, 2018 in IoT (Internet of Things) by Upasana
• 8,620 points
1,215 views
0 votes
1 answer

How to explore and analyze the data inside a Hyperledger Blockchain network?

In Hyperledger Composer, you have all the ...READ MORE

answered Aug 10, 2018 in Blockchain by Christine
• 15,790 points
1,010 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP