1

https://github.com/hyperledger/fabric-samples/blob/main/asset-transfer-basic/chaincode-go/chaincode/smartcontract.go

I installed the above contract on my blockchain network on Kaleido platform. I created an asset like this :

{
"headers": {
    "type": "SendTransaction",
    "signer": "user2",
    "channel": "default-channel",
    "chaincode": "asset_transfer"
  },
  "func": "CreateAsset",
  "args": [
    "asset5","whitee","10","Tom","12300"
  ],
  "init": false
}

The response was positive and I assume the asset was created with the given data :

{
    "headers": {
        "id": "4493af12-7483-49cc-60d4-ad621dc451b3",
        "type": "TransactionSuccess",
        "timeReceived": "2022-09-28T10:31:03.681639234Z",
        "timeElapsed": 0.362129531,
        "requestOffset": "",
        "requestId": ""
    },
    "blockNumber": 86,
    "signerMSP": "u0fm8amwnc",
    "signer": "user2",
    "transactionID": "fbc993a6ce104d4211adb36fcb391e53b01e1944b230613b44bdff38c91f8e21",
    "status": "VALID"
}

Now I want to read the data on asset5, i.e. I want to get "whitee","10","Tom","12300" this data from the blockchain. I tried :

{
  "headers": {
    "type": "SendTransaction",
    "signer": "user2",
    "channel": "default-channel",
    "chaincode": "asset_transfer"
  },
  "func": "ReadAsset",
  "args": [
    "asset5"
  ],
  "init": false
}

I got a success response but not the data I need :

{
    "headers": {
        "id": "344bfc60-8950-42ec-6ec8-43689b90a881",
        "type": "TransactionSuccess",
        "timeReceived": "2022-09-28T11:12:26.766305515Z",
        "timeElapsed": 0.290215954,
        "requestOffset": "",
        "requestId": ""
    },
    "blockNumber": 89,
    "signerMSP": "u0fm8amwnc",
    "signer": "user2",
    "transactionID": "413c2e8a584f606bb2d31d4451d5bf90ed00c8cb1c4c6c887dca934bb1400204",
    "status": "VALID"
}

https://youtu.be/bwRevURQve0?t=3313 This guy gets his data doing the same thing.

Am I missing something?

Sunil Kumar
  • 6,112
  • 6
  • 36
  • 40

1 Answers1

0

I was sending these requests to /transactions end-point of fabconnect.

I should send POST requests to /query in order to read data from there. For example :

{
  "headers": {
    "signer": "user2",
    "channel": "default-channel",
    "chaincode": "asset_transfer"
  },
  "func": "ReadAsset",
  "args": ["asset4"],
  "strongread": true
}
Sunil Kumar
  • 6,112
  • 6
  • 36
  • 40