BusinessNetworkDefinition (Common API)

Overview - Common API - Client API - Admin API - Runtime API

BusinessNetworkDefinition

A BusinessNetworkDefinition defines a set of Participants that exchange Assets by sending Transactions. This class manages the metadata and domain-specific types for the network as well as a set of executable scripts.

Applications should retrieve instances from BusinessNetworkDefinition#fromArchive

Details

  • Module common

See also

Method Summary

Name Returns Description
fromArchive Promise Create a BusinessNetworkDefinition from an archive
fromDirectory Promise Builds a BusinessNetworkDefintion from the contents of a directory.
getDescription String Returns the description for this business network
getFactory Factory Provides access to the Factory for this business network
getIdentifier String Returns the identifier for this business network The identifier is formed from a business network name + '@' + version
getIntrospector Introspector Provides access to the Introspector for this business network
getMetadata BusinessNetworkMetadata Returns the metadata for this business network
getName String Returns the name for this business network
getSerializer Serializer Provides access to the Serializer for this business network
getVersion String Returns the version for this business network
toArchive Buffer Store a BusinessNetworkDefinition as an archive

Method Details

getIdentifier

String getIdentifier( )

Returns the identifier for this business network The identifier is formed from a business network name + '@' + version. The version is a semver valid version string. It is not used by Hyperledger Composer and is not needed in any other API. It is for application developer information purposes onlyu

Returns

String - the identifier of this business network

See also

Parameters

No parameters

getMetadata

BusinessNetworkMetadata getMetadata( )

Returns the metadata for this business network

Returns

BusinessNetworkMetadata - the metadata for this business network

See also

Parameters

No parameters

getName

String getName( )

Returns the name for this business network

Returns

String - the name of this business network

See also

Parameters

No parameters

getVersion

String getVersion( )

Returns the version for this business network

Returns

String - the version of this business network. Use semver module to parse.

See also

Parameters

No parameters

getDescription

String getDescription( )

Returns the description for this business network

Returns

String - the description of this business network

See also

Parameters

No parameters

fromArchive

Promise fromArchive( Buffer buffer )

Create a BusinessNetworkDefinition from an archive.

Returns

Promise - a Promise to the instantiated business network

See also

Parameters

Name Type Mandatory Description
Buffer Buffer Yes the Buffer to a zip archive

toArchive

Buffer toArchive( [Object options] )

Store a BusinessNetworkDefinition as an archive.

Returns

Buffer - buffer - the zlib buffer

See also

Parameters

Name Type Mandatory Description
options Object Yes JSZip options

fromDirectory

Promise fromDirectory( String path, [Object options] )

Builds a BusinessNetworkDefintion from the contents of a directory. The directory must include a package.json in the root (used to specify the name, version and description of the business network). This method is designed to work with business networks that refer to external models using npm dependencies as well as business networks that statically package their model files.

If package.json contains a dependencies property then this method will search for model (CTO) files under the node_modules directory for each dependency that passes the options.dependencyGlob pattern.

If the network depends on an npm module its dependencies (transitive closure) will also be scanned for model (CTO) files.

The directory may optionally contain a README.md file which is accessible from the BusinessNetworkMetadata.getREADME method.

In addition all model files will be added that are not under node_modules and that pass the options.modelFileGlob pattern. By default you should put model files under a directory called 'models'.

All script (js) files will be added that are not under node_modules and that pass the options.scriptGlob pattern. By default you should put Javascript files under the 'lib' directory.

Returns

Promise - a Promise to the instantiated business network

See also

Parameters

Name Type Mandatory Description
path String Yes to a local directory
options Object Yes an optional set of options to configure the instance.

Sub-options

Name Type Mandatory Description
options.dependencyGlob Object Yes specify the glob pattern used to match the npm dependencies to process. Defaults to **
options.modelFileGlob boolean Yes specify the glob pattern used to match the model files to include. Defaults to \/models/\/*.cto
options.scriptGlob boolean Yes specify the glob pattern used to match the script files to include. Defaults to \/lib/\/*.js

getIntrospector

Introspector getIntrospector( )

Provides access to the Introspector for this business network. The Introspector is used to reflect on the types defined within this business network.

Returns

Introspector - the Introspector for this business network

See also

Parameters

No parameters

getFactory

Factory getFactory( )

Provides access to the Factory for this business network. The Factory is used to create the types defined in this business network.

Returns

Factory - the Factory for this business network

See also

Parameters

No parameters

getSerializer

Serializer getSerializer( )

Provides access to the Serializer for this business network. The Serializer is used to serialize instances of the types defined within this business network.

Returns

Serializer - the Serializer for this business network

See also

Parameters

No parameters

Inherited methods