Skip to content
This repository has been archived by the owner on Jan 16, 2023. It is now read-only.

Commit

Permalink
Removed duplicate content (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
MadelineMurray authored Apr 29, 2019
1 parent 916d6e7 commit 936616a
Showing 1 changed file with 5 additions and 77 deletions.
82 changes: 5 additions & 77 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,85 +1,13 @@
# Permissioning Smart Contracts

## Requirements
1. [NodeJS](https://nodejs.org/en/) v8.9.4 or later
1. A [Pantheon node](https://github.com/PegaSysEng/pantheon) running with a [permissioning enabled genesis](genesis.json) file (genesis file with the Ingress contract embedded).
1. [Truffle installed](https://truffleframework.com/docs/truffle/getting-started/installation)
**Note:** The contracts in this repository are currently in the process of going through a third party audit. [Please
contact us]([email protected]) before using in a production environment.

## Initial setup
1. Run `npm install`.
1. Open `truffle-config.js`.
1. Create the following environment variables:
- `PANTHEON_NODE_PERM_ACCOUNT` - Set the value to the adress of the account used to interact with the permissioning contracts.
- `PANTHEON_NODE_PERM_KEY` - Set the value to the private key associated with the account.
- `INGRESS_CONTRACT_ADDRESS` "0x0000000000000000000000000000000000009999" - must match what is in the genesis file
1. If your node is not using the default JSON-RPC host and port (`http://127.0.0.1:8545`), create a environment variable named `PANTHEON_NODE_PERM_ENDPOINT` and set its value to match your node endpoint.
## Using

The [Pantheon documentation](https://docs.pantheon.pegasys.tech/en/stable/Permissions/Onchain-Permissioning/)
describes how to use the contracts for onchain permissioning.

## How to deploy and setup contracts
1. Run `truffle migrate`

After this step, you should have your Rules and Admin contracts deployed on the network. This will also update the Ingress contract with the name and version of the Rules and Admin contracts.

## Add and Remove Enodes to the whitelist
1. Run `truffle console`
1. Open https://permissioning-tools.pegasys.tech/
1. Type the enode that you want to include in the whitelist in the input box.
1. Click "Process".
1. Copy the truffe command output.
1. Paste the truffle command into the console and press enter.

Example output:
```
$ truffle console
$ truffle(development)> Rules.deployed().then(function(instance) {instance.addEnode("0x6f8a80d14311c39f35f516fa664deaaaa13e85b2f7493f37f6144d86991ec012", "0x937307647bd3b9a82abe2974e1407241d54947bbb39763a4cac9f77166ad92a0", "0x0a033a06", "30303").then(function(tx) {console.log(tx)});});
undefined
truffle(development)> { tx: '0xaecbc376089d8eba7154f93d08c6be3bdf7fa13bfe2d8dbdfe4cd323fec77160',
receipt:
{ blockHash: '0x553007bb40a52e3f37f3c9b8e559816d029c9e272590efac69b96926431ebfdd',
blockNumber: 22264,
contractAddress: null,
cumulativeGasUsed: 596203,
from: '0xfe3b557e8fb62b89f4916b721be55ceb828dbd73',
gasUsed: 596203,
logs: [],
logsBloom: '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
status: true,
to: '0xa86eb77c09ae0f2164065ab14094565011b0bfca',
transactionHash: '0xaecbc376089d8eba7154f93d08c6be3bdf7fa13bfe2d8dbdfe4cd323fec77160',
transactionIndex: 0,
rawLogs: [] },
logs: [] }
undefined
```

After this step, you should have the enode added to your whitelist. Please repeat this step for each enode that you want to add to the whitelist.

**View the whitelist**
```
Rules.deployed().then(function(instance) {instance.getSize().then(function(txCount) {console.log("size of whitelist: " + txCount); var i=txCount; while(i>=0) {instance.getByIndex(i--).then(function(tx) {console.log(tx)})}});});
```

## Add and Remove Admin accounts

When you first deploy the Rules and Admin smart contracts, the account used to deploy them will automatically be set as an Admin. Only Admin accounts can add or remove nodes from the whitelist.

If you want to add or remove accounts as Admins, use the following commands in `truffle console`:

**Add account `0x627306090abaB3A6e1400e9345bC60c78a8BEf57` to Admin list**
```
Admin.deployed().then(function(instance) {instance.addAdmin("0x627306090abaB3A6e1400e9345bC60c78a8BEf57").then(function(tx) {console.log(tx)});});
```

**Remove acccount `0x627306090abaB3A6e1400e9345bC60c78a8BEf57` from Admin list**
```
Admin.deployed().then(function(instance) {instance.removeAdmin("0x627306090abaB3A6e1400e9345bC60c78a8BEf57").then(function(tx) {console.log(tx)});});
```

**View Admin list**
```
Admin.deployed().then(function(instance) {instance.getAdmins().then(function(tx) {console.log(tx)});});
```
## Development

### Linting
Expand Down

0 comments on commit 936616a

Please sign in to comment.