A sample Hyperledger Sawtooth-Sabre application
A sample application that is written in rust and compiled into WASM. The compiled WASM is deployed on the Sabre as a smart contract.
The application can PRODUCE items and CONSUME items after that.
The application can be run as docker container. It has been tested on following version of the docker components.
- Docker version 19.03.4
- Docker compose version 1.24.1
Note: The following commands make it easier for the application developer.
Many of the Hyperledger Sawtooth-Sabre deployment commands are abstracted for the
developer. Please refer to the files registry.sh
and submit-txn.sh
files
to know more details.
- Clone the repository, run the following command
$ git clone https://github.com/arsulegai/produce-consume
$ cd produce-consume
$ docker-compose up
Wait for all the containers to be up, please ensure that processor container is up and running before proceeding further. Note that the container may exit with the status 0. The reason for exit is because, container is used only for building the WASM smart-contract.
To bring down the setup, please run the following command
$ docker-compose down
- Login to the Produce Consume CLI, run the following command
$ docker exec -it pc-cli bash
$ cd ..
$ ./cli/target/debug/pc-cli -C PRODUCE -I Bread -Q 10 -K /keys/validator.priv
This command produces 10 units of the item "Bread".
- Login to the Sabre CLI, run the following command
$ docker exec -it sabre-cli bash
$ cd /project
$ ./registry.sh
$ ./submit-txn.sh
This command would submit the built processor
to the Sawtooth-Sabre, also
sends the generated default.batch
(found in the root folder produce-consume
)
to the WASM
smart-contract. A sample contract-definition.yaml
is also
submitted to the network. Note that the directory paths are hardcoded now.
To add the event handler, run the command from the folder events
$ docker-compose -f docker-compose-go.yaml up
This will bring up the handler written in Go.
A debug docker-compose file for running the smart-contract as a Hyperledger Sawtooth TP is also provided in the repository.
Run the following command to bring up the Hyperledger Sawtooth network with the PRODUCE-CONSUME TP and a CLI.
$ docker-compose -f debug-sawtooth-docker-compose.yaml up
To bring down the setup, please run the following command
$ docker-compose -f debug-sawtooth-docker-compose.yaml down
Imn order for the client to send the transaction directly to the Sawtooth
network, the pc-cli
is provided an --url
or -U
option. i.e. The
client request to the validator would look like
$ ./cli/target/debug/pc-cli -C PRODUCE -I Bread -Q 10 -K /keys/validator.priv --url http://rest-api:8008
This software is in development phase and is Apache 2.0 licensed. We accept
contributions via GitHub pull
requests.
Each commit must include a Signed-off-by:
in the commit message
(git commit -s
). This sign-off means you agree the commit satisfies the
Developer Certificate of Origin (DCO).
This software is licensed under the Apache License Version 2.0 software license.
© Copyright 2019, Walmart Inc.