Updated on May 20, 2020

Get started with onchain permissioning

The following steps describe bootstrapping a local permissioned network using a Hyperledger Besu node and a development server to run the Permissioning Management Dapp.

Note

Production environments require a webserver to host the Permissioning Management Dapp.

To start a network with onchain permissioning:

  1. Install the prerequisites
  2. Add the ingress contracts to the genesis file
  3. Set the environment variables
  4. Start first node with onchain permissioning and the JSON-RPC HTTP service enabled
  5. Clone the permissioning contracts repository and install dependencies
  6. Build the project
  7. Deploy the permissioning contracts
  8. Start the webserver for the Permissioning Management Dapp
  9. Add the first node to the nodes whitelist.

Prerequisites

For the development server to run the dapp:

Add the ingress contracts to the genesis file

Tip

If the network is using only account or nodes permissioning, add only the relevant ingress contract to the genesis file.

Add the Ingress contracts to the genesis file for your network by copying them from genesis.json in the permissioning-smart-contracts repository:

"0x0000000000000000000000000000000000008888": {
      "comment": "Account Ingress smart contract",
      "balance": "0",
      "code": <stripped>,
      "storage": {
         <stripped>
      }
}

"0x0000000000000000000000000000000000009999": {
      "comment": "Node Ingress smart contract",
      "balance": "0",
      "code": <stripped>,
      "storage": {
         <stripped>
      }
}

Important

To support the permissioning contracts, ensure your genesis file includes at least the constantinopleFixBlock milestone.

Set the environment variables

Create the following environment variables and set to the specified values:

  • BESU_NODE_PERM_ACCOUNT - account to deploy the permissioning contracts and become the first admin account.
  • BESU_NODE_PERM_KEY - private key of the account to deploy the permissioning contracts.
  • ACCOUNT_INGRESS_CONTRACT_ADDRESS - address of the Account Ingress contract in the genesis file.
  • NODE_INGRESS_CONTRACT_ADDRESS - address of the Node Ingress contract in the genesis file.
  • BESU_NODE_PERM_ENDPOINT - required only if your node is not using the default JSON-RPC host and port (http://127.0.0.1:8545). Set to JSON-RPC host and port. When bootstrapping the network, Besu uses the specified node to deploy the contracts and is the first node in the network.
  • CHAIN_ID The chainID from the genesis file.

Important

The specified node must be a miner (PoW networks) or validator (PoA networks).

If your network is not a free gas network, the account used to interact with the permissioning contracts must have a balance.

Onchain permissioning command line options

To enable account and/or node permissioning, all nodes participating in a permissioned network must include the command line options:

Clone the contracts and install dependencies

  1. Clone the permissioning-smart-contracts repository:

    git clone https://github.com/PegaSysEng/permissioning-smart-contracts.git
    
  2. Change into the permissioning-smart-contracts directory and run:

    yarn install
    

Build the project

In the permissioning-smart-contracts directory, build the project:

yarn run build

Deploy the contracts

In the permissioning-smart-contracts directory, deploy the Admin and Rules contracts:

yarn truffle migrate --reset

This also updates the Ingress contract with the name and version of the Admin and Rules contracts. The migration logs the addresses of the Admin and Rules contracts.

Important

The account that deploys the contracts is automatically an admin account.

Start the webserver for the Permissioning Management Dapp

Note

Production environments require a webserver to host the Permissioning Management Dapp.

  1. In the permissioning-smart-contracts directory, start the webserver serving the Dapp:

    yarn start
    

    The Dapp displays at http://localhost:3000.

  2. Ensure MetaMask connects to your local node (by default http://localhost:8545).

    A MetaMask notification displays requesting permission for Besu Permissioning to connect to your account.

  3. Click the Connect button.

    The Dapp displays with the account specified by the BESU_NODE_PERM_ACCOUNT environment variable in the Whitelisted Accounts and Admin Accounts tabs.

Note

Only admin accounts can add or remove nodes from the whitelist.

Add the first node to the whitelist

The first node must add itself to the whitelist before adding other nodes.