# Deploy/run dApp

## Step 1. Start Hyperledger network and deploy the chaincode

Switch to project folder

```
$ cd hyperledger-supply-chain
```

Switch to the network folder

```
cd network/fabric-network
```

Start network

```
./network.sh up createChannel -ca -s couchdb
```

Deploy the chaincode

```
./network.sh deployCC -ccn supplychain -ccp ../../chaincode -ccl typescript
```

## Step 2. Generate user certificates

Switch to the following folder:

```
cd hyperledger-supply-chain/web-app/server/fabric
```

Remove previously generated certificates

```
rm -R wallet/*
```

Run the following commands in sequence to generate identity certificates for admin and manager/employee users.

```
node enrollAdmin.js
node registerUsers.js
```

## Step 3. Run API

Switch to the web API folder

```
cd hyperledger-supply-chain/web-app/server
```

Start the server

```
node app
```

## How to stop network

Run the following script from the network folder mentioned above

```
./network down
```
