Skip to content

Commit

Permalink
[WIP] Add developing chaincode tutorial
Browse files Browse the repository at this point in the history
See #127

Signed-off-by: James Taylor <[email protected]>
  • Loading branch information
jt-nti committed Aug 16, 2024
1 parent e9bf835 commit c86e6e7
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 0 deletions.
56 changes: 56 additions & 0 deletions docs/tutorials/develop-chaincode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Developing and debuging chaincode

TODO: Check chaincode/contract api implementations all support automatic switching between client and server mode...
- [Go contracts](https://github.com/hyperledger/fabric-contract-api-go/commit/7c7666d5dd3bdc23ace194784d123697669a3558)
- Java (tbc)
- Node (tbc)


Use ccaas.env file? Might be easier to set chaincode ID outside file?

```
# CHAINCODE_SERVER_ADDRESS must be set to the host and port where the peer can
# connect to the chaincode server
CHAINCODE_SERVER_ADDRESS=
# CHAINCODE_ID must be set to the Package ID that is assigned to the chaincode
# on install. The `peer lifecycle chaincode queryinstalled` command can be
# used to get the ID after install if required
CHAINCODE_ID=
# Optional parameters that will be used for TLS connection between peer node
# and the chaincode.
# TLS is disabled by default, uncomment the following line to enable TLS connection
# CHAINCODE_TLS_DISABLED=false
# Following variables will be ignored if TLS is not enabled.
# They need to be in PEM format
# CHAINCODE_TLS_KEY=/path/to/private/key/file
# CHAINCODE_TLS_CERT=/path/to/public/cert/file
# The following variable will be used by the chaincode server to verify the
# connection from the peer node.
# Note that when this is set a single chaincode server cannot be shared
# across organizations unless their root CA is same.
# CHAINCODE_CLIENT_CA_CERT=/path/to/peer/organization/root/ca/cert/file
```

Run the chaincode... use docker? What networking would be required to get to peer inside k8s test network?

```
docker pull ghcr.io/hyperledger-labs/fabric-builder-k8s/sample-go-contract:latest
docker pull ghcr.io/hyperledger-labs/fabric-builder-k8s/sample-node-contract:latest
docker pull ghcr.io/hyperledger-labs/fabric-builder-k8s/sample-java-contract:latest
```

```
docker run -it --rm --name sample-contract --env-file ccaas.env ghcr.io/hyperledger-labs/fabric-builder-k8s/sample-go-contract
```

TBC, that seemed to run the peer!!!

Maybe don't use docker! :)

See also:
- https://github.com/hyperledger/fabric-samples/blob/main/full-stack-asset-transfer-guide/docs/SmartContractDev/03-Test-And-Debug-Reference.md

1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,5 @@ nav:
- Kubernetes namespace: configuring/kubernetes-namespace.md
- Kubernetes service account: configuring/kubernetes-service-account.md
- Tutorials:
- Developing and debuging chaincode: tutorials/develop-chaincode.md
- Creating a chaincode package: tutorials/package-chaincode.md
24 changes: 24 additions & 0 deletions samples/go-contract/ccaas.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# CHAINCODE_SERVER_ADDRESS must be set to the host and port where the peer can
# connect to the chaincode server
CHAINCODE_SERVER_ADDRESS=localhost

# CHAINCODE_ID must be set to the Package ID that is assigned to the chaincode
# on install. The `peer lifecycle chaincode queryinstalled` command can be
# used to get the ID after install if required
CHAINCODE_ID=test

# Optional parameters that will be used for TLS connection between peer node
# and the chaincode.
# TLS is disabled by default, uncomment the following line to enable TLS connection
# CHAINCODE_TLS_DISABLED=false

# Following variables will be ignored if TLS is not enabled.
# They need to be in PEM format
# CHAINCODE_TLS_KEY=/path/to/private/key/file
# CHAINCODE_TLS_CERT=/path/to/public/cert/file

# The following variable will be used by the chaincode server to verify the
# connection from the peer node.
# Note that when this is set a single chaincode server cannot be shared
# across organizations unless their root CA is same.
# CHAINCODE_CLIENT_CA_CERT=/path/to/peer/organization/root/ca/cert/file

0 comments on commit c86e6e7

Please sign in to comment.