Run A Local Test Network
This page guide you to run fakenet (private testing network) with N local nodes, primarily for testing/benchmarking purposes.
Download go-u2u
Please check out and clone go-u2u source code:
git clone https://github.com/unicornultrafoundation/go-u2uScripts
Scripts to run fakenet are located at demo folder, it contains these scripts:
start network:
./start.sh;stop network:
./stop.sh;clean data and logs:
./clean.sh;
You can specify number of genesis validators by setting N environment variable.
Balance transfer example
from demo/ dir
Start network:
N=3 ./start.shAttach js-console to running node0:
go run ../cmd/u2u attach http://localhost:4000Check the balance to ensure that node0 has something to transfer (node0 js-console):
eth.getBalance(eth.accounts[0]);output shows the balance value:
1e+27Get node1 address:
go run ../cmd/u2u attach --exec "eth.accounts[0]" http://localhost:4001output shows address:
"0x02aff1d0a9ed566e644f06fcfe7efe00a3261d03"Transfer some amount from node0 to node1 address as receiver (node0 js-console):
eth.sendTransaction(
{from: eth.accounts[0], to: "0x02aff1d0a9ed566e644f06fcfe7efe00a3261d03", value: "1000000000"},
function(err, transactionHash) {
if (!err)
console.log(transactionHash + " success");
});output shows unique hash of the outgoing transaction:
0x68a7c1daeee7e7ab5aedf0d0dba337dbf79ce0988387cf6d63ea73b98193adfd successCheck the transaction status by its unique hash (js-console):
eth.getTransactionReceipt("0x68a7c1daeee7e7ab5aedf0d0dba337dbf79ce0988387cf6d63ea73b98193adfd").blockNumberoutput shows number of block, transaction was included in:
174As soon as transaction is included into a block you will see new balance of both node addresses:
go run ../cmd/u2u attach --exec "eth.getBalance(eth.accounts[0])" http://localhost:4000
go run ../cmd/u2u attach --exec "eth.getBalance(eth.accounts[0])" http://localhost:4001outputs:
9.99999999978999e+26
1.000000000000001e+27Last updated