mirror of
https://github.com/tappollo/quorum-examples.git
synced 2026-04-30 13:52:31 +08:00
Merge branch 'master' of https://github.com/jpmorganchase/quorum-examples
This commit is contained in:
@@ -19,8 +19,9 @@
|
||||
"coinbase": "0x0000000000000000000000000000000000000000",
|
||||
"config": {
|
||||
"byzantiumBlock": 1,
|
||||
"chainId": 1,
|
||||
"chainId": 10,
|
||||
"eip150Block": 1,
|
||||
"eip155Block": 0,
|
||||
"eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
|
||||
"eip158Block": 1,
|
||||
"isQuorum":true
|
||||
|
||||
1
examples/7nodes/keys/key6
Normal file
1
examples/7nodes/keys/key6
Normal file
@@ -0,0 +1 @@
|
||||
{"address":"ae9bc6cd5145e67fbd1887a5145271fd182f0ee7","crypto":{"cipher":"aes-128-ctr","ciphertext":"013ed4c928bf7ae50dba7c9d8396f2d89d1fccc16a2067fdad56e125a0f5d96c","cipherparams":{"iv":"9fce4f1ab5c9cdaee9432dbc43d28ed8"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":262144,"p":1,"r":8,"salt":"5301d6b0c7bc8ba4ca60256ba524bae57cb078679e0de7d5322ebdc2393849a0"},"mac":"55aabdbc4853a188e8b63a1cec93e5d233a8b5b529ed00c610d1b4a9b27990da"},"id":"025f7cf0-f35b-4988-8a22-2443a08e5d69","version":3}
|
||||
1
examples/7nodes/keys/key7
Normal file
1
examples/7nodes/keys/key7
Normal file
@@ -0,0 +1 @@
|
||||
{"address":"cc71c7546429a13796cf1bf9228bff213e7ae9cc","crypto":{"cipher":"aes-128-ctr","ciphertext":"a522d53d5a86405435f6288d4e34b0c038de25f46fa935b0be78fd24d4aa65da","cipherparams":{"iv":"10511f1422825b699718559dcaaa0ff2"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":262144,"p":1,"r":8,"salt":"471dfeff2dc7524d27970e54d8224320cb13f7e580431473a362fe8850ebc120"},"mac":"25ee0b623467350a4245a041a89a6797560ade8a1bd1c8d4d1b67ca5e37c56c0"},"id":"477df10a-9591-4fae-9c30-3aa0bc0ec57b","version":3}
|
||||
1
examples/7nodes/keys/key8
Normal file
1
examples/7nodes/keys/key8
Normal file
@@ -0,0 +1 @@
|
||||
{"address":"a9e871f88cbeb870d32d88e4221dcfbd36dd635a","crypto":{"cipher":"aes-128-ctr","ciphertext":"ef6b5b4fc31fb5d6e7f76ef41fd535c911f6fb30ea4352ab0c4e596a174e139d","cipherparams":{"iv":"d131dec4288badf4ba25d04053294df9"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":262144,"p":1,"r":8,"salt":"92e02db465c1a22e0a16d913cfd5cc538321a50b192d0888dbc92c450ead85e4"},"mac":"19bc6e3fdc15eded402506309d42c36c9a03ffadd087d89aad6f61b61ea88760"},"id":"e65354b5-54ce-46f9-a287-9f2a0efc2d35","version":3}
|
||||
2529
examples/7nodes/package-lock.json
generated
Normal file
2529
examples/7nodes/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
18
examples/7nodes/package.json
Normal file
18
examples/7nodes/package.json
Normal file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"name": "7nodes",
|
||||
"version": "1.0.0",
|
||||
"description": "This example configures 7 nodes, each with their own PrivateTransactionManager. Usage:",
|
||||
"main": "send-signed-tx.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"ethereumjs-tx": "^1.3.4",
|
||||
"fs": "0.0.1-security",
|
||||
"keythereum": "^1.0.4",
|
||||
"minimist": "^1.2.0",
|
||||
"web3": "^1.0.0-beta.34"
|
||||
}
|
||||
}
|
||||
22
examples/7nodes/public-contract.js
Normal file
22
examples/7nodes/public-contract.js
Normal file
@@ -0,0 +1,22 @@
|
||||
a = eth.accounts[0]
|
||||
web3.eth.defaultAccount = a;
|
||||
|
||||
// abi and bytecode generated from simplestorage.sol:
|
||||
// > solcjs --bin --abi simplestorage.sol
|
||||
var abi = [{"constant":true,"inputs":[],"name":"storedData","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"x","type":"uint256"}],"name":"set","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"get","outputs":[{"name":"retVal","type":"uint256"}],"payable":false,"type":"function"},{"inputs":[{"name":"initVal","type":"uint256"}],"payable":false,"type":"constructor"}];
|
||||
|
||||
var bytecode = "0x6060604052341561000f57600080fd5b604051602080610149833981016040528080519060200190919050505b806000819055505b505b610104806100456000396000f30060606040526000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680632a1afcd914605157806360fe47b11460775780636d4ce63c146097575b600080fd5b3415605b57600080fd5b606160bd565b6040518082815260200191505060405180910390f35b3415608157600080fd5b6095600480803590602001909190505060c3565b005b341560a157600080fd5b60a760ce565b6040518082815260200191505060405180910390f35b60005481565b806000819055505b50565b6000805490505b905600a165627a7a72305820d5851baab720bba574474de3d09dbeaabc674a15f4dd93b974908476542c23f00029";
|
||||
|
||||
var simpleContract = web3.eth.contract(abi);
|
||||
var simple = simpleContract.new(42, {from:web3.eth.accounts[0], data: bytecode, gas: 0x47b760}, function(e, contract) {
|
||||
if (e) {
|
||||
console.log("err creating contract", e);
|
||||
} else {
|
||||
if (!contract.address) {
|
||||
console.log("Contract transaction send: TransactionHash: " + contract.transactionHash + " waiting to be mined...");
|
||||
} else {
|
||||
console.log("Contract mined! Address: " + contract.address);
|
||||
console.log(contract);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -27,6 +27,7 @@ echo "[*] Configuring node 3 (permissioned)"
|
||||
mkdir -p qdata/dd3/{keystore,geth}
|
||||
cp permissioned-nodes.json qdata/dd3/static-nodes.json
|
||||
cp permissioned-nodes.json qdata/dd3/
|
||||
cp keys/key6 qdata/dd3/keystore
|
||||
cp raft/nodekey3 qdata/dd3/geth/nodekey
|
||||
geth --datadir qdata/dd3 init genesis.json
|
||||
|
||||
@@ -49,10 +50,12 @@ echo "[*] Configuring node 6"
|
||||
mkdir -p qdata/dd6/{keystore,geth}
|
||||
cp permissioned-nodes.json qdata/dd6/static-nodes.json
|
||||
cp raft/nodekey6 qdata/dd6/geth/nodekey
|
||||
cp keys/key7 qdata/dd6/keystore
|
||||
geth --datadir qdata/dd6 init genesis.json
|
||||
|
||||
echo "[*] Configuring node 7"
|
||||
mkdir -p qdata/dd7/{keystore,geth}
|
||||
cp permissioned-nodes.json qdata/dd7/static-nodes.json
|
||||
cp raft/nodekey7 qdata/dd7/geth/nodekey
|
||||
cp keys/key8 qdata/dd7/keystore
|
||||
geth --datadir qdata/dd7 init genesis.json
|
||||
|
||||
@@ -10,12 +10,12 @@ echo "[*] Starting Ethereum nodes"
|
||||
set -v
|
||||
ARGS="--nodiscover --raft --rpc --rpcaddr 0.0.0.0 --rpcapi admin,db,eth,debug,miner,net,shh,txpool,personal,web3,quorum --emitcheckpoints"
|
||||
PRIVATE_CONFIG=qdata/c1/tm.ipc nohup geth --datadir qdata/dd1 $ARGS --permissioned --raftport 50401 --rpcport 22000 --port 21000 --unlock 0 --password passwords.txt 2>>qdata/logs/1.log &
|
||||
PRIVATE_CONFIG=qdata/c2/tm.ipc nohup geth --datadir qdata/dd2 $ARGS --permissioned --raftport 50402 --rpcport 22001 --port 21001 2>>qdata/logs/2.log &
|
||||
PRIVATE_CONFIG=qdata/c3/tm.ipc nohup geth --datadir qdata/dd3 $ARGS --permissioned --raftport 50403 --rpcport 22002 --port 21002 2>>qdata/logs/3.log &
|
||||
PRIVATE_CONFIG=qdata/c4/tm.ipc nohup geth --datadir qdata/dd4 $ARGS --permissioned --raftport 50404 --rpcport 22003 --port 21003 2>>qdata/logs/4.log &
|
||||
PRIVATE_CONFIG=qdata/c5/tm.ipc nohup geth --datadir qdata/dd5 $ARGS --raftport 50405 --rpcport 22004 --port 21004 2>>qdata/logs/5.log &
|
||||
PRIVATE_CONFIG=qdata/c6/tm.ipc nohup geth --datadir qdata/dd6 $ARGS --raftport 50406 --rpcport 22005 --port 21005 2>>qdata/logs/6.log &
|
||||
PRIVATE_CONFIG=qdata/c7/tm.ipc nohup geth --datadir qdata/dd7 $ARGS --raftport 50407 --rpcport 22006 --port 21006 2>>qdata/logs/7.log &
|
||||
PRIVATE_CONFIG=qdata/c2/tm.ipc nohup geth --datadir qdata/dd2 $ARGS --permissioned --raftport 50402 --rpcport 22001 --port 21001 --unlock 0 --password passwords.txt 2>>qdata/logs/2.log &
|
||||
PRIVATE_CONFIG=qdata/c3/tm.ipc nohup geth --datadir qdata/dd3 $ARGS --permissioned --raftport 50403 --rpcport 22002 --port 21002 --unlock 0 --password passwords.txt 2>>qdata/logs/3.log &
|
||||
PRIVATE_CONFIG=qdata/c4/tm.ipc nohup geth --datadir qdata/dd4 $ARGS --permissioned --raftport 50404 --rpcport 22003 --port 21003 --unlock 0 --password passwords.txt 2>>qdata/logs/4.log &
|
||||
PRIVATE_CONFIG=qdata/c5/tm.ipc nohup geth --datadir qdata/dd5 $ARGS --raftport 50405 --rpcport 22004 --port 21004 --unlock 0 --password passwords.txt 2>>qdata/logs/5.log &
|
||||
PRIVATE_CONFIG=qdata/c6/tm.ipc nohup geth --datadir qdata/dd6 $ARGS --raftport 50406 --rpcport 22005 --port 21005 --unlock 0 --password passwords.txt 2>>qdata/logs/6.log &
|
||||
PRIVATE_CONFIG=qdata/c7/tm.ipc nohup geth --datadir qdata/dd7 $ARGS --raftport 50407 --rpcport 22006 --port 21006 --unlock 0 --password passwords.txt 2>>qdata/logs/7.log &
|
||||
set +v
|
||||
|
||||
echo
|
||||
|
||||
51
examples/7nodes/send-signed-tx.js
Normal file
51
examples/7nodes/send-signed-tx.js
Normal file
@@ -0,0 +1,51 @@
|
||||
const argv = require('minimist')(process.argv.slice(2));
|
||||
const EthereumTx = require('ethereumjs-tx');
|
||||
const keythereum = require("keythereum");
|
||||
const Web3 = require('web3');
|
||||
const fs = require('fs');
|
||||
|
||||
|
||||
// connect to block chain
|
||||
console.log('using node', argv.node);
|
||||
const providerURL = "http://127.0.0.1";
|
||||
const providerPort = "2200".concat(argv.node - 1);
|
||||
var web3 = new Web3(new Web3.providers.HttpProvider(providerURL + ":" + providerPort));
|
||||
|
||||
const keyJSON = fs.readFileSync('keys/key'+argv.node, 'utf8');
|
||||
const keyObj = JSON.parse(keyJSON);
|
||||
const password = '';
|
||||
const privateKey = keythereum.recover(password, keyObj);
|
||||
|
||||
console.log('privateKey: ', privateKey.toString('hex'));
|
||||
|
||||
|
||||
web3.eth.getAccounts().then(re => {
|
||||
let account = re[0];
|
||||
console.log('account: ', account);
|
||||
|
||||
return web3.eth.getTransactionCount(account);
|
||||
}).then(nonce => {
|
||||
console.log('nonce: ', nonce);
|
||||
|
||||
let txParams = {
|
||||
nonce: '0x0'+nonce,
|
||||
gasPrice: '0x00',
|
||||
gasLimit: '0x47b760',
|
||||
to: '0xca843569e3427144cead5e4d5999a3d0ccf92b8e', // node 2 account
|
||||
value: '0x01',
|
||||
chainId: 10,
|
||||
};
|
||||
|
||||
console.log('tx payload: ', txParams);
|
||||
|
||||
const tx = new EthereumTx(txParams);
|
||||
|
||||
tx.sign(privateKey);
|
||||
const serializedTx = tx.serialize();
|
||||
var rawTx = '0x' + tx.serialize().toString('hex');
|
||||
|
||||
console.log('raw transaction: ', rawTx);
|
||||
|
||||
web3.eth.sendSignedTransaction(rawTx)
|
||||
.on('receipt', console.log);
|
||||
});
|
||||
Reference in New Issue
Block a user