Adding participants
A participant can be added to a participant registry using either the API or the command line.
Before you start
Before you follow these steps, you must have modeled a participant in a Business Network Definition and deployed it as a Business Network.
The procedure below shows an example using the following model of a participant from the Digital Property sample Business Network Definition: digitalproperty-network
Please note: If you are adding the participant using the composer participant add
command, ensure that the JSON representation of the participant is wrapped in single quotes.
namespace net.biz.digitalPropertyNetwork
participant Person identified by personId {
o String personId
o String firstName
o String lastName
}
Procedure
Add the participant to a participant registry
- JavaScript API
const BusinessNetworkConnection = require('composer-client').BusinessNetworkConnection; let businessNetworkConnection = new BusinessNetworkConnection(); return businessNetworkConnection.connect('admin@digitalPropertyNetwork') .then(() => { return businessNetworkConnection.getParticipantRegistry('net.biz.digitalPropertyNetwork'); }) .then((participantRegistry) => { let factory = businessNetworkConnection.getFactory(); let participant = factory.newResource('net.biz.digitalPropertyNetwork', 'Person', 'mae@biznet.org'); participant.firstName = 'Mae'; participant.lastName = 'Smith'; return participantRegistry.add(participant); }) .then(() => { return businessNetworkConnection.disconnect(); }) .catch((error) => { console.error(error); process.exit(1); });
Command line
composer participant add -c admin@network -d '{"$class":"net.biz.digitalPropertyNetwork.Person","personId":"mae@biznet.org","firstName":"Mae","lastName":"Smith"}'