Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- async function teste() {
- var namespace = 'br.com.synapsetec';
- var producerType = 'Producer';
- var producerNS = namespace + '.' + producerType;
- const AdminConnection = require('composer-admin').AdminConnection;
- const BusinessNetworkConnection = require('composer-client').BusinessNetworkConnection;
- const cardStore = require('composer-common').NetworkCardStoreManager.getCardStore();
- const { IdCard } = require('composer-common');
- businessNetworkConnection = new BusinessNetworkConnection({ cardStore: cardStore });
- await businessNetworkConnection.connect('admin@my-network');
- factory = businessNetworkConnection.getBusinessNetwork().getFactory();
- const producerRegistry = await businessNetworkConnection.getParticipantRegistry(producerNS);
- const alice = factory.newResource(namespace, producerType, 'alice3@email.com');
- await producerRegistry.add(alice);
- let identity = await businessNetworkConnection.issueIdentity(producerNS + '#alice3@email.com', 'alice3');
- const connectionProfile = {
- "name": "my-network",
- "x-type": "hlfv1"
- };
- adminConnection = new AdminConnection({ cardStore: cardStore });
- const metadata = {
- userName: identity.userID,
- version: 1,
- enrollmentSecret: identity.userSecret,
- businessNetwork: 'my-network'
- };
- const card = new IdCard(metadata, connectionProfile);
- await adminConnection.importCard('alice@my-network', card);
- console.log('ok');
- }
- teste();
Add Comment
Please, Sign In to add comment