This document describes how to prepare hosted PAB deployment from scratch that can operate on Alonzo purple testnet.
The following required to be run on host machine to use PAB with contracts in hosted scenario on testnet (for 2020-11-05 PAB Release):
- Cardano node connected to Alonzo testnet
- cardano wallet connected to node
- chain-index connected to node
- PAB executable connected to node, cardano-wallet and chain-index
Note: we are using somewhat more involved setup with a bit custom docker compose, and wallet and chain-index being built from sources, but there is ready to go node+wallet docker solution available
This section describes how to start Cardano node connected to Alonzo testnet using Docker (and docker-compose).
Use official cardano node image to run contaner with docker:
docker run --rm \
-e NETWORK=testnet \
-v "$PWD"/socket:/ipc \
-v "$PWD"/data:/data \
inputoutput/cardano-node
or for specific node version
docker run --rm \
-e NETWORK=testnet \
-v "$PWD"/socket:/ipc \
-v "$PWD"/data:/data \
inputoutput/cardano-node:1.31.0
It will take some time for node to sync. Sync status could be checked with cardano-cli
tool using tip
query, e.g.:
cardano-cli query tip --testnet-magic 1097911063
Tip of synced node looks something like this (note syncProgress
):
{
"epoch": 1005,
"hash": "162d6541cc5aa6b0e098add8fa08a94660a08b9463c0a86fcf84661b5f63375f",
"slot": 7232440,
"block": 322985,
"era": "Alonzo",
"syncProgress": "100.00"
}
ℹ️ GtiHub repo
Install cardano wallet and start it.
cardano-wallet serve \
--node-socket $CARDANO_NODE_SOCKET_PATH \
--database /path/to/wallet/database \
--testnet /path/to/node/configuration/config/alonzo-purple-byron-genesis.json \
--listen-address 0.0.0.0 \
--port 8090
Create wallet for tests (which PAB will use).
We are usually using CLI to generate recovery-phrase
and then create wallet from-recovery-phrase
.
Get some tAda on that wallet (as one possible option: https://testnets.cardano.org/en/testnets/cardano/tools/faucet/)
We building chain-index
from sources from desired commit of plutus-apps and staring it, like:
Fast way with nix build
(ty @ngua)
cd plutus-apps
nix build -f default.nix \
plutus-apps.haskell.packages.plutus-chain-index.components.exes.plutus-chain-index
./result/bin/plutus-chain-index --socket-path $CARDANO_NODE_SOCKET_PATH \
--db-path /path/to/chain-index.db --network-id 1097911063 start-index
or with cabal
from nix-shell
cd plutus-apps
nix-shell
cd plutus-chain-index
cabal build
cabal run exe:plutus-chain-index -- --socket-path $CARDANO_NODE_SOCKET_PATH --db-path /path/to/chain-index.db --network-id 1097911063 start-index
Full config could be also provided with --config
flag, can be found here: https://github.com/input-output-hk/plutus-apps/blob/main/plutus-pab/test-node/testnet/chain-index-config.json
It will probably take some time for chain-index to sync. Request to localhost:chain-index-port/tip
can be performed to see current status.
Add PAB executable (example) and build it.
Prepare config (sample) - here you specify where PAB should send requests to cardano-wallet, chain-index and node socket.
We currently have test config like this as example (note mscNodeMode: AlonzoNode
):
dbConfig:
dbConfigFile: pab-core.db
dbConfigPoolSize: 20
pabWebserverConfig:
baseUrl: http://localhost:9080
staticDir: ./dist
permissiveCorsPolicy: False
# Optional timeout (in seconds) for calls to endpoints that are not currently
# available. If this is not set, calls to unavailable endpoints fail
# immediately.
endpointTimeout: 5
walletServerConfig:
baseUrl: http://localhost:8090
wallet:
getWallet: 1
nodeServerConfig:
mscBaseUrl: "localhost"
mscSocketPath: /our/path/to/node.socket
mscKeptBlocks: 100
mscNetworkId: "1097911063" # Testnet network ID (main net = empty string)
mscSlotConfig:
scSlotZeroTime: 1591566291000 # Wednesday, July 29, 2020 21:44:51 - shelley launch time in milliseconds
scSlotLength: 1000 # In milliseconds
mscFeeConfig:
fcConstantFee:
getLovelace: 10 # Constant fee per transaction in lovelace
fcScriptsFeeFactor: 1.0 # Factor by which to multiply size-dependent scripts fee in lovelace
mscInitialTxWallets:
- getWallet: 1
- getWallet: 2
- getWallet: 3
mscNodeMode: AlonzoNode
chainIndexConfig:
ciBaseUrl: http://localhost:9083
ciWatchedAddresses: []
requestProcessingConfig:
requestProcessingInterval: 1
signingProcessConfig:
spBaseUrl: http://localhost:9084
spWallet:
getWallet: 1
metadataServerConfig:
mdBaseUrl: http://localhost:9085
# Optional EKG Server Config
# ----
# monitoringConfig:
# monitoringPort: 9090
Now you cas start PAB and start serving your contracts at pabWebserverConfig.baseUrl
, e.g.:
cabal exec my-dapp -- --config ./my-dapp/plutus-pab.yaml migrate (creates database)
cabal exec my-dapp -- --config ./my-dapp/plutus-pab.yaml --passphrase WALLET_PASSPHRASE webserver
For WALLET_PASSPHRASE
specify passphrase of wallet created earlier with cardano-wallet
.
After PAB started (watch for Starting PAB backend server on port 9080
in logs) contracts can be activated. E.g.:
curl --location --request POST 'localhost:9080/api/contract/activate' \
--header 'Content-Type: application/json' \
--data-raw '{
"caID": {
"tag": "UserContract",
"contents": {
"someParam": "param"
}
},
"caWallet": {
"getWalletId": "WALLET_ID"
}
}'
(for WALLET_ID
we are using wallet which passphrase was provided to start PAB, as that wallet will be doing transaction signing)