Example #1
0
    cli = Client(net_profile=CONNECTION_PROFILE_PATH)

    print(cli.organizations)  # orgs in the network
    print(cli.peers)  # peers in the network
    print(cli.orderers)  # orderers in the network
    print(cli.CAs)  # ca nodes in the network, TODO

    # get the admin user from local path
    org1_admin = cli.get_user(org_name='org1.example.com', name='Admin')

    # Create a New Channel, the response should be true if succeed
    response = loop.run_until_complete(
        cli.channel_create(orderer='orderer.example.com',
                           channel_name='businesschannel',
                           requestor=org1_admin,
                           config_yaml=CONFIG_YAML_PATH,
                           channel_profile='TwoOrgsChannel'))
    if response:
        print("Create channel successful")
    else:
        print("Create channel failed")
        print(response)
        exit(-1)

    # Join Peers into Channel, the response should be true if succeed
    response = loop.run_until_complete(
        cli.channel_join(
            requestor=org1_admin,
            channel_name='businesschannel',
            peers=['peer0.org1.example.com', 'peer1.org1.example.com'],
Example #2
0
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(org_name='org1.dz', name='Admin')

# Create a New Channel, the response should be true if succeed
response = loop.run_until_complete(
    cli.channel_create(
        orderer='orderer.org1.dz',
        channel_name='firstchannel',
        requestor=org1_admin,
        config_yaml=
        '/home/Adel/Desktop/PFE/Two_Chain_Network_Template/pfe-project',
        channel_profile='firstchannel'))

print(response == True)

# Join Peers into Channel, the response should be true if succeed

responses = loop.run_until_complete(
    cli.channel_join(requestor=org1_admin,
                     channel_name='firstchannel',
                     peers=[
                         'peer0.org1.dz', 'peer1.org1.dz', 'peer2.org1.dz',
                         'peer3.org1.dz'
                     ],
Example #3
0
    "policy": {
        "1-of": [{
            "signed-by": 0
        }]
    },
}

cli.new_channel("firstchannel")
cli.new_channel("secondchannel")

# Creating the two channels
response = loop.run_until_complete(
    cli.channel_create(
        orderer="orderer1.org1.dz",
        channel_name="firstchannel",
        requestor=org1_admin,
        config_yaml="/*****************YOUR_PATH*****************/",
        channel_profile="firstchannel",
    ))

response = loop.run_until_complete(
    cli.channel_create(
        orderer="orderer1.org1.dz",
        channel_name="secondchannel",
        requestor=org1_admin,
        config_yaml="/*****************YOUR_PATH*****************/",
        channel_profile="secondchannel",
    ))

# Join Peers into Channel, the response should be true if succeed
Example #4
0
import asyncio
from hfc.fabric import Client
from hfc.fabric_network import wallet
from hfc.fabric_ca.caservice import ca_service

loop = asyncio.get_event_loop()

cli = Client(net_profile="../connection-profile/network.json")
org1_admin = cli.get_user(org_name='org1.example.com', name='Admin')
org2_admin = cli.get_user(org_name='org2.example.com', name='Admin')

# Create a New Channel, the response should be true if succeed
response = loop.run_until_complete(
    cli.channel_create(orderer='orderer.example.com',
                       channel_name='channel1',
                       requestor=org1_admin,
                       config_yaml='../crypto-material/config_solo/',
                       channel_profile='TwoOrgsChannel'))
print(response == True)

# Join Peers into Channel, the response should be true if succeed
responses = loop.run_until_complete(
    cli.channel_join(requestor=org1_admin,
                     channel_name='channel1',
                     peers=['peer0.org1.example.com'],
                     orderer='orderer.example.com'))
print(len(responses) == 1)

# For operations on peers from org2.example.com, org2_admin is required as requestor
responses = loop.run_until_complete(
    cli.channel_join(requestor=org2_admin,
Example #5
0
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(org_name='org1.example.com', name='Admin')

# Create a New Channel, the response should be true if succeed
response = loop.run_until_complete(
    cli.channel_create(orderer='orderer.example.com',
                       channel_name='businesschannel',
                       requestor=org1_admin,
                       config_yaml='test/fixtures/e2e_cli/',
                       channel_profile='TwoOrgsChannel'))
print(response == True)