Sawtooth example network using JavaScript SDK: transaction processor and client
This is a minimal example of a sawtooth 1.0 application. This example demonstrates, a common usecase, where a customer deposits/withdraws/transfers money from a wallet account.
A customer can:
- deposit money into his/her wallet account
- withdraw money from his/her wallet account
- check the balance in the wallet account
- transfer money from his/her wallet account to another
The customer is identified by a customer name and a corresponding public key. The wallet account balance, is stored at an address, derived from SHA 512 hash of customer's public key and the simplewallet transaction family namespace.
The application is built in two parts:
- The client application written in nodeJS. The
app.js
is the main javascript file from where themain
function call occurs. Handlebars are used for templating, client related CSS and JavaScript code is written in public folder and server related files are written inrouter/
folder. It is accessible via browser atlocalhost:3000
. - The Transaction Processor, that uses the JS Sawtooth SDK.
JAVASCRIPT CLIENT USAGE
How to use the simplewallet UI:
- Build and start the Docker containers:
docker-compose -f docker-compose.yaml up
- Open bash shell in
simplewallet-client-js
container:
docker exec -it simplewallet-client-js bash
- Create user accounts for jack and jill:
sawtooth keygen jack && sawtooth keygen jill
-
Open two new browser tabs and go to
http://localhost:3000
on each tab -
Login in one tab as
jack
and in other asjill
-
Start with an initial deposit for each user - jack and jill via the
Deposit
tab in the UI homepage