{"id":19014526,"url":"https://github.com/deeptiman/offchaindata","last_synced_at":"2025-04-23T00:43:33.868Z","repository":{"id":57574720,"uuid":"243138328","full_name":"Deeptiman/offchaindata","owner":"Deeptiman","description":"Hyperledger Fabric OffChain Storage","archived":false,"fork":false,"pushed_at":"2021-06-14T20:56:50.000Z","size":29,"stargazers_count":22,"open_issues_count":0,"forks_count":15,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-23T00:43:25.754Z","etag":null,"topics":["blockchain-technology","couchdb","docker","golang","grpc-client","grpc-go","grpc-service","hyperledger-fabric","mapreduce","mapreduce-demo","offchain-storage"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Deeptiman.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-02-26T01:13:48.000Z","updated_at":"2024-04-06T17:54:33.000Z","dependencies_parsed_at":"2022-09-18T06:15:21.041Z","dependency_job_id":null,"html_url":"https://github.com/Deeptiman/offchaindata","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Deeptiman%2Foffchaindata","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Deeptiman%2Foffchaindata/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Deeptiman%2Foffchaindata/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Deeptiman%2Foffchaindata/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Deeptiman","download_url":"https://codeload.github.com/Deeptiman/offchaindata/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250348884,"owners_count":21415907,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["blockchain-technology","couchdb","docker","golang","grpc-client","grpc-go","grpc-service","hyperledger-fabric","mapreduce","mapreduce-demo","offchain-storage"],"created_at":"2024-11-08T19:29:51.386Z","updated_at":"2025-04-23T00:43:33.841Z","avatar_url":"https://github.com/Deeptiman.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1\u003eOffChain Data\u003c/h1\u003e\n\u003cp\u003e     \u003cimg alt=\"GitHub last commit\" src=\"https://img.shields.io/github/last-commit/Deeptiman/offchaindata\"\u003e  \u003cimg alt=\"GitHub language count\" src=\"https://img.shields.io/github/languages/count/Deeptiman/offchaindata\"\u003e \u003cimg alt=\"GitHub top language\" src=\"https://img.shields.io/github/languages/top/Deeptiman/offchaindata\"\u003e\u003c/p\u003e\n\u003cp\u003e\u003ca href=\"https://www.hyperledger.org/projects/fabric\"\u003e\u003cimg src=\"https://www.hyperledger.org/wp-content/uploads/2016/09/logo_hl_new.png\" alt=\"N|Solid\"\u003e\u003c/a\u003e\u003c/p\u003e\n\u003cp\u003e\u003cb\u003eOffChain Data\u003c/b\u003e is a sample demonstration to understand the concept of implementing offchain storage and it's capability in Hyperledger fabric Blockchain network.\n So, this project will work as a peer block event listener and will store the block details in the \u003cb\u003eCouchDB\u003c/b\u003e that can be query through \u003cb\u003eMapReduce\u003c/b\u003e.\u003c/p\u003e\n \u003cp\u003e\u003cb\u003eMedium writeup : \u003c/b\u003e\u003ca href=\"https://medium.com/@deeptiman/offchain-storage-in-hyperledger-fabric-77e28bd99e0c\"\u003ehttps://medium.com/@deeptiman/offchain-storage-in-hyperledger-fabric-77e28bd99e0c\u003c/a\u003e\n\n \n \u003ch2\u003eConfiguration requirements\u003c/h2\u003e\n \u003cp\u003eYou need to add the certain project details in `config.json`, so that it will be used to create an event listener and the Blocks will be received through \u003cb\u003eGRPC\u003c/b\u003e delivery\nclient. \u003c/p\u003e\n\n````````````````````````````````````````````````````````````````````````````````````````````````````````````\nexport FABRIC_CFG_PATH= /home/user/go/src/github.com/exampleledger/fixtures\n````````````````````````````````````````````````````````````````````````````````````````````````````````````\n\n````````````````````````````````````````````````````````````````````````````````````````````````````````````\n       {\n            \"peer_config_path\": \"exampleledger/fixtures/crypto-config/peerOrganizations/\",\n            \"msp_id\": \"Org1MSP\",\n            \"msp_type\": \"bccsp\",    \n            \"msp_config_dir\": \"org1.example.ledger.com/users/Admin@org1.example.ledger.com/msp\",\n            \"client_key\": \"org1.example.ledger.com/peers/peer0.org1.example.ledger.com/tls/server.key\",\n            \"client_cert\": \"org1.example.ledger.com/peers/peer0.org1.example.ledger.com/tls/server.crt\",\n            \"root_cert\": \"org1.example.ledger.com/peers/peer0.org1.example.ledger.com/tls/ca.crt\",\n            \"server\": \"peer0.org1.example.ledger.com:7051\",\n            \"channel_id\": \"exampleledger\",\n            \"config_file\": \"configtx\"\n       }\n`````````````````````````````````````````````````````````````````````````````````````````````````````````````````\n\n\u003ch2\u003eCreate CouchDB local instance \u003c/h2\u003e\n\nThe CouchDB local instance can be created using Docker.\n```````````````````````````````````````````````````````````````````````````````````````````````````````````````\ndocker run --publish 5990:5984 --detach --name offchaindb hyperledger/fabric-couchdb\ndocker start offchaindb\n`````````````````````````````````````````````````````````````````````````````````````````````````````````````````\n\n\u003ch2\u003e Mock Chaincode Model\u003c/h2\u003e\nI have followed a sample user model to create the offchaindb. You can also create your own chaincode model and the offchaindata\nwill listen the `KVWriteSet` to store in the couchdb.\n\n\u003cb\u003eSample Model\u003c/b\u003e\n``````````````````````````````````````````````````````````````````````````````````````````````````````````````````\ntype SampleUser struct {\n\tEmail \t  string \t\t`json:\"email\"`\t\n\tName \t  string \t\t`json:\"name\"`\n\tAge\t  string\t\t`json:\"age\"`\n\tCountry   string\t\t`json:\"country\"`\n }\n``````````````````````````````````````````````````````````````````````````````````````````````````````````````````\n\n\u003ch2\u003eConfigure MapReduce\u003c/h2\u003e\n\n\u003cp\u003e\u003cb\u003eMapReduce\u003c/b\u003e will query the offchain data from \u003cb\u003eCouchDB\u003c/b\u003e. So, you need to configure MapReduce for certain design element from CouchDB collection.\u003c/p\u003e\n\n\u003cb\u003eConfigure MapReduce for Email\u003c/b\u003e\n````````````````````````````````````````````````````````````````````````````````````````````````````````````````\ncurl -X PUT http://127.0.0.1:5990/offchaindb/_design/emailviewdesign/ -d '{\"views\":{\"emailview\":{\"map\":\"function(doc) { emit(doc.email,1);}\", \"reduce\":\"function (keys, values, combine) {return sum(values)}\"}}}' -H 'Content-Type:application/json'\n````````````````````````````````````````````````````````````````````````````````````````````````````````````````\n\u003cb\u003eOutput\u003c/b\u003e\n````````````````````````````````````````````````````````````````````````````````````````````````````````````````\n{\"ok\": true, \"id\":\"_design/emailviewdesign\", \"rev\": \"1-f34147f686003ff5c7da5a5e7e2759b8\"}\n````````````````````````````````````````````````````````````````````````````````````````````````````````````````\n\n\u003cb\u003eQuery `Reduce` function to count total email\u003c/b\u003e\n```````````````````````````````````````````````````````````````````````````````````````````````````````````````\ncurl -X GET http://127.0.0.1:5990/offchaindb/_design/emailviewdesign/_view/emailview?reduce=true\n```````````````````````````````````````````````````````````````````````````````````````````````````````````````\n\u003cb\u003eOutput\u003c/b\u003e \n```````````````````````````````````````````````````````````````````````````````````````````````````````````````\n{\"rows\":[\n\t\t{\"key\":null,\"value\":7}\n\t]}\n```````````````````````````````````````````````````````````````````````````````````````````````````````````````\n\n\u003cb\u003eQuery `Map` function to list all emails\u003c/b\u003e\n```````````````````````````````````````````````````````````````````````````````````````````````````````````````\ncurl -X GET http://127.0.0.1:5990/offchaindb/_design/emailviewdesign/_view/emailview?group=true\n```````````````````````````````````````````````````````````````````````````````````````````````````````````````\n\u003cb\u003eOutput\u003c/b\u003e\n```````````````````````````````````````````````````````````````````````````````````````````````````````````````\n{\"rows\":[\n\t\t{\"key\":\"alice@gmail.com\",\"value\":1},\n\t\t{\"key\":\"john@gmail.com\",\"value\":1},\n\t\t{\"key\":\"michale@gmail.com\",\"value\":1},\n\t\t{\"key\":\"mark@mail.com\",\"value\":1},\n\t\t{\"key\":\"bob@gmail.com\",\"value\":1},\n\t\t{\"key\":\"oscar@gmail.com\",\"value\":1},\n\t\t{\"key\":\"william@example.com\",\"value\":1}\n\t]}\n```````````````````````````````````````````````````````````````````````````````````````````````````````````````\n\nSo, all the query peformed in offchain without querying from blockchain ledger.\n\n\u003ch2\u003eLicense\u003c/h2\u003e\n\u003cp\u003eThis project is licensed under the \u003ca href=\"https://github.com/Deeptiman/offchaindata/blob/master/LICENSE\"\u003eMIT License\u003c/a\u003e\u003c/p\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeeptiman%2Foffchaindata","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdeeptiman%2Foffchaindata","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeeptiman%2Foffchaindata/lists"}