quorum入门

quorum(改进了以太坊的隐私机制)

官网相关链接

相关工具

一个以太币各单位之间的转换工具

http://ether.fund/tool/converter

与Quorum相关的第三方工具

相关文档

以太坊项目开发系列教程

http://www.8btc.com/author/17094

Quorum相关官方教程

区块链相关社区

安装教程

Quickstart

前置软件

vagrant开发目录:D:\quorum\quorum-examples

相关问题

  • 多开命令行:运行内输入cmd,每次都会开一个命令行

正式步骤

The quickest way to get started with Quorum is using VirtualBox and Vagrant:

git clone https://github.com/jpmorganchase/quorum-examples  
cd quorum-examples  
vagrant up
#(should take 5 or so minutes)
vagrant ssh

Now that you have a fully-functioning Quorum environment set up, let’s run the 7-node cluster example. This will spin up several nodes with a mix of voters, block makers, and unprivileged nodes.

# (from within vagrant env, use `vagrant ssh` to enter)  
ubuntu@ubuntu-xenial:~$ cd quorum-examples/7nodes

$ ./init.sh

$ ./start.sh
[*] Starting Constellation nodes

$ geth attach ipc:qdata/dd1/geth.ipc
$ geth attach ipc:qdata/dd2/geth.ipc
...
$ geth attach ipc:qdata/dd7/geth.ipc


# e.g.

$ geth attach ipc:qdata/dd2/geth.ipc
Welcome to the Geth JavaScript console!

instance: Geth/v1.5.0-unstable/linux/go1.7.3
coinbase: 0xca843569e3427144cead5e4d5999a3d0ccf92b8e
at block: 679 (Tue, 15 Nov 2016 00:01:05 UTC)
 datadir: /home/ubuntu/quorum-examples/7nodes/qdata/dd2
 modules: admin:1.0 debug:1.0 eth:1.0 net:1.0 personal:1.0 quorum:1.0 rpc:1.0 txpool:1.0 web3:1.0

> quorum.nodeInfo
{
  blockMakerAccount: "0xca843569e3427144cead5e4d5999a3d0ccf92b8e",
  blockmakestrategy: {
    maxblocktime: 10,
    minblocktime: 3,
    status: "active",
    type: "deadline"
  },
  canCreateBlocks: true,
  canVote: true,
  voteAccount: "0x0fbdc686b912d7722dc86510934589e0aaf3b55a"
}

# let's look at the private txn created earlier:
> eth.getTransaction("0xbfb7bfb97ba9bacbf768e67ac8ef05e4ac6960fc1eeb6ab38247db91448b8ec6")
{
  blockHash: "0xb6aec633ef1f79daddc071bec8a56b7099ab08ac9ff2dc2764ffb34d5a8d15f8",
  blockNumber: 1,
  from: "0xed9d02e382b34818e88b88a309c7fe71e65f419d",
  gas: 300000,
  gasPrice: 0,
  hash: "0xbfb7bfb97ba9bacbf768e67ac8ef05e4ac6960fc1eeb6ab38247db91448b8ec6",
  input: "0x9820c1a5869713757565daede6fcec57f3a6b45d659e59e72c98c531dcba9ed206fd0012c75ce72dc8b48cd079ac08536d3214b1a4043da8cea85be858b39c1d",
  nonce: 0,
  r: "0x226615349dc143a26852d91d2dff1e57b4259b576f675b06173e9972850089e7",
  s: "0x45d74765c5400c5c280dd6285a84032bdcb1de85a846e87b57e9e0cedad6c427",
  to: null,
  transactionIndex: 1,
  v: "0x25",
  value: 0
}
Note in particular the v field of "0x25" (37 in decimal) which marks this transaction as having a private payload (input).

Setup Bootnode

Optionally you can set up a bootnode that all the other nodes will first connect to in order to find other peers in the network. 
You will first need to generate a bootnode key:

1-  To generate the key for the first time:

bootnode –genkey tmp_file.txt //this will start a bootnode with an enode address and generate a key inside a “tmp_file.txt” file

2-  To later restart the bootnode using the same key (and hence use the same enode url):

bootnode –nodekey tmp_file.txt

or

bootnode –nodekeyhex 77bd02ffa26e3fb8f324bda24ae588066f1873d95680104de5bc2db9e7b2e510 // Key from tmp_file.txt

Start node

Starting a node is as simple as geth. This will start the node without any of the roles and makes the node a spectator. If you have setup a bootnode then be sure to add the –bootnodes param to your startup command:

geth --bootnodes $BOOTNODE_ENODE

Voting role

Start a node with the voting role:

geth --voteaccount 0xed9d02e382b34818e88b88a309c7fe71e65f419d

Optionally the –votepassword can be used to unlock the account. If this flag is omitted the node will prompt for the password.

Block maker role

Start a node with the block maker role:

geth --blockmakeraccount 0x9186eb3d20cbd1f5f992a950d808c4495153abd5

Created blocks will be signed with this account.

Optionally the –blockmakerpassword can be used to unlock the account. If this flag is omitted the node will prompt for the password.

Setup multi-node network

Quorum comes with several scripts to setup a private test network with 7 nodes:

node 1, has no special roles
node 2, has the block maker role
node 3, has no special roles
node 4, has the voting role
node 5, has the voting role
node 6, has no special roles
All scripts can be found in the 7nodes folder in the quorum-examples repository.

Step 1, run init.sh and initialize data directories (change variables accordingly)
Step 2, start nodes with start.sh (change variables accordingly)
Step 3, stop network with stop.sh

Permissioned Network

Node Permissioning is a feature that controls which nodes can connect to a given node and also to which nodes this node can dial out to. Currently, it is managed at individual node level by the command line flag –permissioned while starting the node.

If the –permissioned node is present, the node looks for a file named /permissioned-nodes.json. This file contains the list of enodes that this node can connect to and also accepts connections only from those nodes. In other words, if permissioning is enabled, only the nodes that are listed in this file become part of the network. It is an error to enable –permissioned but not have the permissioned-nodes.json file. If the flag is given, but no nodes are present in this file, then this node can neither connect to any node or accept any incoming connections.

The permissioned-nodes.json follows following pattern (similar to static-nodes.json):

[
  "enode://enodehash1@ip1:port1",
  "enode://enodehash2@ip2:port2",
  "enode://enodehash3@ip3:port3",
]  
Sample file:

[
  "enode://6598638ac5b15ee386210156a43f565fa8c48592489d3e66ac774eac759db9eb52866898cf0c5e597a1595d9e60e1a19c84f77df489324e2f3a967207c047470@127.0.0.1:30300",
]

In the current release, every node has its own copy of permissioned-nodes.json. In a future release, the permissioned nodes list will be moved to a smart contract, thereby keeping the list on chain and one global list of nodes that connect to the network.

web3js api reference

<!doctype>

<script type="text/javascript" src="../node_modules/bignumber.js/bignumber.min.js"></script> <script type="text/javascript" src="../dist/web3-light.js"></script> <script type="text/javascript">
var Web3 = require('web3');
var web3 = new Web3();
web3.setProvider(new web3.providers.HttpProvider());
function watchBalance() {
    var coinbase = web3.eth.coinbase;
    var originalBalance = web3.eth.getBalance(coinbase).toNumber();
    document.getElementById('coinbase').innerText = 'coinbase: ' + coinbase;
    document.getElementById('original').innerText = ' original balance: ' + originalBalance + '    watching...';
    web3.eth.filter('latest').watch(function() {
        var currentBalance = web3.eth.getBalance(coinbase).toNumber();
        document.getElementById("current").innerText = 'current: ' + currentBalance;
        document.getElementById("diff").innerText = 'diff:    ' + (currentBalance - originalBalance);
    });
}

以太币货币单

Ether币最小的单位是Wei,也是命令行默认的单位, 然后每1000个进一个单位,依次是

kwei (1000 Wei)
mwei (1000 KWei)
gwei (1000 mwei)
szabo (1000 gwei)
finney (1000 szabo)
ether (1000 finney)

版权声明:本文为j1097376869原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。