Пример #1
0
        print("Join channel failed")
        exit(-1)

    # Install Chaincode to Peers
    # This is only needed if to use the example chaincode inside sdk
    gopath_bak = os.environ.get('GOPATH', '')
    gopath = os.path.normpath(os.path.join(
        os.path.dirname(os.path.realpath('__file__')),
        CHAINCODE_PATH
    ))
    os.environ['GOPATH'] = os.path.abspath(gopath)

    # The response should be true if succeed
    response = loop.run_until_complete(cli.chaincode_install(
        requestor=org1_admin,
        peers=['peer0.org1.example.com', 'peer1.org1.example.com'],
        cc_path=CC_PATH,
        cc_name=CC_NAME,
        cc_version=CC_VERSION))

    # Instantiate Chaincode in Channel, the response should be true if succeed
    args = ['a', '200', 'b', '300']
    response = loop.run_until_complete(cli.chaincode_instantiate(
        requestor=org1_admin,
        channel_name='businesschannel',
        peers=['peer0.org1.example.com'],
        args=args,
        cc_name=CC_NAME,
        cc_version=CC_VERSION))
    if response:
        print("Instantiate chaincode successful")
    else:
Пример #2
0
        print("Join channel failed")
        exit(-1)

    # Install Chaincode to Peers
    # This is only needed if to use the example chaincode inside sdk
    gopath_bak = os.environ.get('GOPATH', '')
    gopath = os.path.normpath(
        os.path.join(os.path.dirname(os.path.realpath('__file__')),
                     CHAINCODE_PATH))
    os.environ['GOPATH'] = os.path.abspath(gopath)

    # The response should be true if succeed
    response = 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'))
    if response:
        print("Install chaincode successful")
    else:
        print("Install chaincode failed")
        exit(-1)

    # Instantiate Chaincode in Channel, the response should be true if succeed
    args = ['a', '200', 'b', '300']
    response = loop.run_until_complete(
        cli.chaincode_instantiate(requestor=org1_admin,
                                  channel_name='businesschannel',
                                  peers=['peer0.org1.example.com'],
                                  args=args,
Пример #3
0
import asyncio
from hfc.fabric import Client

loop = asyncio.get_event_loop()

cli = Client(
    net_profile=
    "/home/Adel/Desktop/PFE/Two_Chain_Network_Template/pfe-project/sdk/MyNetwork.json"
)
org1_admin = cli.get_user('org1.dz', 'Admin')

org1_admin = cli.get_user(org_name='org1.dz', name='Admin')
# Make the client know there is a channel in the network
cli.new_channel('firstchannel')

# Install Example Chaincode to Peers
# The response should be true if succeed
responses = loop.run_until_complete(
    cli.chaincode_install(requestor=org1_admin,
                          peers=[
                              'peer0.org1.dz', 'peer1.org1.dz',
                              'peer2.org1.dz', 'peer3.org1.dz'
                          ],
                          cc_path='chaincodes',
                          cc_name='first_chaincode',
                          cc_version='v1.0'))

print(responses)
# Install Example Chaincode to Peers
# GOPATH setting is only needed to use the example chaincode inside sdk
gopath_bak = os.environ.get('GOPATH', '')
gopath = os.path.normpath(
    os.path.join(os.path.dirname(os.path.realpath('__file__')),
                 '../chaincode'))
os.environ['GOPATH'] = os.path.abspath(gopath)

print("gopath", 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/registration_cc_v2',
        cc_name='registration_cc_v2',
        cc_version='v1.0'))

# The response should be true if succeed
responses = loop.run_until_complete(
    cli.chaincode_install(
        requestor=org2_admin,
        peers=['peer0.org2.example.com', 'peer1.org2.example.com'],
        cc_path='github.com/registration_cc_v2',
        cc_name='registration_cc_v2',
        cc_version='v1.0'))

# Instantiate Chaincode in Channel, the response should be true if succeed
args = ["Qmeq4hW6kK2abdbpE2vc7FjSX1xmn1tphg2hGrHFGxqk16"]
Пример #5
0
import asyncio
from hfc.fabric import Client

loop = asyncio.get_event_loop()

cli = Client(net_profile="/home/Adel/Desktop/PFE/Two_Chain_Network_Template/pfe-project/sdk/MyNetwork.json")
org1_admin = cli.get_user('org1.dz', 'Admin')



org1_admin = cli.get_user(org_name='org1.dz', name='Admin')
# Make the client know there is a channel in the network
cli.new_channel('secondchannel')

# Install Example Chaincode to Peers
# The response should be true if succeed
responses = loop.run_until_complete(cli.chaincode_install(
                   requestor=org1_admin,
                   peers=['peer0.org1.dz',
                          'peer1.org1.dz',
                          'peer2.org1.dz',
                          'peer3.org1.dz'],
                   cc_path='chaincodes',
                   cc_name='test_cc2',
                   cc_version='v1.0'
                             ))

print(responses)
Пример #6
0
    ))

responses = loop.run_until_complete(
    cli.channel_join(
        requestor=org1_admin,
        channel_name="secondchannel",
        peers=["peer0.org1.dz", "peer1.org1.dz", "peer2.org1.dz"],
        orderer="orderer1.org1.dz",
    ))

# The response should be true if succeed
responses = loop.run_until_complete(
    cli.chaincode_install(
        requestor=org1_admin,
        peers=["peer0.org1.dz", "peer1.org1.dz", "peer2.org1.dz"],
        cc_path="firstcc",
        cc_name="firstcc",
        cc_version="v1.0",
    ))
responses = loop.run_until_complete(
    cli.chaincode_install(
        requestor=org1_admin,
        peers=["peer0.org1.dz", "peer1.org1.dz", "peer2.org1.dz"],
        cc_path="secondcc",
        cc_name="secondcc",
        cc_version="v1.0",
    ))

########################

cli.new_channel("firstchannel")
Пример #7
0
# Install Example Chaincode to Peers
# GOPATH setting is only needed to use the example chaincode inside sdk
gopath_bak = os.environ.get('GOPATH', '')
gopath = os.path.normpath(os.path.join(
    os.path.dirname(os.path.realpath('__file__')),
    '../chaincode'
))
os.environ['GOPATH'] = os.path.abspath(gopath)

print("gopath", gopath)

# The response should be true if succeed
responses = loop.run_until_complete(cli.chaincode_install(
    requestor=org1_admin,
    peers=['peer0.org1.example.com'],
    cc_path='github.com/base_cc',
    cc_name='base_cc',
    cc_version='v1.0'
))

# Instantiate Chaincode in Channel, the response should be true if succeed
args = ['b2f79319-c6a8-4d91-ab05-5761656e8e96', 'YsYWKEJ3va5Cq0khPokYNQ6DXvUfxB35zYtzeYIcf/Y=']

# 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},