[英]how to read asset on hyperledger fabric?
https://github.com/hyperledger/fabric-samples/blob/main/asset-transfer-basic/chaincode-go/chaincode/smartcontract.go 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.我在 Kaleido 平台上的 blockchain.network 上安装了上述合约。 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, ie I want to get "whitee","10","Tom","12300" this data from the blockchain.现在我想读取 asset5 上的数据,即我想从区块链中获取“whitee”、“10”、“Tom”、“12300”这个数据。 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. https://youtu.be/bwRevURQve0?t=3313这家伙得到他的数据做同样的事情。
Am I missing something?我错过了什么吗?
I was sending these requests to /transactions end-point of fabconnect.我将这些请求发送到 fabconnect 的 /transactions 端点。
I should send POST requests to /query in order to read data from there.我应该将 POST 请求发送到 /query 以便从那里读取数据。 For example:例如:
{
"headers": {
"signer": "user2",
"channel": "default-channel",
"chaincode": "asset_transfer"
},
"func": "ReadAsset",
"args": ["asset4"],
"strongread": true
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.