Class: Gateway

fabric-network~ Gateway

The gateway peer provides the connection point for an application to access the Fabric network. It is instantiated using the default constructor. It can then be connected to a fabric network using the connect method by passing either a common connection profile definition or an existing Client object. Once connected, it can then access individual Network instances (channels) using the getNetwork method which in turn can access the smart contracts installed on a network and submit transactions to the ledger.

new Gateway()

Methods


<async> connect(config, options)

Connect to the Gateway with a connection profile or a prebuilt Client instance.
Parameters:
Name Type Description
config object | Client The configuration for this Gateway which can be:
  • A common connection profile JSON (Object)
  • A pre-configured client instance
options module:fabric-network.GatewayOptions specific options for creating this Gateway instance
Example
const gateway = new Gateway();
const wallet = await Wallets.newFileSystemWallet('./WALLETS/wallet');
const connectionProfileJson = (await fs.promises.readFile('network.json')).toString();
const connectionProfile = JSON.parse(connectionProfileJson);
await gateway.connect(connectionProfile, {
    identity: 'admin',
    wallet: wallet
});

disconnect()

Clean up and disconnect this Gateway connection in preparation for it to be discarded and garbage collected

getIdentity()

Get the identity associated with the gateway connection.
Returns:
An identity.
Type
module:fabric-network.Identity

<async> getNetwork(networkName)

Returns an object representing a network
Parameters:
Name Type Description
networkName string The name of the network (channel name)
Returns:
Type
module:fabric-network.Network

getOptions()

Returns the set of options associated with the Gateway connection
Returns:
The Gateway connection options
Type
module:fabric-network.Gateway~GatewayOptions