[{"data":1,"prerenderedAt":326},["Reactive",2],{"content-query-hlFMir8nkU":3},{"_path":4,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":8,"description":9,"body":10,"_type":321,"_id":322,"_source":323,"_file":324,"_extension":325},"/docs/dev/running-local-blockchain","dev",false,"","Running local blockchain","In this tutorial we will explain how to run local blockchain. It will be extremely useful for testing your dapps locally, before deplying them to public networks",{"type":11,"children":12,"toc":314},"root",[13,21,26,33,45,51,56,66,71,76,87,92,97,106,111,120,125,131,154,159,167,187,192,201,206,219,224,234,239,244,253,258,268,273,282,287,297,302],{"type":14,"tag":15,"props":16,"children":18},"element","h1",{"id":17},"running-local-blockchain",[19],{"type":20,"value":8},"text",{"type":14,"tag":22,"props":23,"children":24},"p",{},[25],{"type":20,"value":9},{"type":14,"tag":27,"props":28,"children":30},"h3",{"id":29},"download-node-and-wallet",[31],{"type":20,"value":32},"Download node and wallet",{"type":14,"tag":22,"props":34,"children":35},{},[36,38],{"type":20,"value":37},"Create an empty folder (called dappnet in our examples) and download the binaries for the node and CLI wallet from ",{"type":14,"tag":39,"props":40,"children":42},"a",{"href":41},"/downloads/dappnet",[43],{"type":20,"value":44},"beam website",{"type":14,"tag":27,"props":46,"children":48},{"id":47},"initialize-wallet",[49],{"type":20,"value":50},"Initialize wallet",{"type":14,"tag":22,"props":52,"children":53},{},[54],{"type":20,"value":55},"First, let's change the wallet configuration file to make everything easy and seamless when we run it later. Edit the beam-wallet.cfg file and set the following flags:",{"type":14,"tag":57,"props":58,"children":60},"pre",{"code":59},"\n# General options:\n################################################################################\n\n# log level [info|debug|verbose]\nlog_level=debug\n\n# file log level [info|debug|verbose]\n# file_log_level=debug\n\n# old logs cleanup period (days)\n# log_cleanup_days=5\n\n################################################################################\n# Wallet options:\n################################################################################\n\n# password for the wallet\npass=123\n\n# phrase to generate secret key according to BIP-39.\n# seed_phrase=\n\n# address of node\nnode_addr=127.0.0.1:8100\n\n# path to wallet file\nwallet_path=wallet.db\n\nMaturity.Coinbase=0\n\n# command to execute [new_addr|send|receive|listen|init|info|export_miner_key|export_owner_key|generate_phrase]\n# command=listen\n\n\n",[61],{"type":14,"tag":62,"props":63,"children":64},"code",{"__ignoreMap":7},[65],{"type":20,"value":59},{"type":14,"tag":22,"props":67,"children":68},{},[69],{"type":20,"value":70},"Note the Maturity.Coinbase=0 flag. It means that you can spend coinbase rewards immediately (unlike the 60 block lockup in mainnet) It is useful for testing in a local environment, since you do not have to wait for your mined rewards to before available",{"type":14,"tag":22,"props":72,"children":73},{},[74],{"type":20,"value":75},"Now let's move on to wallet initialization. Run",{"type":14,"tag":22,"props":77,"children":78},{},[79,85],{"type":14,"tag":62,"props":80,"children":82},{"className":81},[],[83],{"type":20,"value":84},"beam-wallet-dappnet.exe init",{"type":20,"value":86},"  (or ./beam-wallet-dappnet on Mac)",{"type":14,"tag":22,"props":88,"children":89},{},[90],{"type":20,"value":91},"Save the generated seed phase somewhere in a text file ( we might need it later)",{"type":14,"tag":22,"props":93,"children":94},{},[95],{"type":20,"value":96},"Now print the owner key by running:",{"type":14,"tag":22,"props":98,"children":99},{},[100],{"type":14,"tag":62,"props":101,"children":103},{"className":102},[],[104],{"type":20,"value":105},"beam-wallet-dappnet.exe export_owner_key",{"type":14,"tag":22,"props":107,"children":108},{},[109],{"type":20,"value":110},"And last generate the mining key by running",{"type":14,"tag":22,"props":112,"children":113},{},[114],{"type":14,"tag":62,"props":115,"children":117},{"className":116},[],[118],{"type":20,"value":119},"beam-wallet-dappnet.exe export_miner_key --subkey=1",{"type":14,"tag":22,"props":121,"children":122},{},[123],{"type":20,"value":124},"Save both keys in the same file as the seed phrase",{"type":14,"tag":27,"props":126,"children":128},{"id":127},"initializing-the-node",[129],{"type":20,"value":130},"Initializing the Node",{"type":14,"tag":22,"props":132,"children":133},{},[134,136,144,146,152],{"type":20,"value":135},"Before we start configuring the node, download sample Beam treasury file ",{"type":14,"tag":39,"props":137,"children":141},{"href":138,"rel":139},"https://github.com/BeamMW/beam/blob/master/treasury.bin",[140],"nofollow",[142],{"type":20,"value":143},"treasury.bin",{"type":20,"value":145},", and copy it to the same folder as the ",{"type":14,"tag":62,"props":147,"children":149},{"className":148},[],[150],{"type":20,"value":151},"beam-node",{"type":20,"value":153}," binary.",{"type":14,"tag":22,"props":155,"children":156},{},[157],{"type":20,"value":158},"Now, open beam-node.cfg file in a text editor and set the following flags:",{"type":14,"tag":57,"props":160,"children":162},{"code":161},"################################################################################\n# General options:\n################################################################################\n\n# port to start server on\nport=8100\n\n# log level [info|debug|verbose]\nlog_level=debug\n\n# file log level [info|debug|verbose]\nfile_log_level=debug\n\n# old logs cleanup period (days)\n# log_cleanup_days=5\n\n################################################################################\n# Node options:\n################################################################################\n\n# node storage path\n# storage=node.db\n\n# nodes to connect to !!! MUST BE EMPTY !!!\n# peer=\n\n# port to start stratum server on\n# stratum_port=0\n\n# path to stratum server api keys file, and tls certificate and private key\n# stratum_secrets_path=.\n\n# Enforce re-synchronization (soft reset)\n# resync=0\n\n# Owner viewer key\nowner_key=\u003Cyour owner key>\n\n# Standalone miner key\nminer_key=\u003Cyour miner key>\n\n# password for keys\npass=123\n\n# Fork1 height\n# Fork1=\n\n# Path to treasury for testing\ntreasury_path=treasury.bin\n\n# Enables the node to produce blocks\nmining_threads=1\n\nMaturity.Coinbase=0\n\n\n",[163],{"type":14,"tag":62,"props":164,"children":165},{"__ignoreMap":7},[166],{"type":20,"value":161},{"type":14,"tag":168,"props":169,"children":170},"ol",{},[171,177,182],{"type":14,"tag":172,"props":173,"children":174},"li",{},[175],{"type":20,"value":176},"Make sure to set miner and owner keys to those generated by your wallet",{"type":14,"tag":172,"props":178,"children":179},{},[180],{"type":20,"value":181},"Make sure peer list is empty (to avoid accidental connections to other nodes)",{"type":14,"tag":172,"props":183,"children":184},{},[185],{"type":20,"value":186},"Check that mining_threads flag is set to 1",{"type":14,"tag":22,"props":188,"children":189},{},[190],{"type":20,"value":191},"We are now ready to run the node using the command:",{"type":14,"tag":22,"props":193,"children":194},{},[195],{"type":14,"tag":62,"props":196,"children":198},{"className":197},[],[199],{"type":20,"value":200},"beam-node-dappnet.exe",{"type":14,"tag":22,"props":202,"children":203},{},[204],{"type":20,"value":205},"Sample output should look something like this",{"type":14,"tag":207,"props":208,"children":209},"figure",{},[210,215],{"type":14,"tag":211,"props":212,"children":214},"img",{"src":213,"alt":7},".gitbook/assets/image.png",[],{"type":14,"tag":216,"props":217,"children":218},"figcaption",{},[],{"type":14,"tag":22,"props":220,"children":221},{},[222],{"type":20,"value":223},"Wait for about 30 seconds to make sure new blocks are produced. A new block shoud appear every 15 seconds or so",{"type":14,"tag":207,"props":225,"children":226},{},[227,231],{"type":14,"tag":211,"props":228,"children":230},{"src":229,"alt":7},".gitbook/assets/image (3).png",[],{"type":14,"tag":216,"props":232,"children":233},{},[],{"type":14,"tag":22,"props":235,"children":236},{},[237],{"type":20,"value":238},"Synchronizing the wallet",{"type":14,"tag":22,"props":240,"children":241},{},[242],{"type":20,"value":243},"In another command line (or Terminal) window, run the CLI wallet with the following command:",{"type":14,"tag":22,"props":245,"children":246},{},[247],{"type":14,"tag":62,"props":248,"children":250},{"className":249},[],[251],{"type":20,"value":252},"beam-wallet-dappnet.exe listen",{"type":14,"tag":22,"props":254,"children":255},{},[256],{"type":20,"value":257},"This will synchronize the wallet state with the blockchain. Your output should read something like:",{"type":14,"tag":207,"props":259,"children":260},{},[261,265],{"type":14,"tag":211,"props":262,"children":264},{"src":263,"alt":7},".gitbook/assets/image (24).png",[],{"type":14,"tag":216,"props":266,"children":267},{},[],{"type":14,"tag":22,"props":269,"children":270},{},[271],{"type":20,"value":272},"Stop the wallet (by clicking Ctrl + C) and check your current balance by running:",{"type":14,"tag":22,"props":274,"children":275},{},[276],{"type":14,"tag":62,"props":277,"children":279},{"className":278},[],[280],{"type":20,"value":281},"beam-wallet-dappnet.exe info",{"type":14,"tag":22,"props":283,"children":284},{},[285],{"type":20,"value":286},"You should see the mined BEAM coins in your wallet",{"type":14,"tag":207,"props":288,"children":289},{},[290,294],{"type":14,"tag":211,"props":291,"children":293},{"src":292,"alt":7},".gitbook/assets/image (26).png",[],{"type":14,"tag":216,"props":295,"children":296},{},[],{"type":14,"tag":22,"props":298,"children":299},{},[300],{"type":20,"value":301},"You now have a local network!",{"type":14,"tag":22,"props":303,"children":304},{},[305,307],{"type":20,"value":306},"For a full reference on Beam CLI wallet see the ",{"type":14,"tag":39,"props":308,"children":311},{"href":309,"rel":310},"https://beamx.gitbook.io/cli-guide/",[140],[312],{"type":20,"value":313},"CLI Wallet Guide",{"title":7,"searchDepth":315,"depth":315,"links":316},2,[317,319,320],{"id":29,"depth":318,"text":32},3,{"id":47,"depth":318,"text":50},{"id":127,"depth":318,"text":130},"markdown","docs:docs:dev:running-local-blockchain.md","docs","docs/dev/running-local-blockchain.md","md",1777630727718]