6.6 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.
!!! note In production, a webserver is required to host the Permissioning Management Dapp.
To start a network with onchain permissioning:
- Install pre-requisites
- Add the ingress contracts to the genesis file
- Set environment variables
- Start first node with onchain permissioning and the JSON-RPC HTTP service enabled
- Clone the permissioning contracts repository and install dependencies
- Build project
- Deploy the permissioning contracts
- Start the development server for the Permissioning Management Dapp
- Add the first node to the nodes whitelist
Pre-requisites
For the development server to run the dapp:
- NodeJS v10.16.0 or later
- Yarn v1.15 or later
- Browser with MetaMask installed
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:
-
--permissions-accounts-contract-enabledto enable onchain accounts permissioning -
--permissions-accounts-contract-addressset to the address of the Account Ingress contract in the genesis file ("0x0000000000000000000000000000000000008888") -
--permissions-nodes-contract-enabledto enable onchain nodes permissioning -
--permissions-nodes-contract-addressset to the address of the Node Ingress contract in the genesis file ("0x0000000000000000000000000000000000009999")
Start your first node with command line options to enable onchain permissioning and the JSON-RPC HTTP host and port
matching environment variable PANTHEON_NODE_PERM_ENDPOINT.
Clone Project and Install Dependencies
-
Clone the
permissioning-smart-contractsrepository:git clone https://github.com/PegaSysEng/permissioning-smart-contracts.git -
Change into the
permissioning-smart-contractsdirectory 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:
yarn 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
!!! note In production, a webserver is required to host the Permissioning Management Dapp.
-
In the
permissioning-smart-contractsdirectory, start the web server serving the Dapp:yarn startThe Dapp is displayed at http://localhost:3000.
-
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.
-
Click the Connect button.
The Dapp is displayed with the account specified by the
PANTHEON_NODE_PERM_ACCOUNTenvironment 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.