How to debug chaincode? LedgerError - ResourceNotFound

后端 未结 1 710
粉色の甜心
粉色の甜心 2021-01-16 17:24

I got this I believe pretty common error \"..LedgerError - ResourceNotFound: ledger: resource not found\" .

To make it simple, this is what I have:

相关标签:
1条回答
  • 2021-01-16 18:16

    The following command,

    CORE_CHAINCODE_ID_NAME=mycc CORE_PEER_ADDRESS=0.0.0.0:30303 ./chaincode_example02 
    

    doesn't deploy the chaincode, it simply start and register the chaincode with the validating peer.

    Once it is registered, you need todeploy and then invoke it before you can query.

    As described here,

    First, send a chaincode deploy transaction, only once, to the validating peer. The CLI connects to the validating peer using the properties defined in the core.yaml file. Note: The deploy transaction typically requires a path parameter to locate, build, and deploy the chaincode. However, because these instructions are specific to local development mode and the chaincode is deployed manually, the name parameter is used instead.

    peer chaincode deploy -n mycc -c '{"Function":"init", "Args": ["a","100", "b", "200"]}'
    

    Once it is deployed, you can invoke it as many times you want and then query the invoked transaction,

    To invoke,

    peer chaincode invoke -l golang -n mycc -c '{"Function": "invoke", "Args": ["a", "b", "10"]}'
    

    and to query,

    peer chaincode query -l golang -n mycc -c '{"Function": "query", "Args": ["b"]}'
    

    Also make sure that you have peer running in one terminal, running the chaincode in 2nd terminal, while deploying, invoking and querying transactions from the third one.

    0 讨论(0)
提交回复
热议问题