Skip to main content

Generating Keys and Addresses

The best way to set up your environment is with the plinth-template installer, which creates a ready-to-build Plinth project using your choice of Nix, Docker, Demeter, or plain GHC + Cabal. See its README for details. For this tutorial, create the project in a directory named on-chain:

curl -fsSL https://raw.githubusercontent.com/IntersectMBO/plinth-template/main/install.sh | sh -s -- --dir on-chain

Make sure you also have NodeJS and yarn (or npm, which comes with NodeJS) installed. Then, create a separate off-chain directory, initialize package.json, and install the required dependencies:

mkdir off-chain && cd $_
yarn init -y
yarn add @meshsdk/core
yarn add @harmoniclabs/pair
yarn add cbor

We'll use mesh, a JavaScript framework, for writing off-chain code. We'll use Blockfrost as the blockchain provider, to avoid the need of running a local node. If you don't have a Blockfrost account, you can sign up for one, and create a project for the Preview network.

The first step is to generate keys and addresses for the seller and the bidders. Add a new file named off-chain/generate-keys.mjs, with the following content:

Loading

Then, generate keys and addresses for one seller and two bidders by running:

node generate-keys.mjs seller
node generate-keys.mjs bidder1
node generate-keys.mjs bidder2

This will create three files for each participant (seller, bidder1, and bidder2): a .skey file that contains a secret key, a .addr file that contains the corresponding wallet address, and a .pkh file that contains the corresponding public key hash.