{"id":21101696,"url":"https://github.com/decodedco/blockchain-marketplace-chaincode","last_synced_at":"2025-08-12T22:37:36.514Z","repository":{"id":72510227,"uuid":"82821618","full_name":"DecodedCo/blockchain-marketplace-chaincode","owner":"DecodedCo","description":"Decoded's blockchain powered marketplace - replaced by blockchain.decoded.com","archived":false,"fork":false,"pushed_at":"2017-02-22T15:55:33.000Z","size":17,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-14T08:21:34.390Z","etag":null,"topics":[],"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/DecodedCo.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-02-22T15:39:30.000Z","updated_at":"2018-11-28T00:43:10.000Z","dependencies_parsed_at":"2023-03-24T03:05:05.955Z","dependency_job_id":null,"html_url":"https://github.com/DecodedCo/blockchain-marketplace-chaincode","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/DecodedCo/blockchain-marketplace-chaincode","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DecodedCo%2Fblockchain-marketplace-chaincode","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DecodedCo%2Fblockchain-marketplace-chaincode/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DecodedCo%2Fblockchain-marketplace-chaincode/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DecodedCo%2Fblockchain-marketplace-chaincode/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DecodedCo","download_url":"https://codeload.github.com/DecodedCo/blockchain-marketplace-chaincode/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DecodedCo%2Fblockchain-marketplace-chaincode/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259288720,"owners_count":22834897,"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":[],"created_at":"2024-11-19T23:48:14.900Z","updated_at":"2025-06-11T15:13:50.777Z","avatar_url":"https://github.com/DecodedCo.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# blockchain-golang-chaincode\n\nThe blockchain application in Golang\n\n# Running the application\n\nYou need to add the hyperledger GO code to your local installation.\n\nso in your GO/src/github.com folder:\n\n```\nmkdir hyperledger\ncd hyperledger\ngit clone git@github.com:hyperledger/fabric.git\ncd fabric\ngit fetch\ngit checkout v.06\n```\n\nThen return to this repo and run:\n\n```\ngo build .\n```\n\nThe run and register it with the blockchain using\n\n```\nCORE_CHAINCODE_ID_NAME=\u003capplicationname\u003e CORE_PEER_ADDRESS=0.0.0.0:7051 ./blockchain-golang-chaincode\n```\n\n```\nCORE_CHAINCODE_ID_NAME=DecodedBlockChain CORE_PEER_ADDRESS=0.0.0.0:7051 ./blockchain-golang-chaincode\n```\n\n# Operations overview.\n\n### Deploy\n\nNow **deploy** the chaincode using:\n\n```\ncurl -X POST -H \"Content-Type: application/json\" -H \"Cache-Control: no-cache\" -d '{\n    \"jsonrpc\": \"2.0\", \n    \"method\": \"deploy\",  \n    \"params\": {\n        \"type\":1, \n        \"chaincodeID\": {\n            \"name\":\"DecodedBlockChain\"\n        }, \n        \"ctorMsg\": { \n            \"function\":\"init\", \n            \"args\": [] \n        } \n    },\n    \"id\": 46664\n}' \"http://0.0.0.0:7050/chaincode\"\n```\n\n**Note: This will be different in the future when using a cluster of peers since you cannot attach a process to all of them it seems**\n\n### Invoke and Query OWNERS\n\nTo create a new owner we need to use the **invoke** method (this adds a `transaction` to the blockchain).\n\n```\ncurl -X POST -H \"Content-Type: application/json\" -H \"Cache-Control: no-cache\" -d '{\n    \"jsonrpc\": \"2.0\", \n    \"method\": \"invoke\",  \n    \"params\": {\n        \"type\":1, \n        \"chaincodeID\": {\n            \"name\":\"DecodedBlockChain\"\n        }, \n        \"ctorMsg\": { \n            \"function\":\"addOwnerString\", \n            \"args\": [ \"dcd\", \"Decoded\", \"100000\", \"description\", \"logo-url\", \"tag\" ] \n        } \n    },\n    \"id\": 2600\n}' \"http://0.0.0.0:7050/chaincode\"\n```\n\nand create another one\n\n```\ncurl -X POST -H \"Content-Type: application/json\" -H \"Cache-Control: no-cache\" -d '{\n    \"jsonrpc\": \"2.0\", \n    \"method\": \"invoke\",  \n    \"params\": {\n        \"type\":1, \n        \"chaincodeID\": {\n            \"name\":\"DecodedBlockChain\"\n        }, \n        \"ctorMsg\": { \n            \"function\":\"addOwnerString\", \n            \"args\": [ \"bc\", \"BlockChain\", \"100000\", \"description\", \"logo-url\", \"tag\" ] \n        } \n    },\n    \"id\": 2600\n}' \"http://0.0.0.0:7050/chaincode\"\n```\n\nNow we have two companies available. We can read the owners in three ways:\n\n1. To now **query** a specific owner:\n\n```\ncurl -X POST -H \"Content-Type: application/json\" -H \"Cache-Control: no-cache\" -d '{\n    \"jsonrpc\": \"2.0\", \n    \"method\": \"query\",  \n    \"params\": {\n        \"type\":1, \n        \"chaincodeID\": {\n            \"name\":\"DecodedBlockChain\"\n        }, \n        \"ctorMsg\": { \n            \"function\":\"read\", \n            \"args\": [ \"dcd\" ] \n        } \n    },\n    \"id\": 1337\n}' \"http://0.0.0.0:7050/chaincode\"\n```\n\nTo **query** all owners without the owners full information\n\n```\ncurl -X POST -H \"Content-Type: application/json\" -H \"Cache-Control: no-cache\" -d '{\n    \"jsonrpc\": \"2.0\", \n    \"method\": \"query\",  \n    \"params\": {\n        \"type\":1, \n        \"chaincodeID\": {\n            \"name\":\"DecodedBlockChain\"\n        }, \n        \"ctorMsg\": { \n            \"function\":\"read\", \n            \"args\": [ \"Owners\" ] \n        } \n    },\n    \"id\": 1337\n}' \"http://0.0.0.0:7050/chaincode\"\n```\n\nTo **query** all Owners with full information you can use the function `readAllOwners`\n\n```\ncurl -X POST -H \"Content-Type: application/json\" -H \"Cache-Control: no-cache\" -d '{\n    \"jsonrpc\": \"2.0\", \n    \"method\": \"query\",  \n    \"params\": {\n        \"type\":1, \n        \"chaincodeID\": {\n            \"name\":\"DecodedBlockChain\"\n        }, \n        \"ctorMsg\": { \n            \"function\":\"readAllOwners\", \n            \"args\": [] \n        } \n    },\n    \"id\": 1337\n}' \"http://0.0.0.0:7050/chaincode\"\n```\n\n### Invoke and Query ASSETS\n\nTo add an asset:\n\n```\ncurl -X POST -H \"Content-Type: application/json\" -H \"Cache-Control: no-cache\" -d '{\n    \"jsonrpc\": \"2.0\", \n    \"method\": \"invoke\",  \n    \"params\": {\n        \"type\":1, \n        \"chaincodeID\": {\n            \"name\":\"DecodedBlockChain\"\n        }, \n        \"ctorMsg\": { \n            \"function\":\"addAssetString\", \n            \"args\": [ \"appleId\", \"Apples\", \"dcd\", \"100\", \"13\", \"description\", \"logo\", \"approval\", \"approvalqty\", \"phonenr\", \"phonemsg\", \"tag\" ] \n        } \n    },\n    \"id\": 2600\n}' \"http://0.0.0.0:7050/chaincode\"\n```\n\nThe quantity and price are no optional\n\n```\ncurl -X POST -H \"Content-Type: application/json\" -H \"Cache-Control: no-cache\" -d '{\n    \"jsonrpc\": \"2.0\", \n    \"method\": \"invoke\",  \n    \"params\": {\n        \"type\":1, \n        \"chaincodeID\": {\n            \"name\":\"DecodedBlockChain\"\n        }, \n        \"ctorMsg\": { \n            \"function\":\"addAssetString\", \n            \"args\": [ \"bananaId\", \"Banana\", \"dcd\", \"100\", \"23\", \"description\", \"logo\", \"approval\", \"approvalqty\", \"phonenr\", \"phonemsg\", \"tag\" ] \n        } \n    },\n    \"id\": 2600\n}' \"http://0.0.0.0:7050/chaincode\"\n```\n\nTo read all the Assets you can use a similar function as for the Owners: `readAllAssets`\n\n```\ncurl -X POST -H \"Content-Type: application/json\" -H \"Cache-Control: no-cache\" -d '{\n    \"jsonrpc\": \"2.0\", \n    \"method\": \"query\",  \n    \"params\": {\n        \"type\":1, \n        \"chaincodeID\": {\n            \"name\":\"DecodedBlockChain\"\n        }, \n        \"ctorMsg\": { \n            \"function\":\"readAllAssets\", \n            \"args\": [ ] \n        } \n    },\n    \"id\": 0\n}' \"http://0.0.0.0:7050/chaincode\"\n```\n\n### Invoke and Query TRANSACTIONS\n\nThere are two types of Transactions possible at this moment: straight-through (no approval needed) and pending (approval needed).\n\nTo transact an asset straight away without approval:\n\n```\ncurl -X POST -H \"Content-Type: application/json\" -H \"Cache-Control: no-cache\" -d '{\n    \"jsonrpc\": \"2.0\",\n    \"method\": \"invoke\",\n    \"params\": {\n        \"type\": 1,\n        \"chaincodeID\": {\n            \"name\": \"DecodedBlockChain\"\n        },\n        \"ctorMsg\": {\n            \"function\": \"transactAsset\",\n            \"args\": [\n                \"appleId\", \"dcd\", \"bc\", \"33\", \"12345\", \"FALSE\"\n            ]\n        }\n    },\n    \"id\": 1\n}' \"http://0.0.0.0:7050/chaincode\"\n```\n\nThe input arguments are: `assetId`, `sellerId`, `buyerId`, `quantity`, `price`, `approvalRequired`.\n\nYou can check the transactions using\n\n```\ncurl -X POST -H \"Content-Type: application/json\" -H \"Cache-Control: no-cache\" -d '{\n    \"jsonrpc\": \"2.0\", \n    \"method\": \"query\",  \n    \"params\": {\n        \"type\":1, \n        \"chaincodeID\": {\n            \"name\":\"DecodedBlockChain\"\n        }, \n        \"ctorMsg\": { \n            \"function\":\"readAllTransactions\", \n            \"args\": [] \n        } \n    },\n    \"id\": 0\n}' \"http://0.0.0.0:7050/chaincode\"\n```\n\nTo create a transaction that needs to be approved use:\n\n```\ncurl -X POST -H \"Content-Type: application/json\" -H \"Cache-Control: no-cache\" -d '{\n    \"jsonrpc\": \"2.0\",\n    \"method\": \"invoke\",\n    \"params\": {\n        \"type\": 1,\n        \"chaincodeID\": {\n            \"name\": \"DecodedBlockChain\"\n        },\n        \"ctorMsg\": {\n            \"function\": \"transactAsset\",\n            \"args\": [\n                \"appleId\", \"dcd\", \"bc\", \"47\", \"8888\", \"TRUE\"\n            ]\n        }\n    },\n    \"id\": 1\n}' \"http://0.0.0.0:7050/chaincode\"\n```\n\nTo approve a transaction\n\n```\ncurl -X POST -H \"Content-Type: application/json\" -H \"Cache-Control: no-cache\" -d '{\n    \"jsonrpc\": \"2.0\",\n    \"method\": \"invoke\",\n    \"params\": {\n        \"type\": 1,\n        \"chaincodeID\": {\n            \"name\": \"DecodedBlockChain\"\n        },\n        \"ctorMsg\": {\n            \"function\": \"approveTransaction\",\n            \"args\": [\n                \"\u003cTRANSACTION-ID\u003e\"\n            ]\n        }\n    },\n    \"id\": 1\n}' \"http://0.0.0.0:7050/chaincode\"\n```\n\nTo decline a transaction\n\n```\ncurl -X POST -H \"Content-Type: application/json\" -H \"Cache-Control: no-cache\" -d '{\n    \"jsonrpc\": \"2.0\",\n    \"method\": \"invoke\",\n    \"params\": {\n        \"type\": 1,\n        \"chaincodeID\": {\n            \"name\": \"DecodedBlockChain\"\n        },\n        \"ctorMsg\": {\n            \"function\": \"declineTransaction\",\n            \"args\": [\n                \"\u003cTRANSACTION-ID\u003e\"\n            ]\n        }\n    },\n    \"id\": 1\n}' \"http://0.0.0.0:7050/chaincode\"\n```\n\n### Other\n\nTo change the validation status of an owner:\n\n```\ncurl -X POST -H \"Content-Type: application/json\" -H \"Cache-Control: no-cache\" -d '{\n    \"jsonrpc\": \"2.0\", \n    \"method\": \"invoke\",  \n    \"params\": {\n        \"type\":1, \n        \"chaincodeID\": {\n            \"name\":\"DecodedBlockChain\"\n        }, \n        \"ctorMsg\": { \n            \"function\":\"changeOwnerValidationStatus\", \n            \"args\": [ \"bc\" ] \n        } \n    },\n    \"id\": 2600\n}' \"http://0.0.0.0:7050/chaincode\"\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdecodedco%2Fblockchain-marketplace-chaincode","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdecodedco%2Fblockchain-marketplace-chaincode","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdecodedco%2Fblockchain-marketplace-chaincode/lists"}