Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test 5NODES with 7 nodes as supply chain #66

Open
wants to merge 34 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
95840d7
Added 5nodesRTGS example
rsarres May 25, 2017
80c898a
Edited 5nodesRTGS README
rsarres May 26, 2017
5c3cc71
Edited 5nodesRTGS README
rsarres May 26, 2017
c624052
Edited 5nodesRTGS README
rsarres May 26, 2017
432b7fd
Edited 5nodesRTGS README
rsarres May 26, 2017
6ecb904
Edited 5nodesRTGS README
rsarres May 26, 2017
d6c96d3
Edited 5nodesRTGS README
rsarres May 26, 2017
1a2f63c
Edited 5nodesRTGS README
rsarres May 26, 2017
f72fdcc
Edited 5nodesRTGS README
rsarres May 26, 2017
8b33dfd
Update README.md
tylobban Jul 14, 2017
ea72cb2
Merge pull request #1 from tylobban/patch-2
rsarres Jul 17, 2017
da4c3e9
5nodesRTGS README.md update
rsarres Jul 24, 2017
54a6712
Merge branch 'master' of https://github.com/rsarres/quorum-examples
rsarres Jul 24, 2017
aba5ca3
Examples cleanup and README update
rsarres Aug 31, 2017
0df608e
Quorum 2.0.0 compatibility and raft consensus
Nov 23, 2017
9a67aee
Quorum v2.0.0 compatibility and raft consensus
Nov 23, 2017
8f55c6e
README update
Nov 23, 2017
b470b87
README update
Nov 23, 2017
51ea0fc
Clean up
Nov 23, 2017
150aa34
cleanup
Nov 23, 2017
4c6ffe1
Bootstrap script and readme update
Nov 23, 2017
d1086fe
Restored contracts.sol file
Nov 30, 2017
2b1f638
Readme update
Nov 30, 2017
9da716e
Added minimal web3 functionality
Dec 4, 2017
d0f16f1
Readme update
Dec 4, 2017
a121ef9
Updated readme
Dec 4, 2017
3fc52e2
Restored correct contracts.sol version
Dec 5, 2017
5c0b0ad
Updated bank3 address on Readme
Dec 6, 2017
ee9b4bb
Created new javascript example to interact with the blockchain
Dec 8, 2017
7e53554
Readme update
Dec 8, 2017
e63f3c0
Readme update
Dec 8, 2017
3c2b291
Update README.md
eric6356 Mar 1, 2018
c88ef37
Created deploy examples using compiled contracts in solidoty 0.4.10 a…
Apr 12, 2018
96f9ee0
Merge pull request #2 from eric6356/patch-1
rsarres Jan 31, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
43 changes: 9 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,46 +2,21 @@

This repository contains setup examples for Quorum.

Current examples include:
* [7nodes](https://github.com/jpmorganchase/quorum-examples/tree/master/examples/7nodes): Starts up a fully-functioning Quorum environment consisting of 7 independent nodes with a mix of block makers, voters, and unprivileged nodes. From this example one can test consensus, privacy, and all the expected functionality of an Ethereum platform.
* [permissions](https://github.com/jpmorganchase/quorum-examples/tree/master/examples/permissions): Focuses on how to add, remove, and update the list of nodes permitted to participate in the network.
Current BACEN example is:
* [5nodesRTGS](https://github.com/bacen/quorum-examples/tree/master/examples/5nodesRTGS): Starts up a set of 5 nodes that simulates a Real-time Gross Setlement environment with 3 banks, one regulator (typically a central bank) and an observer that cannot access the private data.

The easiest way to get started with running the examples is to use the vagrant environment (see below).
The easiest way to get started with running the examples is to use a clean Ubuntu 16.04 environment (see README at 5nodesRTGS directory).

**Important note**: Any account/encryption keys contained in this repository are for
demonstration and testing purposes only. Before running a real environment, you should
generate new ones using Geth's `account` tool and `constellation-enclave-keygen`.

## Vagrant Usage

This is a complete Vagrant environment containing Quorum, Constellation, and the
Quorum examples.

### Requirements

1. Install [VirtualBox](https://www.virtualbox.org/wiki/Downloads)
1. Install [Vagrant](https://www.vagrantup.com/downloads.html)

(If you are behind a proxy server, please see https://github.com/jpmorganchase/quorum/issues/23)

### Running

## Usage
```sh
git clone https://github.com/jpmorganchase/quorum-examples
git clone https://github.com/bacen/quorum-examples
cd quorum-examples
vagrant up
# (should take 5 or so minutes)
vagrant ssh
cd examples
cd 5nodesRTGS
./bootstrap.sh
# (run as root, should take some user confirmations, requires internet connection)
```

(*macOS note*: If you get an error saying that the ubuntu/xenial64 image doesn't
exist, please run `sudo rm -r /opt/vagrant/embedded/bin/curl`. This is usually due to
issues with the version of curl bundled with Vagrant.)

Once in the VM environment, `cd quorum-examples` then simply follow the
instructions for the demo you'd like to run.

To shut down the Vagrant instance, run `vagrant suspend`. To delete it, run
`vagrant destroy`. To start from scratch, run `vagrant up` after destroying the
instance.

14 changes: 0 additions & 14 deletions Vagrantfile

This file was deleted.

File renamed without changes.
56 changes: 56 additions & 0 deletions examples/5nodesRTGS/1-interacting-with-the-blockchain/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
'use strict';
import $ from 'jquery';
import Web3 from 'web3quorum';

// Instance Web3 using localhost testrpc
var web3 = new Web3(new Web3.providers.HttpProvider("http://IP:PORT"));

//var transactionAccount;
var abi = [{"constant":false,"inputs":[{"name":"_transactionID","type":"bytes32"}],"name":"confirmTransactionRegulator","outputs":[],"type":"function","payable":true},{"constant":false,"inputs":[{"name":"_seconds","type":"uint256"}],"name":"setConfirmationTime","outputs":[],"type":"function","payable":true},{"constant":false,"inputs":[{"name":"_value","type":"uint256"},{"name":"_random","type":"string"}],"name":"receiveValue","outputs":[],"type":"function","payable":true},{"constant":false,"inputs":[{"name":"_transactionID","type":"bytes32"}],"name":"confirmTransactionBank","outputs":[],"type":"function","payable":true},{"constant":true,"inputs":[{"name":"","type":"bytes32"}],"name":"transactions","outputs":[{"name":"value","type":"uint256"},{"name":"senderContract","type":"address"},{"name":"destinationContract","type":"address"},{"name":"confirmed","type":"bool"},{"name":"senderBalanceAtTransfer","type":"uint256"}],"type":"function","payable":true},{"constant":true,"inputs":[],"name":"confirmationTime","outputs":[{"name":"","type":"uint256"}],"type":"function","payable":true},{"constant":false,"inputs":[{"name":"_contractAddress","type":"address"}],"name":"setTransactionListAddress","outputs":[],"type":"function","payable":true},{"constant":true,"inputs":[],"name":"isRegulatorNode","outputs":[{"name":"","type":"bool"}],"type":"function","payable":true},{"constant":true,"inputs":[],"name":"TransactionListAddress","outputs":[{"name":"","type":"address"}],"type":"function","payable":true},{"constant":true,"inputs":[],"name":"thisBankContract","outputs":[{"name":"","type":"address"}],"type":"function","payable":true},{"constant":false,"inputs":[{"name":"_thisBankContract","type":"address"}],"name":"setThisBankContract","outputs":[],"type":"function","payable":true},{"constant":false,"inputs":[{"name":"_destination","type":"address"},{"name":"_value","type":"uint256"},{"name":"_random","type":"string"}],"name":"sendValue","outputs":[],"type":"function","payable":true},{"constant":false,"inputs":[],"name":"setRegulatorNode","outputs":[],"type":"function","payable":true},{"constant":false,"inputs":[{"name":"_transactionID","type":"bytes32"}],"name":"confirmTransactionPair","outputs":[],"type":"function","payable":true},{"constant":true,"inputs":[],"name":"balance","outputs":[{"name":"","type":"uint256"}],"type":"function","payable":true},{"constant":true,"inputs":[],"name":"totalTransactions","outputs":[{"name":"","type":"uint256"}],"type":"function","payable":true},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"transactionIDs","outputs":[{"name":"","type":"bytes32"}],"type":"function","payable":true},{"constant":true,"inputs":[],"name":"regulator","outputs":[{"name":"","type":"address"}],"type":"function","payable":true},{"constant":false,"inputs":[{"name":"_balance","type":"uint256"}],"name":"setBalance","outputs":[],"type":"function","payable":true},{"inputs":[],"type":"constructor","payable":true},{"type":"fallback","payable":true}]


// We will use this functions to show the status of the accounts generated by testRPC
const synchAccounts = () => {
$('#accounts').html("");
//transactionAccount=we3.accounts[0];
web3.eth.accounts.forEach(account => {
let balance = web3.eth.getBalance(account);
$('#accounts').append(`<p><a href="#" class="from">from</a> <a href="#" class="to">to</a> <span class="address">${account}</span> | <span class="balance">ETH ${balance}</span></p>`);
});
};

// This callback just avoids us to copy & past every time you want to use an address
const updateAddressFromLink = (event, inputSelector) => {
event.preventDefault();
$(inputSelector).val($(event.target).siblings(".address").text());
};

// Show initial accounts state and initialize callback triggers
synchAccounts();
$(document).on('click', '.from', e => updateAddressFromLink(e, '#sender-address'));
$(document).on('click', '.to', e => updateAddressFromLink(e, '#recipient-address'));


$('#get-bank-balance').click(() => {
let bankAddress = $('#bank-address').val();

console.log(`Address: ${bankAddress}`);

let bankContract = web3.eth.contract(abi).at(bankAddress);

let balance = bankContract.balance();

console.log(`Retrieved Balance: ${balance}, ${bankAddress}`);

$("#bank-balance").text(`Bank Balance: ${balance}`);


});

$('#change-node').click(() => {
let node = $('#choose-node').val();

console.log(`Node: ${node}`);


});
59 changes: 59 additions & 0 deletions examples/5nodesRTGS/1-interacting-with-the-blockchain/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<html>
<header>
<script src="https://code.jquery.com/jquery-1.11.3.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css">
<style>
.container { width: 100% !important; }
#transaction-hash { color: grey; font-size: 12px; }
#errors { background-color: #ffd6c8; color: darkred; }
#accounts { list-style: none; }
.balance { color: grey; width: 70px; }
.from, .to { color: blue !important; }
#transaction-info { background-color: darkgrey; border: grey 1px solid; margin-top: 10px; }
#transaction-info p { margin: -15px 2px; }
</style>
</header>
<body>
<div id="app" class="container">
<div id="errors"></div>
<div class="row">
<div class="col-sm-6">
<h3>Accounts</h3>
<pre id="accounts"></pre>
</div>
<div class="col-sm-6">
<h3>Transaction Information</h3>
<pre id="transaction-info">
<p><b>Hash:</b> <span id="hash"></span></p>
<p><b>Nonce:</b> <span id="nonce"></span></p>
<p><b>Gas usage:</b> <span id="gas-usage"></span></p>
<p><b>Block Number:</b> <span id="block-number"></span></p>
<p><b>Block Hash:</b> <span id="block-hash"></span></p>
<p><b>Tx Index:</b> <span id="transaction-index"></span></p>
<p><b>From:</b> <span id="from"></span></p>
<p><b>To:</b> <span id="to"></span></p>
<p><b>Value:</b> <span id="value"></span></p>
</pre>
</div>
</div>

<div class="row">
<div class="col-sm-6" id="get-balance-form">
<h3>Get a Bank Balance</h3>

<div class="form-group row">
<label for="bank-address" class="col-sm-3 col-form-label">Bank contract (address)</label>
<div class="col-sm-9"><input class="form-control" id="bank-address"></div>
</div>
<p id="bank-balance">Bank Balance: </p>
<button id="get-bank-balance" class="btn btn-primary">Get Bank Balance</button>
</div>
</div>



</div>
<script type="application/javascript" src="./bundle.js"></script>
</body>
</html>