0

I have set up a hyperledger fabric network shown below: org1: peer0.org1 org2: peer0.org2

chaincodes: 1:deed.js 2:bor.js

I have installed chaincode deed.js on org1 and org2 peers. I have installed bor.js only on org2 peer.

I have approved chaincode deed.js on org1 and org2 peers. I have committed chaincode bor.js on org1 and org2 peers.

I have invoked chaincode deed.js using org1 and org2 peers. I have invoked chaincode bor.js using org2 peer.

Querying deed.js works fine. But querying bor.js is throwing an error:

Error: endorsement failure during query. response: status:500 message:"make sure the chaincode bor has been successfully defined on channel mychannel and try again: chaincode definition for 'bor' exists, but chaincode is not installed" .

I know the error is due to the reason that I have not installed chaincode bor.js on org1, but my project is such that I must install bor.js smart contract only on org2 but not on org1.

My endorsement policy for applications section of configtx.yaml is defined below:

Application: &ApplicationDefaults

# Organizations is the list of orgs which are defined as participants on
# the application side of the network
Organizations:

# Policies defines the set of policies at this level of the config tree
# For Application policies, their canonical path is
#   /Channel/Application/<PolicyName>
Policies:
    Readers:
        Type: ImplicitMeta
        Rule: "ANY Readers"
    Writers:
        Type: ImplicitMeta
        Rule: "ANY Writers"
    Admins:
        Type: ImplicitMeta
        Rule: "MAJORITY Admins"
    LifecycleEndorsement:
        Type: ImplicitMeta
        Rule: "MAJORITY Endorsement"
    Endorsement:
        Type: ImplicitMeta
        Rule: "MAJORITY Endorsement"

Capabilities:
    <<: *ApplicationCapabilities

Is there any way to perform the query operation on bor.js chaincode without an error by installing bor.js only on org2 peer?.

4 Answers4

2

See the answer to this post: https://stackoverflow.com/a/73478194/9848275

It's likely due to a wrong --package-id.

Matias Salimbene
  • 510
  • 6
  • 19
  • 1
    In my case was wrong package id. I omitted 'sacc_1.0:' which isn't correct. It has to be like this -> echo $CC_PACKAGE_ID sacc_1.0:541acc921b0810039a2fc680c29117070d4ff89b76c7b96627c5ae984effade8 – Sabina Orazem Sep 10 '22 at 10:31
0

If I am correct you created one channel and you are trying to install 2 chain codes.

Check whether you have correctly installed your deed and bor chain codes on your resp peers. Check with these commands: peer chaincode list --installed peer chaincode list --instantiated -C yourchannelname If 2 chaincode exist then cross-check your CouchDB whether the data stores into a ledger or not. If data is storing in your CouchDB, then check your command and the peer on which you are querying or invoking. If any queries I can help you

  • Yeah. I created a channel and two peers one for each of two organizations. I need to install deed chaincode on org1 peer and org2 peer followed by bor chaincode only on org2 peer. Is it possible to do that way? Both org1 and org2 peers on same channel. I'm using fabric 2.0 version – Satish Chandra Medi May 03 '20 at 16:51
  • add one more consortium parameters(only ordg2) into your configtx.yaml. – adineshreddy1 May 03 '20 at 17:23
  • my profiles section looks like these TwoOrgsOrdererGenesis: <<: *ChannelDefaults Orderer: <<: *OrdererDefaults Organizations: - *OrdererOrg Capabilities: <<: *OrdererCapabilities Consortiums: SampleConsortium: Organizations: - *Org1 - *Org2 tell me where i need to do changes..I'm newbie so please help me out – Satish Chandra Medi May 04 '20 at 03:53
  • As of now, you have one consortium, create one more consortium SampleConsortium1: Organizations: - *Org2 . Then try – adineshreddy1 May 04 '20 at 04:05
  • after creating consortium is there any changes to be made in TwoOrgasChannel section: TwoOrgsChannel: Consortium: SampleConsortium <<: *ChannelDefaults Application: <<: *ApplicationDefaults Organizations: - *Org1 - *Org2 Capabilities: <<: *ApplicationCapabilities – Satish Chandra Medi May 04 '20 at 04:10
  • Did you checked either chaincode is installed or not by using commands ??? – adineshreddy1 May 04 '20 at 14:04
  • Yeah I have checked . I have installed deed chaincode on org1 and org2. bor chaincode on org2 – Satish Chandra Medi May 05 '20 at 03:35
0

Make sure your --package-id starts with the chaincode label.

e.g.,

chaincode label = sacc_1.0
export CHAINCODE_ID=sacc_1.0:541acc921b0810039a2fc680c29117070d4ff89b76c7b96627c5ae984effade8
Sabina Orazem
  • 477
  • 4
  • 12
0

Sometimes you need only to grant internet access to your peer as Chaincode looks for Internet to install its dependencies.

Badr Bellaj
  • 11,560
  • 2
  • 43
  • 44