{"id":24431138,"url":"https://github.com/0xjonaseb11/hlf_cc_dev_go","last_synced_at":"2025-04-12T12:50:44.800Z","repository":{"id":217941680,"uuid":"745162646","full_name":"0xJonaseb11/hlf_cc_dev_go","owner":"0xJonaseb11","description":"Hyperledger chaincode development using GoLang","archived":false,"fork":false,"pushed_at":"2024-06-17T06:41:34.000Z","size":47347,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-26T07:36:04.445Z","etag":null,"topics":["blockchain","chaincode","docker","golang","hyperledger-fabric","sdks","startups"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/0xJonaseb11.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2024-01-18T19:05:52.000Z","updated_at":"2024-11-17T20:18:51.000Z","dependencies_parsed_at":"2024-01-25T11:43:11.386Z","dependency_job_id":"cb9b7754-a033-4a90-a1d5-5057e97374bd","html_url":"https://github.com/0xJonaseb11/hlf_cc_dev_go","commit_stats":null,"previous_names":["jaz-3-0/hyperledger_chaincode_dev","0xjonaseb11/hlf_cc_dev_go"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xJonaseb11%2Fhlf_cc_dev_go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xJonaseb11%2Fhlf_cc_dev_go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xJonaseb11%2Fhlf_cc_dev_go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xJonaseb11%2Fhlf_cc_dev_go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/0xJonaseb11","download_url":"https://codeload.github.com/0xJonaseb11/hlf_cc_dev_go/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248571329,"owners_count":21126516,"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","chaincode","docker","golang","hyperledger-fabric","sdks","startups"],"created_at":"2025-01-20T14:59:00.051Z","updated_at":"2025-04-12T12:50:39.776Z","avatar_url":"https://github.com/0xJonaseb11.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Hyperledger_fabric2.x_chaincode_development\n\n_**Author: @0xJonaseb11**_\n\n## About\n\nMaster and interact with Hyperledger chain code development using Go Lang\n\nHyperledger Fabric is a platform for distributed ledger solutions, underpinned by a modular architecture delivering high degrees of confidentiality, resiliency, flexibility and scalability. It is designed to support pluggable implementations of different components, and accommodate the complexity and intricacies that exist across the economic ecosystem.\n\nHyperledger Fabric delivers a uniquely elastic and extensible architecture, distinguishing it from alternative blockchain\nsolutions\n\n## Getting started\n\n- Install\n  \n  - curl\n  - docker LTS\n  - docker compose LTS (install with docker)\n  - Go LTS\n  - Node.js LTS\n  \n## `Check for installed`\n\n```sh\ndocker --version\ndocker-compose --version\ncurl --version\norderer version\npeer version\ngo --version\nvagrant --version\n ```\n\n ```sh\n # validate go-tools\n govendor -h\n # validate fabric\n ./validate-fabric.sh\n # validate git-repo updates\n ./validate-git-repo.sh\n # validate prerequisites\n ./validate-prereqs.sh\n # validate setup\n ./validate-setup.sh\n # validate hyperledger explorer\n ./validate-explorer.sh\n# validate node\nnode -v\n ```\n\n## `Update git repo`\n\n ```sh\n ./update-git-repo.sh\n ```\n\n### `Install dependencies`\n\n```sh\nvagrant up\nvagrant ssh\ncd network/setup\n\n# install prerequisites\n./install-preqs.sh\n# install hyperledger explorer\n./install-explorer.sh\n# install fabric\n./install-fabric.sh\n# install nodejs utilities\n./install-node-utils.sh\n```\n\n## `Development scripts`\n\n```sh\nvagrant ssh\ncd network/bin\n# initialize and launch dev setup\n./dev-init.sh\n# validate the dev environment\n./dev-validate.sh\n# stop containers -\u003e (non-destructive)\n./dev.stop.sh\n# start the stopped containers\n./dev-start.sh\n# check the launch mode for the env (dev|net)\n./dev-mode.sh\n```\n\n## `Validate container health`\n\n```sh\ndocker ps\n```\n\n## `Environment setup scrupts`\n\n```sh\nvagrant ssh\n# set environement variables for peer binary\nset-env.sh\n# shows the values set in environment variables\nshow-env.sh\n```\n\n## `Set up the organisation context`\n\n```sh\nsource set-env.sh  acme | budget # in source\n. set-env.sh  acme | budget # .\n```\n\n## `Getting the organisation context`\n\n```sh\n# print the current env context setup\nshow-env.sh\n```\n\n## `Channel commands`\n\n```sh\n# peer channel help\npeer channel --help\n# List the channels peer has joined\npeer channel list\n# Get info about the blockchain\npeer channel getinfo -c airlinechannel\n```\n\n## `Manage lifecycle of chaincode`\n\n```sh\npeer lifecycle subcommand --flags || peer chaincode subcommand --flags\n# get help on it\npeer lifecycle chaincode -h\n\n## Get peers chaincode validated and up runnning\npeer lifecycle chaincode queryinstalled\n\n# wait for commit confirmation on the peer\npeer lifecycle chaincode command --waitForEvent\n\n# Peer lifecycle chaincode approveFormyorg - all flags\npeer lifecycle chaincode approveformyorg -h\n\n# check ther orgs that have approved\npeer lifecycle chaincode checkcommitreadiness \u003c--flags\u003e || -h\n\n# Peer lifecycle commit\npeer lifecycle chaincode commit \u003c--flags\u003e || -h\n\n# Check commit status\npeer lifecycle chaincode querycommitted\n\n# Alternatively, you can check and commit with `chain.sh`\nchain.sh commit # commit \nchain.sh querycommitted # status of commit\nchain.sh list # list of installed chaincode\n\n# Common lifecycle flags used \n-n -v # Name \u0026\u0026 version of chaincode\n-C --channelID # channel ID\n-sequence # sequence number on the CC\n--init-required # indicates if initialization is required\n--peerAddresses # endorsing peers\n-o # Orderer address\n\n# With the accessible main apis\n# execute logic - peer\npeer chaincode invoke\n# Read blockchain state\npeer chaincode query\n\n## With older versions of fabric ( below 2.x)\npeer chaincode install\npeer chaincode upgrade\npeer chaincode instantiate\n```\n\n## `Working with hyperledger explorer`\n\n```sh\n# Reset the explorer runtime\nexp-init.sh -e\n# Stop the running explorer containers\nexp-stop.sh\n# Restart the explorer containers\nexp-start.sh  \n```\n\n## `Chaincode development scripts`\n\n```sh\n# Execute peer chaincode commands\nchain.sh\n# set environemt variables for chaincode arguments || With no flags displays the current setup\nset-chain-env.sh\n# Access the command arguments in Environent variables\ncc.env.sh\n# Show all the envoronemt variables set using `set-chain-env.sh`\nshow-chain-env.sh\n# Reset chaincode environment\nreset-chain-env.sh\n\n## Let's try to change the name of the chaincode\nset-chain-env.sh -n new_chaincode_name\n\n# Query the peer and get the instant chaincode from it\nchain.sh queryinstalled\n# Query the gocc chaincode installed at my peer\nchain.sh query\n# Let's get the command the chain.sh will execute\nchain.sh querycommitted -o\n\n## Get every list of flags\nset-chain-env.sh -h\n```\n\n## `Peer lifecycle package installation`\n\n```sh\npeer lifecycle package tar-file --flags\n# Important flags to consider\n--peerAddress -\u003e Target peer(multiple may be specified)\n--label -\u003e Label for the chaincode\n-p -\u003e path for the chaincode\n\n# Once you don't specify the path, it will beinstalled at\n$ CORE_PEER_ADDRESS\n```\n\n## `Install chaincode using  'chain.sh'  utility`\n\n```sh\nchain.sh install packge_name\n# Create a package and install chaincode on it\nchain.sh install -p\n```\n\n## `Retrieve list of chaincodes installed`\n\n```sh\nchain.sh queryinstalled\n```\n\n## `Approve chaincode`\n\n```sh\n. set-chain-env.sh acme\n# Do the approval\nchain.sh approveformyorg || chain.sh approve\n\n# show which orgs have approved\nchain.sh checkcommitreadiness || chain.sh check\n\n# Chain.sh foe CC instantiation\nchain.sh instantiate # approves, commits and inits the chaincode\n```\n\n## `set the initialization status`\n\n```sh\nset-chain-env.sh -I false || true\n```\n\n## `Query and invoke interfaces`\n\n## `query`\n\n```sh\nset-chain-env.sh -i # CC_INVOKE_ARGS\n# for query \nset-chain-env.sh -q # CC_QUERY_ARGS\n\n# Real query operations\nset-chain-env.sh -q '{\"Args\":[\"query\",\"a\"]}' # set args\nchain.sh query # get result\n```\n\n## `invoke`\n\n```sh\nset-chain-env.sh -i '{\"Args\":[\"invoke\",\"a\",\"b\",\"5\"]}'\nchain.sh invoke\nchain.sh query\n```\n\n## `With init`\n\n```sh\nset-chain-env.sh -C # CC_CONSTRUCTOR\n```\n\n## _**`NOTE:: init MUST be executed before Invoke and Query operations`**_\n\n```sh\nchain.sh init -o\nchain.sh init\n```\n\n## `Chaincode update and Upgrade`\n\n```sh\nset-chain-env.sh -v \u003cversion\u003e # set chaincode version \n# Updating chaincode parameters\nset-chain-env.sh -s \u003csequence_no\u003e # New sequence number\nset-chain-env.sh -v \u003cversion\u003e # Version of the chaincode\nset-chain-env.sh -I \u003cboolean\u003e # Initialization true | false\nset-chain-env.sh -g, -G # Specify Endorsement policy\nset-chain-env.sh -R # Private data collection\n```\n\n`trial task`\n\n```sh\nset-chain-env.sh -v 2.1\nset-chain-env.sh -s 4\nchain.sh package\nchain.sh install\nchain.sh approve -o\nchain.sh approve\nchain.sh commit\n```\n\n## `Chain.sh for automatic updates`\n\n```sh\nchain.sh upgrade-auto\n```\n\n## `Peer launch modes - Net \u0026\u0026 Dev modes`\n\n```sh\ncc-build.sh # Builds the chaincode using: `go build $CC_PATH\ncc-run.sh # Runs chaincode with : `go run $GOPATH/src/$CC_PATH/*.go`\n```\n\n## `dev mode` - Terminal 1\n\n```sh\n# Peer launch dev mode\n## Terminal 1\ndev-init.sh -d\n. set-env.sh acme\nset-chain-env.sh\nchain.sh install\ncc-run.sh \n```\n\n## Terminal 2\n\n```sh\n. set-env.sh acme\nchain.sh instantiate\nchain.sh invoke\nchain.sh query\n```\n\n## `chaincode logging`\n\n```sh\nset-chain-env.sh -L \u003clevel\u003e # provided as a string\nset-chain-env.sh -S \u003clevel\u003e # provided as a string\n```\n\n## `Accessing proposal elements`\n\n```sh\nvagrant up\nvagrant ssh\n# init dev env\ndev-init.sh\nsource set-env.sh acme\n\n# Install \u0026\u0026 instantiate the chaincode\nset-chain-env.sh -n token -p token/v3\n# install the chaincode\nchain.sh install -p\n# instantiate the chaincode\nchain.sh instantiate\n# start following the logs\ncc-logs.sh -f\n\n## In a new terminal\n. set-env.sh acme\nchain.sh invoke\n```\n\n--------------------\n\n@0xJonaseb11\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F0xjonaseb11%2Fhlf_cc_dev_go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F0xjonaseb11%2Fhlf_cc_dev_go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F0xjonaseb11%2Fhlf_cc_dev_go/lists"}