Skip to content

Commit

Permalink
[CE-303] E2E play with smart contract on User Dashboard
Browse files Browse the repository at this point in the history
Update smart contract tutorial part

Change-Id: Ia0d0e36029c0d9cff60047424d2cd151d4f37ed4
Signed-off-by: lujjiang@cn.ibm.com <lujjiang@cn.ibm.com>
  • Loading branch information
lujjiang committed Apr 22, 2018
1 parent fc0da0a commit dbbed6e
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 1 deletion.
Binary file added docs/imgs/tutorial_apply_chain.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/imgs/tutorial_deploy_contract.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/imgs/tutorial_install_contract.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/imgs/tutorial_invoke_contract.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/imgs/tutorial_query_contract.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
68 changes: 67 additions & 1 deletion docs/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Following the [setup steps](./setup.md) to start a Cello cluster.

After that, operators can interact with Cello through dashboard.

By default, the dashboard will listen on port `8080` at the Master Node, you can login with default administrator account of `admin:pass`.
By default, the operator dashboard will listen on port `8080` at the Master Node, you can login with default administrator account of `admin:pass`.

## Add a Host

Expand Down Expand Up @@ -63,6 +63,72 @@ It will be difficult if you have a numbers of chains to create manually. Cello p

Try these methods as you like.

## Apply a blockchain

By default, the user dashboard will listen on port `8081` at the Master Node, and operators can login in with default `admin:pass` credential. Or you can change to "sign up" to create a new account.

Click "Apply Now" to apply a new blockchain. Fill the "Name" field as the chain name, and select "Fabric" for the chain type. Then there will show one Fabric - Advance Config for configurations, keep selecting as default configuration, then click Submit button to request a new blockchain.

![Apply a blockchain](imgs/tutorial_apply_chain.png)

## Add a Smart Contract

By default, there are two smart contracts examples available. You can add a new smart contract by uploading your local smart contracts file.

[map example](https://github.com/hyperledger/cello/blob/master/user-dashboard/src/config-template/cc_code/examples/fabric/map/map.go)

This chaincode implements a simple map that is stored in the state.

The following invoke functions are available.

* put - requires two arguments, a key and value, and stores them in the state
* remove - requires a key and removes it from the state
* get - requires one argument, a key, and returns a value
* keys - requires no arguments, returns all keys

One query function:
* query - requires one argument, a key, and returns a value

[fabric-example02 example](https://github.com/hyperledger/cello/blob/master/user-dashboard/src/config-template/cc_code/examples/fabric/chaincode_example02/chaincode_example02.go)

In this example, we use Init to configure the initial state of variables on the ledger. The example accepts 4 parameters as input and writes validated values on ledger.

* First account name
* Initial amount (integer) in first account
* Second account name
* Initial amount (integer) in second account

The following operations are available.

* Invoke - requires two arguments, a key and value, and stores them in the state
* Query - requires a key and removes it from the state

## Install/Deploy a Smart Contract

Click "..." of "fabric-chaincode_example02" smart contract, and select "Install". In the popup window select your chain where you want to install the smart contract.

![Install a smart contract](imgs/tutorial_install_contract.png)

After the smart contract installed, click "Instantiate" to deploy the smart contract. In the popup window select your chain where you want to initiate the smart contract. and click "New Parameter" to add four parameters, for example: "a", "1000", "b", "2000".

![Deploy a smart contract](imgs/tutorial_deploy_contract.png)

## Invoke/Query a Smart Contract

In the 'Invoke' page, you can perform the contract call.

* Smart Contrac: fabric-example02
* Funtion Name: invoke
* Parameters: a, b, 100
* Method: Invoke

![Invoke a smart contract](imgs/tutorial_invoke_contract.png)

Then we query the current value of a, should be 900 now

![Query a smart contract](imgs/tutorial_query_contract.png)


## Dashboard for operator

If you want to know more advanced operational skills, please continue to the [Operator Dashboard](./dashboard_operator.md).
Expand Down

0 comments on commit dbbed6e

Please sign in to comment.