Sawtooth is a Distributed Ledger Blockchain platform which is being fostered under the Hyperledger Umbrella. Sawtooth is slowly gaining momentum in the Blockchain industry as well and becoming the second Hyperledger Blockchain Platform to do so after Fabric.
To get started on Sawtooth you need to download
After setting those up, you need to download this docker compose file for sawtooth which will alow you to run your Sawtooth network in Docker containers.
Once you have downloaded the file, go to its directory and run the command
docker-compose -f sawtooth-default.yaml up
This will download and start up all the docker containers required for your sawtooth network.
To see your running containers, run the command in another terminal
You will need to access the client container to interact with your sawtooth network. Log into the client container by running
docker exec -it sawtooth-shell-default bash
Now run this command from inside the container to make sure that the validator is up & running
If everything is in order, lets proceed to playing Sawtooth’s built in tic-tac-toe game!
First, we’ll have to register two users. Run the following commands
sawtooth keygen Taha
sawtooth keygen Danyal
Now we have two users named “Taha” & “Danyal”
We will be using the “xo cli” for this tutorial. This cli will be responsible for sending transactions to the validator. To make sure that it is up & running, run the following command inside the client container
Now lets start the game by
xo create game --url http://rest-api:8008 --username Taha
To check if our game has been successfully created
xo list --url http://rest-api:8008 --username Taha
You should see a “game” object in this list. Now lets actually start the game by taking the first player turn!
xo take game 5 --url http://rest-api:8008 --username Taha
This would’ve marked the first player at the 5th position of the board. To confirm, lets run
xo show game --url http://rest-api:8008 --username Taha
This will show you the current state of the board with a cross in the middle.
Now, let the 2nd player do their turn
xo take game 1 --url http://rest-api:8008 --username Danyal
And again, after doing this you can check the state of the board by
xo show game --url http://rest-api:8008 --username Danyal
Now keep repeating these steps to complete your game and hopefully you’ll find a winner. In our case, it was a draw!
If you need more help with Hyperledger Sawtooth, Please feel free to contact our blockchain development company.