Created
April 9, 2018 14:59
-
-
Save rdemorais/d23124955371ad971ee176929c046659 to your computer and use it in GitHub Desktop.
Hyperlegder Fabric - Composer - Create participant
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, '[email protected]'); | |
await producerRegistry.add(alice); | |
let identity = await businessNetworkConnection.issueIdentity(producerNS + '#[email protected]', '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(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment