Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot instantiate a chaincode - AttributeError: 'NoneType' object has no attribute 'send_instantiate_proposal' #189

Open
IIRobotNinjaII opened this issue Apr 22, 2024 · 0 comments

Comments

@IIRobotNinjaII
Copy link

IIRobotNinjaII commented Apr 22, 2024

import asyncio
from hfc.fabric import Client

loop = asyncio.get_event_loop()
cli = Client(net_profile="test/fixtures/network.json")
org1_admin = cli.get_user('org1.example.com', 'Admin')

import os
gopath_bak = os.environ.get('GOPATH', '/usr/local/go')
gopath = os.path.normpath(os.path.join(
                      os.path.dirname(os.path.realpath('__file__')),
                      'test/fixtures/chaincode'
                     ))
os.environ['GOPATH'] = os.path.abspath(gopath)

#The response should be true if succeed
responses = loop.run_until_complete(cli.chaincode_install(
               requestor=org1_admin,
               peers=['peer0.org1.example.com',
                      'peer1.org1.example.com'],
               cc_path='github.com/example_cc',
               cc_name='example_cc',
               cc_version='v1.0'
               ))
print(responses,"Chaincode Installed")
Instantiate Chaincode in Channel, the response should be true if succeed
args = ['a', '200', 'b', '300']

# policy, see https://hyperledger-fabric.readthedocs.io/en/release-1.4/endorsement-policies.html
policy = {
    'identities': [
        {'role': {'name': 'member', 'mspId': 'Org1MSP'}},
    ],
    'policy': {
        '1-of': [
            {'signed-by': 0},
        ]
    }
}
response = loop.run_until_complete(cli.chaincode_instantiate(
               requestor=org1_admin,
               channel_name='businesschannel',
               peers=['peer0.org1.example.com'],
               args=args,
               cc_name='example_cc',
               cc_version='v1.0',               
               cc_endorsement_policy=policy, # optional, but recommended
               collections_config=None, # optional, for private data policy
               transient_map=None, # optional, for private data
               wait_for_event=True # optional, for being sure chaincode is instantiated
               ))
print('Chainode Instantiated Response : ',response)

Get the following error

  File "trial.py", line 97, in <module>
    wait_for_event=True # optional, for being sure chaincode is instantiated
  File "/home/antony/.pyenv/versions/3.7-dev/lib/python3.7/asyncio/base_events.py", line 587, in run_until_complete
    return future.result()
  File "/home/antony/abe/fabric-sdk-py/hfc/fabric/client.py", line 1214, in chaincode_instantiate
    cc_type=cc_type)
  File "/home/antony/abe/fabric-sdk-py/hfc/fabric/chaincode.py", line 134, in instantiate
    cc_type=cc_type)
  File "/home/antony/abe/fabric-sdk-py/hfc/fabric/chaincode.py", line 233, in _instantiate_or_upgrade
    tx_context_dep, target_peers, channel)
  File "/home/antony/abe/fabric-sdk-py/hfc/fabric/chaincode.py", line 53, in send_instantiate_proposal
    return channel.send_instantiate_proposal(tx_context, peers)
AttributeError: 'NoneType' object has no attribute 'send_instantiate_proposal'
@IIRobotNinjaII IIRobotNinjaII changed the title Cannot instantiate a chaincode Cannot instantiate a chaincode - AttributeError: 'NoneType' object has no attribute 'send_instantiate_proposal' Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant