Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kfsoftware/hlf-cc-go-template
https://github.com/kfsoftware/hlf-cc-go-template
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/kfsoftware/hlf-cc-go-template
- Owner: kfsoftware
- Created: 2022-01-11T12:31:36.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2022-01-29T21:04:22.000Z (about 3 years ago)
- Last Synced: 2024-11-05T15:16:54.671Z (3 months ago)
- Language: Go
- Size: 10.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## HLF go chaincode template
### Start tunnel
```bash
ngrok tcp 9999
```### Install, approve and commit chaincode
```bash
CHAINCODE_NAME=template_go
API_URL="http://localhost:8080/graphql"
SIGNATURE_POLICY="OR('Org1MSP.member', 'Org2MSP.member')"
CHAINCODE_ADDRESS_TUNNEL="4.tcp.eu.ngrok.io:13438" # the forwarding URL you get from opening an ngrok tunnel
hlf-cc-dev start --localChaincode="localhost:9999" \
--chaincodeAddress="${CHAINCODE_ADDRESS_TUNNEL}" \
--chaincode="${CHAINCODE_NAME}" \
--signaturePolicy="${SIGNATURE_POLICY}" \
--env-file="${PWD}/.env" \
--apiUrl="${API_URL}"
```### Start chaincode
```bash
source .env && go run ./main.go
```### Test chaincode
You can go to the playground(instead of /graphql, use /playground) and use the following mutation and query to test the chaincode:
```graphql
mutation invoke {
invokeChaincode(input:{
chaincodeName:"template_go"
function: "InitLedger"
args: []
transientMap: []
}){
response
transactionID
chaincodeStatus
}
}mutation query {
queryChaincode(input:{
chaincodeName:"template_go"
function: "GetAllAssets"
args: []
transientMap: []
}){
response
chaincodeStatus
}
}```