Skip to content

Commit

Permalink
Update docs to replace fabcar references with basic asset transfer
Browse files Browse the repository at this point in the history
sample

Signed-off-by: Tiffany Harris <tiffany.harris@ibm.com>
(cherry picked from commit 87adee2)
  • Loading branch information
stephyee authored and denyeart committed Aug 20, 2020
1 parent 1450e3c commit 7d6bb0f
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 42 deletions.
2 changes: 1 addition & 1 deletion docs/source/chaincode_lifecycle.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ automatically create a file in this format.
chaincode language, code path, and package label. You can see an example of
a metadata file below:
```
{"Path":"fabric-samples/chaincode/fabcar/go","Type":"golang","Label":"fabcarv1"}
{"Path":"fabric-samples/asset-transfer-basic/chaincode-go","Type":"golang","Label":"basicv1"}
```

![Packaging the chaincode](lifecycle/Lifecycle-package.png)
Expand Down
36 changes: 22 additions & 14 deletions docs/source/create_channel/create_channel.md
Original file line number Diff line number Diff line change
Expand Up @@ -362,24 +362,32 @@ Blockchain info: {"height":3,"currentBlockHash":"eBpwWKTNUgnXGpaY2ojF4xeP3bWdjlP
## Deploy a chaincode to the new channel
We can confirm that the channel was created successfully by deploying a chaincode to the channel. We can use the `network.sh` script to deploy the Fabcar chaincode to any test network channel. Deploy a chaincode to our new channel using the following command:
We can confirm that the channel was created successfully by deploying a chaincode to the channel. We can use the `network.sh` script to deploy the Basic asset transfer chaincode to any test network channel. Deploy a chaincode to our new channel using the following command:
```
./network.sh deployCC -c channel1
./network.sh deployCC --ccn basic -c channel1 --cci InitLedger
```
After you run the command, you should see the chaincode being deployed to the channel in your logs. The chaincode is invoked to add data to the channel ledger and then queried.
After you run the command, you should see the chaincode being deployed to the channel in your logs. The chaincode is invoked to add data to the channel ledger.
```
2020-08-18 09:23:53.741 EDT [chaincodeCmd] chaincodeInvokeOrQuery -> INFO 001 Chaincode invoke successful. result: status:200
===================== Invoke transaction successful on peer0.org1 peer0.org2 on channel 'channel1' =====================
```
We can confirm the data was added with the below query.
```
peer chaincode query -C channel1 -n basic -c '{"Args":["getAllAssets"]}'
```
After you run the query, you should see the assets that were added to the channel ledger.
```
[{"Key":"CAR0","Record":{"make":"Toyota","model":"Prius","colour":"blue","owner":"Tomoko"}},
{"Key":"CAR1","Record":{"make":"Ford","model":"Mustang","colour":"red","owner":"Brad"}},
{"Key":"CAR2","Record":{"make":"Hyundai","model":"Tucson","colour":"green","owner":"Jin Soo"}},
{"Key":"CAR3","Record":{"make":"Volkswagen","model":"Passat","colour":"yellow","owner":"Max"}},
{"Key":"CAR4","Record":{"make":"Tesla","model":"S","colour":"black","owner":"Adriana"}},
{"Key":"CAR5","Record":{"make":"Peugeot","model":"205","colour":"purple","owner":"Michel"}},
{"Key":"CAR6","Record":{"make":"Chery","model":"S22L","colour":"white","owner":"Aarav"}},
{"Key":"CAR7","Record":{"make":"Fiat","model":"Punto","colour":"violet","owner":"Pari"}},
{"Key":"CAR8","Record":{"make":"Tata","model":"Nano","colour":"indigo","owner":"Valeria"}},
{"Key":"CAR9","Record":{"make":"Holden","model":"Barina","colour":"brown","owner":"Shotaro"}}]
===================== Query successful on peer0.org1 on channel 'channel1' =====================
[{"ID":"asset1","color":"blue","size":5,"owner":"Tomoko","appraisedValue":300},
{"ID":"asset2","color":"red","size":5,"owner":"Brad","appraisedValue":400},
{"ID":"asset3","color":"green","size":10,"owner":"Jin Soo","appraisedValue":500},
{"ID":"asset4","color":"yellow","size":10,"owner":"Max","appraisedValue":600},
{"ID":"asset5","color":"black","size":15,"owner":"Adriana","appraisedValue":700},
{"ID":"asset6","color":"white","size":15,"owner":"Michel","appraisedValue":800}]
```
<!--- Licensed under Creative Commons Attribution 4.0 International License
Expand Down
Binary file modified docs/source/ledger/ledger.diagram.6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 11 additions & 11 deletions docs/source/ledger/ledger.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ In this topic, we're going to cover:
* [How blocks are stored in a blockchain](#blocks)
* [Transactions](#transactions)
* [World state database options](#world-state-database-options)
* [The **Fabcar** example ledger](#example-ledger-fabcar)
* [The **Basic** example ledger](#example-ledger-basic-asset-transfer)
* [Ledgers and namespaces](#namespaces)
* [Ledgers and channels](#channels)

Expand Down Expand Up @@ -330,23 +330,23 @@ graph store, or a temporal database. This provides great flexibility in the
types of ledger states that can be efficiently accessed, allowing Hyperledger
Fabric to address many different types of problems.

## Example Ledger: fabcar
## Example Ledger: Basic Asset Transfer

As we end this topic on the ledger, let's have a look at a sample ledger. If
you've run the [fabcar sample application](../write_first_app.html), then you've
you've run the [basic asset transfer sample application](../write_first_app.html), then you've
created this ledger.

The fabcar sample app creates a set of 10 cars each with a unique identity; a
different color, make, model and owner. Here's what the ledger looks like after
the first four cars have been created.
The basic sample app creates a set of 6 assets each with a unique identity; a
different color, size, owner, and appraised value. Here's what the ledger looks like after
the first four assets have been created.

![ledger.transaction](./ledger.diagram.6.png) *The ledger, L, comprises a world
state, W and a blockchain, B. W contains four states with keys: CAR0, CAR1, CAR2
and CAR3. B contains two blocks, 0 and 1. Block 1 contains four transactions:
state, W and a blockchain, B. W contains four states with keys: ASSET1, ASSET2, ASSET3,
and ASSET4. B contains two blocks, 0 and 1. Block 1 contains four transactions:
T1, T2, T3, T4.*

We can see that the world state contains states that correspond to CAR0, CAR1,
CAR2 and CAR3. CAR0 has a value which indicates that it is a blue Toyota Prius,
We can see that the world state contains states that correspond to ASSET1,
ASSET2, ASSET3, and ASSET4. ASSET1 has a value which indicates that it is a blue with size 5,
currently owned by Tomoko, and we can see similar states and values for the
other cars. Moreover, we can see that all car states are at version number 0,
indicating that this is their starting version number -- they have not been
Expand All @@ -355,7 +355,7 @@ updated since they were created.
We can also see that the blockchain contains two blocks. Block 0 is the genesis
block, though it does not contain any transactions that relate to cars. Block 1
however, contains transactions T1, T2, T3, T4 and these correspond to
transactions that created the initial states for CAR0 to CAR3 in the world
transactions that created the initial states for ASSET1 to ASSET4 in the world
state. We can see that block 1 is linked to block 0.

We have not shown the other fields in the blocks or transactions, specifically
Expand Down
30 changes: 14 additions & 16 deletions docs/source/smartcontract/smartcontract.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,26 +112,24 @@ organizations in that network. It means that only administrators need to worry
about chaincode; everyone else can think in terms of smart contracts.

At the heart of a smart contract is a set of `transaction` definitions. For
example, look at fabcar.js
[here](https://github.com/hyperledger/fabric-samples/blob/{BRANCH}/chaincode/fabcar/javascript/lib/fabcar.js#L93),
where you can see a smart contract transaction that creates a new car:
example, look at assetTransfer.js
[here](https://github.com/hyperledger/fabric-samples/blob/{BRANCH}/asset-transfer-basic/chaincode-javascript/lib/assetTransfer.js#L67),
where you can see a smart contract transaction that creates a new asset:

```javascript
async createCar(ctx, carNumber, make, model, color, owner) {

const car = {
color,
docType: 'car',
make,
model,
owner,
};

await ctx.stub.putState(carNumber, Buffer.from(JSON.stringify(car)));
}
async CreateAsset(ctx, id, color, size, owner, appraisedValue) {
const asset = {
ID: id,
Color: color,
Size: size,
Owner: owner,
AppraisedValue: appraisedValue,
};
return ctx.stub.putState(id, Buffer.from(JSON.stringify(asset)));
}
```

You can learn more about the **Fabcar** smart contract in the [Writing your
You can learn more about the **Basic** smart contract in the [Writing your
first application](../write_first_app.html) tutorial.

A smart contract can describe an almost infinite array of business use cases
Expand Down

0 comments on commit 7d6bb0f

Please sign in to comment.