PAB (Plutus Application Backend) is an Off-Chain application for managing the state of Plutus contract instances.
PAB is a Cabal based Haskell project. Production builds are done with Nix using haskell.nix
$ cabal build
$ nix-build ../default.nix -A plutus.haskell.packages.plutus-pab
In order to use PAB several of its components need to be started. Furthermore the pab-client has to be started in order to access the web frontend. The required steps are described below, assuming nix has been installed.
First we build the startup scripts:
$ nix-build ../default.nix -A plutus-pab.demo-scripts
Next we start all required servers and install several contracts, in one terminal:
$ ./result/bin/pab-start-all-servers
Now we start an additional PAB connecting to the same node, in another terminal:
$ ./result/bin/pab-start-second-pab
Finally we can start the pab web frontend using tool provided by nix environment, in a third terminal:
$ nix-shell
$ cd ../plutus-pab-client
$ npm start
The client is now running at https://localhost:8009 -- See pab-demo-scripts.nix for details on the service invcation and contract installation.
Note: By default the frontend will forward requests to localhost:9080
- the first PAB instance. Connecting to the second
instance currently requires changing the proxy config in webpack.config.js. The second instance runs on port 9086 so the linked section in the config file would have to be
updated accordingly.
PAB contains several commands and services, which are outlined below.
- psgenerator
- migrate
- all-servers
- client-services
- wallet-server
- webserver
- node-server
- chain-index
- metadata-server
- signing-process
- default-logging-config
- process-outboxes
$ cabal run plutus-pab -- psgenerator
Generates the purescript bridge code.
$ cabal run plutus-pab -- migrate
Migrates the database in pab-core.db
to the current schema. The database contains the state for the eventful library. Please refer to the eventful docs for more information.
$ cabal run plutus-pab -- all-servers
Combines the execution of all core services and mocks in the appropriate order:
- mocks
- mock node
- mock wallet
- metadata
- signing-progress
- core services
- PAB webserver
- chain index
- process-outboxes
- plutus-pab.yaml
- sqlite database
- pab-client
$ cabal run plutus-pab -- client-services
Starts all mocks and core services except for the mock node service:
- mocks
- mock wallet
- metadata
- signing-progress
- core services
- PAB webserver
- chain index
- process-outboxes
- plutus-pab.yaml
- sqlite database
- pab-client
$ cabal run plutus-pab -- wallet-server
Plutus specific wallet implementation for managing user funds on the blockchain. Clients to this service are:
- PAB: adding funds to transactions & signing transactions
- user: making payments
- plutus-pab.yaml
- mock node
$ cabal run plutus-pab -- webserver
Serves the PAB user interface
- plutus-pab.yaml
- sqlite database
- pab-client
$ cabal run plutus-pab -- node-server
Mock-implementation of a Goguen node. Clients to this service are:
- chain-index
- webserver
- mock wallet
- plutus-pab.yaml
$ cabal run plutus-pab -- chain-index
Provides a consistent view of the current state of the blockchain including a key-value store for datum and script hashes. Clients to this service are:
- process-outboxes
- plutus-pab.yaml
- mock node
$ cabal run plutus-pab -- metadata-server
Key-Value store for user-defined data (mock implementation)
- plutus-pab.yaml
$ cabal run plutus-pab -- signing-process
Attaches signatures to transactions so that they can be sent to the node. Clients to this service are:
- PAB
- mock wallet
- plutus-pab.yaml
$ cabal run plutus-pab -- default-logging-config
Prints the default logging configuration to STDOUT
$ cabal run plutus-pab -- contracts process-outboxes
A service that regularly lokks at the contract instances requests and handles them
- plutus-pab.yaml
- sqlite database
- pab-client