{"id":2607,"date":"2019-12-25T09:39:45","date_gmt":"2019-12-24T20:39:45","guid":{"rendered":"http:\/\/www.talkcrypto.org\/blog\/?p=2607"},"modified":"2020-02-14T00:22:08","modified_gmt":"2020-02-13T11:22:08","slug":"installing-besu-quick-commands","status":"publish","type":"post","link":"https:\/\/www.talkcrypto.org\/blog\/2019\/12\/25\/installing-besu-quick-commands\/","title":{"rendered":"Installing Besu quick commands"},"content":{"rendered":"\n<pre class=\"wp-block-preformatted\">besu --version \/\/check if  Besu is  installed<br>brew uninstall besu \/\/uninstall Besu<br>brew install besu \/\/install Besu (assuming you have already tapped it first with brew tap hyperledger\/besu)<br>brew cask install adoptopenjdk<br><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Starting Besu<\/h2>\n\n\n\n<p>To start Besu, just type<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">besu<\/pre>\n\n\n\n<p>This will start Besu pointing it to mainnet. This means that the blockchain will start to synchronise with the real Ethereum blockchain. A database folder (where the blockchain will be stored) will appear at usr\/local\/Cellar\/besu\/1.3.8\/ which is where homebrew installed besu.<\/p>\n\n\n\n<p>For testing purposes, start Besu with the network flag of dev<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">besu --network=dev<\/pre>\n\n\n\n<p>The other option is to use a config file and then specific the network, as well as other parameters there. <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">data-path=\"besudata\"<br>network=\"dev\"<br>miner-enabled=true<br>miner-coinbase=\"0xfe3b557e8fb62b89f4916b721be55ceb828dbd73\"<br>rpc-http-cors-origins=[\"all\"]<br>host-whitelist=[\"*\"]<br>rpc-ws-enabled=true<br>rpc-http-enabled=true<\/pre>\n\n\n\n<p>Then reference the config file with:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">besu --config-file=\"\/User\/sean\/config.toml\"<br><\/pre>\n\n\n\n<p>Note that flags in the command line override flags in the config file. For a complete list of other command line options, visit: <a href=\"http:\/\/besu.hyperledger.org\/en\/stable\/Reference\/CLI\/CLI-Syntax\/\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"http:\/\/besu.hyperledger.org\/en\/stable\/Reference\/CLI\/CLI-Syntax\/ (opens in a new tab)\">http:\/\/besu.hyperledger.org\/en\/stable\/Reference\/CLI\/CLI-Syntax\/<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Checking Besu network<\/h2>\n\n\n\n<p>To confirm the network you are connected to, you want to query the Besu API for the net_version. <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">curl -X POST --data '{\"jsonrpc\":\"2.0\",\"method\":\"net_version\",\"params\":[],\"id\":1}' localhost:8545<\/pre>\n\n\n\n<p>You can find out what <a rel=\"noreferrer noopener\" aria-label=\"net_version (opens in a new tab)\" href=\"http:\/\/besu.hyperledger.org\/en\/stable\/Reference\/API-Methods\/#net_version\" target=\"_blank\">net_version<\/a> does along with all the other API options <a href=\"http:\/\/besu.hyperledger.org\/en\/stable\/Reference\/API-Methods\/\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"here (opens in a new tab)\">here<\/a>.<\/p>\n\n\n\n<p>However, in order for this to work, Besu must be started with the flag:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">--rpc-http-enabled<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Exercise<\/h4>\n\n\n\n<p>Enable rpc-http in a config file, but override it in the command line and prove that the override was successful<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">besu --config-file=\/Users\/sean\/config.toml --rpc-http-enabled=\"false\"<\/pre>\n\n\n\n<p>Running the following curl command should yield a &#8220;failed to connect error&#8221;. <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">curl -X POST --data '{\"jsonrpc\":\"2.0\",\"method\":\"net_version\",\"params\":[],\"id\":45}' localhost:8545<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">curl: (7) Failed to connect to localhost port 8545: Connection refused<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Changing the Besu network<\/h2>\n\n\n\n<p>So far we have specified the development network with the flag<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">--network=dev (or in the config file as network=\"dev\")<\/pre>\n\n\n\n<p>or omitting the flag defaults to mainnet. However, there are 6 other <a rel=\"noreferrer noopener\" aria-label=\"networks (opens in a new tab)\" href=\"http:\/\/besu.hyperledger.org\/en\/stable\/Reference\/CLI\/CLI-Syntax\/#network\" target=\"_blank\">networks<\/a> that can be chosen. Ropsten, Rinkeby, Goerli, Classic, Mordor and Kotti. eg:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">besu --network=ropsten<\/pre>\n\n\n\n<p><strong>Fun fact:<\/strong> &#8220;Testnets are named after <a href=\"https:\/\/ethereum.stackexchange.com\/questions\/29194\/why-are-the-rinkeby-and-ropsten-testnets-named-after-swedish-locations\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"train stations (opens in a new tab)\">train stations<\/a> as a convention, usually where the respective testnet maintainers are based from.&#8221; <\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Morden: a subway station in London<\/li><li>Ropsten: a metro station in Stockholm<\/li><li>Rinkeby: a metro station in Stockholm<\/li><li>Kovan: a subway station in Singapore<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Changing the data dir<\/h2>\n\n\n\n<p>It is advisable to change the <a href=\"http:\/\/besu.hyperledger.org\/en\/stable\/Reference\/CLI\/CLI-Syntax\/#data-path\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"data directory (opens in a new tab)\">data directory<\/a> to another location of your choice. This is because it can get quite large. Use  the flag:<\/p>\n\n\n\n<p>&#8211;data-path=&lt;PATH&gt;<\/p>\n\n\n\n<p>For a complete list of Besu command line, visit  <a href=\"http:\/\/besu.hyperledger.org\/en\/stable\/Reference\/CLI\/CLI-Syntax\/\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"http:\/\/besu.hyperledger.org\/en\/stable\/Reference\/CLI\/CLI-Syntax\/ (opens in a new tab)\">http:\/\/besu.hyperledger.org\/en\/stable\/Reference\/CLI\/CLI-Syntax\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>besu &#8211;version \/\/check if Besu is installedbrew uninstall besu \/\/uninstall<\/p>\n","protected":false},"author":1,"featured_media":2608,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-2607","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ethereum"],"featured_image_urls":{"full":["https:\/\/www.talkcrypto.org\/blog\/wp-content\/uploads\/2019\/12\/Hyperledger_Besu_194.jpg",194,61,false],"thumbnail":["https:\/\/www.talkcrypto.org\/blog\/wp-content\/uploads\/2019\/12\/Hyperledger_Besu_194-150x61.jpg",150,61,true],"medium":["https:\/\/www.talkcrypto.org\/blog\/wp-content\/uploads\/2019\/12\/Hyperledger_Besu_194.jpg",194,61,false],"medium_large":["https:\/\/www.talkcrypto.org\/blog\/wp-content\/uploads\/2019\/12\/Hyperledger_Besu_194.jpg",194,61,false],"large":["https:\/\/www.talkcrypto.org\/blog\/wp-content\/uploads\/2019\/12\/Hyperledger_Besu_194.jpg",194,61,false],"1536x1536":["https:\/\/www.talkcrypto.org\/blog\/wp-content\/uploads\/2019\/12\/Hyperledger_Besu_194.jpg",194,61,false],"2048x2048":["https:\/\/www.talkcrypto.org\/blog\/wp-content\/uploads\/2019\/12\/Hyperledger_Besu_194.jpg",194,61,false],"chromenews-featured":["https:\/\/www.talkcrypto.org\/blog\/wp-content\/uploads\/2019\/12\/Hyperledger_Besu_194.jpg",194,61,false],"chromenews-large":["https:\/\/www.talkcrypto.org\/blog\/wp-content\/uploads\/2019\/12\/Hyperledger_Besu_194.jpg",194,61,false],"chromenews-medium":["https:\/\/www.talkcrypto.org\/blog\/wp-content\/uploads\/2019\/12\/Hyperledger_Besu_194.jpg",194,61,false]},"author_info":{"info":["seandotau"]},"category_info":"<a href=\"https:\/\/www.talkcrypto.org\/blog\/category\/ethereum\/\" rel=\"category tag\">Ethereum<\/a>","tag_info":"Ethereum","comment_count":"0","_links":{"self":[{"href":"https:\/\/www.talkcrypto.org\/blog\/wp-json\/wp\/v2\/posts\/2607","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.talkcrypto.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.talkcrypto.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.talkcrypto.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.talkcrypto.org\/blog\/wp-json\/wp\/v2\/comments?post=2607"}],"version-history":[{"count":5,"href":"https:\/\/www.talkcrypto.org\/blog\/wp-json\/wp\/v2\/posts\/2607\/revisions"}],"predecessor-version":[{"id":2624,"href":"https:\/\/www.talkcrypto.org\/blog\/wp-json\/wp\/v2\/posts\/2607\/revisions\/2624"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.talkcrypto.org\/blog\/wp-json\/wp\/v2\/media\/2608"}],"wp:attachment":[{"href":"https:\/\/www.talkcrypto.org\/blog\/wp-json\/wp\/v2\/media?parent=2607"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.talkcrypto.org\/blog\/wp-json\/wp\/v2\/categories?post=2607"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.talkcrypto.org\/blog\/wp-json\/wp\/v2\/tags?post=2607"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}