An enterprise-grade Java-based, Apache 2.0 licensed Ethereum client https://wiki.hyperledger.org/display/besu
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
besu/docs/Permissions/Onchain-Permissioning/Getting-Started-Onchain-Per...

6.3 KiB

description: Setting up and using onchain Permissioning

Getting Started with Onchain Permissioning

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

To start a network with onchain permissioning:

  1. Install pre-requisites
  2. Add the ingress contracts to the genesis file
  3. Set 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. Deploy the permissioning contracts
  7. Start the development server for the Permissioning Management Dapp
  8. Add the first node to the nodes whitelist

Pre-requisites

For the development server to run the dapp:

To deploy the permissioning contracts:

Add Ingress Contracts to 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 Environment Variables

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

  • PANTHEON_NODE_PERM_ACCOUNT - account to deploy the permissioning contracts and become the first admin account.

  • PANTHEON_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.

  • PANTHEON_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, the specified node is used to deploy the contracts and is the first node in the network.

!!! important The account specified must be a miner (PoW networks) or validator (PoA networks).

If your network is not a [free gas network](../../Configuring-Pantheon/FreeGas.md), the account used to 
interact with the permissioning contracts must have a balance. 

Onchain Permissioning Command Line Options

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

Clone Project 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 Project

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

yarn run build

Deploy Contracts

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

truffle migrate --reset

The Admin and Rules contracts are deployed and the Ingress contract updated with the name and version of the 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 Development Server for the Permissioning Management Dapp

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

    yarn start
    

    The Dapp is displayed at http://localhost:3000.

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

    A MetaMask notification is displayed requesting permission for Pantheon Permissioning to connect to your account.

  3. Click the Connect button.

    The Dapp is displayed with the account specified by the PANTHEON_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 First Node to Whitelist

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