<h3>Dev highlights of this week <ul> <li>Releasing a Dust Server update today to include client local time zone based login rewards <li>Android and iOS client updates are currently in QA and will release next week including promoted blasts now marked as “promoted”, legacy Dusters will now get rewards, and other performance enhancements and bug fixes. <li>Designing analytics of rewards in preparation for switching to mainnet <li>Developing method of paying Ethereum gas costs with an ERC-20 token <li>Researching different mechanisms for storing content on the blockchain <h3>How to: blockchain <p dir="auto">This post marks the first in a new “How To” series we’re starting in an effort to provide some easy to read --instructions covering topics our developers found particularly ill-documented online. As we move beyond the token sale, our focus now is helping other developer teams interested in integrating <a href="http://www.mercuryprotocol.com/" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">GMT into their apps. To that end, we’re ramping up our technical content production to make it easier to onboard new developers looking to try their hand with blockchain technology.If you have a particular topic you’d like to see detailed in a How To post, we’d love to hear from you at info@mercuryprotocol.com. <h3>“Hello, Testnet” <p dir="auto">This is a guide for starting your own custom Ethereum blockchain on Mac, not to be confused with starting a node on the main Ethereum blockchain. Here we are starting an entirely new and separate blockchain that cannot interact with Ethereum mainnet.Starting your own Ethereum blockchain is useful, educational, and safer than the public testnet. Learning to set up a private testnet provides tangibility to otherwise abstract concepts such as mining, network peers, and even the geth datadir. <h3><strong>Prerequisites <p dir="auto">You need to have Geth installed. The easiest way to do this is through homebrew. <ol> <li>Open Terminal and <a href="https://brew.sh/" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">install homebrew <pre><code>ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" <p dir="auto">2. Now <a href="https://www.ethereum.org/cli" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">install geth <pre><code>brew tap ethereum/ethereum<br /> <br /> brew install ethereum <h3><strong>Create Genesis File <p dir="auto">The Genesis <strong>block is the first block in the chain, the Genesis <strong>file is a JSON file that defines the characteristics of that initial block and subsequently the rest of the blockchain. <ol> <li>Create a directory to hold your network files <pre><code>mkdir my-eth-chain<br /> <br /> cd my-eth-chain <p dir="auto">2. Create your genesis file <pre><code>touch myGenesis.json <p dir="auto">3. Open your genesis file and paste the following <pre><code>{<br /> <br /> "config": {<br /> <br /> "chainId": 1994,<br /> <br /> "homesteadBlock": 0,<br /> <br /> "eip155Block": 0,<br /> <br /> "eip158Block": 0,<br /> <br /> "byzantiumBlock": 0<br /> <br /> },<br /> <br /> "difficulty": "400",<br /> <br /> "gasLimit": "2000000",<br /> <br /> "alloc": {<br /> <br /> "7b684d27167d208c66584ece7f09d8bc8f86ffff": { <br /> <br /> "balance": "100000000000000000000000" <br /> <br /> },<br /> <br /> "ae13d41d66af28380c7af6d825ab557eb271ffff": { <br /> <br /> "balance": "120000000000000000000000" <br /> <br /> }<br /> <br /> }<br /> <br /> } <h4>config <ul> <li>chainId — this is your chain’s identifier, and is used in replay protection. <li>homesteadBlock, eip155Block, eip158Block, byzantiumBlock — these relate to chain forking and versioning, so in our case lets leave them 0 since we’re starting a new blockchain. <h4>difficulty <p dir="auto">This dictates how difficult it is to mine a block. Setting this value low (~10–10000) is helpful in a private blockchain as it lets you mine blocks quickly, which equals fast transactions, and plenty of ETH to test with. For comparison, the Ethereum mainnet Genesis file defines a difficulty of 17179869184. <h4>gasLimit <p dir="auto">This is the the total amount of gas that can be used in each block. With such a low mining difficulty, blocks will be moving pretty quick, but you should still set this value pretty high to avoid hitting the limit and slowing down your network. <h4>alloc <p dir="auto">Here you can allocate ETH to specific addresses. This won’t create the account for you, so make sure its an account you already have control of. You will need to add the account to your private chain in order to use it, and to do that you need access to the keystore/utc file. For example, Geth and <a href="https://www.myetherwallet.com/" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">MyEtherWalletgive you access to this file when you create an account, but <a href="https://metamask.io/" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Metamask and <a href="https://www.coinbase.com/" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Coinbase do not. The addresses provided are not real addresses, they are just examples. Here we allocate 100,000 and 120,000 ETH respectively. <h3>Start your Node! <p dir="auto">Now the real fun begins, we’re all set to fire up our new Ethereum blockchain. <h4>1. Instantiate your data directory <pre><code>geth --datadir ./myDataDir init ./myGenesis.json <h4>2. Start your Ethereum peer node. <p dir="auto">Networkid helps ensure the privacy of your network. You can use any number here (where we used “1114”), but other peers joining your network must use the same one. <pre><code>geth --datadir ./myDataDir --networkid 1114 console 2>> myEth.log <p dir="auto">Output should look like this: <pre><code>Welcome to the Geth JavaScript console! <pre><code>instance: Geth/v1.7.3-stable-4bb3c89d/darwin-amd64/go1.8.3<br /> <br /> coinbase: 0xae13d41d66af28380c7af6d825ab557eb271ffff<br /> <br /> at block: 5 (Thu, 07 Dec 2017 17:08:48 PST)<br /> <br /> datadir: /Users/test/my-eth-chain/myDataDir<br /> <br /> modules: admin:1.0 clique:1.0 debug:1.0 eth:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 txpool:1.0 web3:1.0 <pre><code>> <p dir="auto">This is the geth JavaScript console. Any command with the symbol <code>> should be typed here. <h4>3. Display your Ethereum logs <ul> <li>Open another terminal window <li>cd to <code>my-eth-chain <li>Type <code>tail -f myEth.log <h4>4. Import/Create an Account <ul> <li>If you allocated ETH in the Genesis file, import the corresponding account by dragging the <a href="https://myetherwallet.github.io/knowledge-base/getting-started/backing-up-your-new-wallet.html" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">UTC file into the <code>myDataDir/keystoredirectory and skip to step 5. <li>In the geth JavaScript console, create an account:<br /> <code>> personal.newAccount("<YOUR_PASSPHRASE>") <li>Do not forget this passphrase! You will be typing this a lot, so for this test network you can keep it simple. <h4>5. Set Default Account <ul> <li>Check your default account, type<br /> <code>> eth.coinbase <li>If this address is the same as the one from step 4, skip the rest of step 5. <li>To set your default account, type <br /> <code>> miner.setEtherbase(web3.eth.accounts[0]) <h4>6. Start mining <ul> <li>Check your balance with <br /> <code>> eth.getBalance(eth.coinbase) <li>Run <br /> <code>> miner.start() <li>Look at your other terminal window, you should see some mining action in the logs. Check your balance again and it should be higher. <li>To end mining, type <br /> <code>> miner.stop() <h3><strong>Optional: Add Other Peers <p dir="auto">Add more nodes to your private Ethereum network. <h4>1. Start another peer <ul> <li>On your same machine instantiate a new datadir: <pre><code>geth --datadir ./peer2DataDir init ./myGenesis.json <ul> <li>Launch the 2nd peer on a different port: <pre><code>geth --datadir ./peer2DataDir --networkid 1114 --port 30304 console 2>> myEth2.log <h4>2. Display your Ethereum logs <ul> <li>Open another terminal window <li>cd to <code>my-eth-chain <li>Type <code>tail -f myEth2.log <h4>3. Join the 1st peer <ul> <li>In the geth JavaScript console of your 1st peer, type: <pre><code>> admin.nodeInfo.enode <ul> <li>Output will look like this: <code>“enode://dcff6d9dcb14eeb1d1b7575b0653fa1025ad1b7722c6d652d0449f0966e97931bdf037e5542086e7b9e0bec056566522c6c0cc4d73d8e4186a35da8aa5988e15@[::]:30303” <li>In the geth JavaScript console of your new 2nd peer, type: <pre><code>> admin.addPeer( “enode://<a href="http://b56882b93f4f97dd69f98c1dca1bd751c72374b5a8b5852288a56059a8cbc63614afd57274cfa7695178cf292aad9e682f0117044f9a28c9e098da688c8dfd89@192.168.1.174:30303/" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">b56882b93f4f97dd69f98c1dca1bd751c72374b5a8b5852288a56059a8cbc63614afd57274cfa7695178cf292aad9e682f0117044f9a28c9e098da688c8dfd89@127.0.0.1:30303” ) <ul> <li>Make sure you replace <code>“enode://…@” above with the output from <code>admin.nodeInfo.enode which is specific to you. As shown above, the “<code>[::]” is replaced with “<code>127.0.0.1:30303” which is the IP:Port of the 1st peer. <h4>4. Verify your nodes are now communicating <ul> <li>In the geth JavaScript console of your new 2nd peer, type: <pre><code>> admin.peers <ul> <li>Output should show that peer 2 is connected to<code>127.0.0.1:30303 <h3><strong>Helpful: geth console commands <p dir="auto">admin.nodeInfo.enode<br /> net.listening<br /> net.peerCount<br /> admin.peers<br /> eth.coinbase<br /> eth.getBalance(eth.coinbase)<br /> personal<br /> eth.accounts<br /> miner.setEtherbase(web3.eth.accounts[0])<br /> miner.setEtherbase(“0xae13d41d66af28380c7af6d825ab557eb271ffff”)<br /> miner.start()<br /> miner.stop()<br /> miner.hashrate<br /> eth.getBlock(0)<br /> eth.getBlock(“latest”)<br /> eth.blockNumber <br /> web3.eth.getBlock(BLOCK_NUMBER).hash<br /> eth.syncing<br /> debug.verbosity(6) // highest logging level, 3 is default<strong>Share your thoughts with us in any of the community channels linked below!
Hi! I am a robot. I just upvoted you! I found similar content that readers might be interested in:
https://medium.com/mercuryprotocol/how-to-create-your-own-private-ethereum-blockchain-dad6af82fc9f
like