Verify World State in CouchDB

Q

How to Verify World State in CouchDB container?

✍: FYIcenter.com

A

Since peer0.org1.example.com uses the couchdb container to store the world state, you can check the current states of all assets managed by the chaincode.

1. Get database name for the chaincode "fabcar":

$ curl http://localhost:5984/_all_dbs
["_replicator","_users","mychannel_","mychannel_fabcar","mychannel_lscc"]

2. List all assets (called documents in CouchDB) of "mychannel_fabcar":

$ curl http://localhost:5984/mychannel_fabcar/_all_docs
{"total_rows":10,"offset":0,"rows":[
{"id":"CAR0","key":"CAR0","value":{"rev":"2-470e6972dfda1d4e4d5451f351e0a148"}},
{"id":"CAR1","key":"CAR1","value":{"rev":"2-c3dc6200995111fd68a1b31fef101407"}},
{"id":"CAR2","key":"CAR2","value":{"rev":"2-a6152f6417c7806ca9b8cb65df610408"}},
{"id":"CAR3","key":"CAR3","value":{"rev":"2-2284005a15045726607cd868bded26e7"}},
{"id":"CAR4","key":"CAR4","value":{"rev":"2-a76d55af36a1c1d876db82bac10a5193"}},
{"id":"CAR5","key":"CAR5","value":{"rev":"2-34515cfea948a09c67f5fee6fd286ff6"}},
{"id":"CAR6","key":"CAR6","value":{"rev":"2-d52f643d550d6b6b1126c60fa71386c3"}},
{"id":"CAR7","key":"CAR7","value":{"rev":"2-bf0c75774546d03bba5e3ada27be3afe"}},
{"id":"CAR8","key":"CAR8","value":{"rev":"2-a953576d2447d0bc4c6534a0cfc1aeca"}},
{"id":"CAR9","key":"CAR9","value":{"rev":"2-06ab42f3f3274b05144522b717c04e56"}}
]}

3. Get the content of the last asset, CAR9:

$ curl http://localhost:5984/mychannel_fabcar/CAR9
{   "_id": "CAR9",
    "_rev": "2-06ab42f3f3274b05144522b717c04e56",
    "colour": "brown",
    "make": "Holden",
    "model": "Barina",
    "owner": "Shotaro",
    "~version": "\u0000CgMBAwA="
}

 

Verify Blockchain on the Channel

Interact with "fabcar" Chaincode on CLI

WYFA (Writing Your First Application)

⇑⇑ Hyperledger Tutorials

2020-02-20, 435👍, 0💬