{"id":15407186,"url":"https://github.com/ltfschoen/geth-node","last_synced_at":"2025-04-18T03:16:50.911Z","repository":{"id":76620057,"uuid":"115693418","full_name":"ltfschoen/geth-node","owner":"ltfschoen","description":"Deploy FixedSupplyToken to Private Network with Web3.js or Web3.py, Geth and Mist","archived":false,"fork":false,"pushed_at":"2018-01-14T07:28:33.000Z","size":104,"stargazers_count":7,"open_issues_count":1,"forks_count":5,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-29T06:21:39.840Z","etag":null,"topics":["ethereum","geth-node","mist","private-blockchain","promise-all","solidity-contracts","web3js"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ltfschoen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-12-29T06:18:52.000Z","updated_at":"2018-12-04T02:27:25.000Z","dependencies_parsed_at":null,"dependency_job_id":"52d2afe9-bedf-4a69-878b-c46bfedd49f9","html_url":"https://github.com/ltfschoen/geth-node","commit_stats":{"total_commits":15,"total_committers":2,"mean_commits":7.5,"dds":0.06666666666666665,"last_synced_commit":"474a687ccd15b227bbe7f52cef8b84d6e552d13d"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ltfschoen%2Fgeth-node","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ltfschoen%2Fgeth-node/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ltfschoen%2Fgeth-node/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ltfschoen%2Fgeth-node/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ltfschoen","download_url":"https://codeload.github.com/ltfschoen/geth-node/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249419319,"owners_count":21268606,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ethereum","geth-node","mist","private-blockchain","promise-all","solidity-contracts","web3js"],"created_at":"2024-10-01T16:27:31.231Z","updated_at":"2025-04-18T03:16:50.904Z","avatar_url":"https://github.com/ltfschoen.png","language":"JavaScript","readme":"# Fast Setup (only after previously setting up using the \"Slow Setup\")\n\n* Change the Shell script to match the directory that you setup in the \"Slow Setup\" steps.\n\n* Run the Shell script to automatically run a Geth Node in a terminal tab, launches MIST that waits 5 seconds before trying to attach to the Geth Node from a second terminal tab, waits 5 seconds before trying to run a Geth JavaScript Console that attaches to the Geth Node in a third terminal tab, and opens Visual Studio Code from a fourth terminal tab.\n  ```shell\n  bash launch.sh\n  ```\n\n* Click \"Launch Application\" in MIST \n\n* Go to \"Contracts\"\n\n* Click \"Deploy Contracts\"\n\n* Copy/paste a Solidity Smart Contract into the \"SOLIDITY CONTRACT SOURCE CODE\" section to check if it compiles\n\n# Slow Setup\n\n* Setup Geth Node (independent of MIST or Parity) as an Ethereum client using Ethereum Protocol that allows for interaction with the Private Network blockchain.\n\n* Make a directory\n  ```\n  mkdir /Users/Ls/code/blockchain/geth-node;\n  cd /Users/Ls/code/blockchain/geth-node\n  ```\n\n* Create genesis.json file and chaindata/ folder, where:\n  * `coinbase` is where mining goes to\n  * `difficulty` is difficulty to mine a new block (`0x20000` is fast)\n  * `gasLimit` is upper limit to the amount of assembler OPCODEs a miner is allowed to perform for transactions on blockchain that require payment of gas to miners\n  * `timestamp` - defines the time when this block was generated (i.e. `0x00` is ~1970 epoch)\n  * `alloc` - used to add Ether to pre-allocated accounts\n  * `config` - \n    * `chainID` - do not set to `1` since this is the main net\n\n* Initial genesis.json\n\n```\n{\n  \"coinbase\"   : \"0x0000000000000000000000000000000000000001\",\n  \"difficulty\" : \"0x20000\",\n  \"extraData\"  : \"\",\n  \"gasLimit\"   : \"0x8000000\",\n  \"nonce\"      : \"0x0000000000000042\",\n  \"mixhash\"    : \"0x0000000000000000000000000000000000000000000000000000000000000000\",\n  \"parentHash\" : \"0x0000000000000000000000000000000000000000000000000000000000000000\",\n  \"timestamp\"  : \"0x00\",\n  \"alloc\": {},\n  \"config\": {\n        \"chainId\": 15,\n        \"homesteadBlock\": 0,\n        \"eip155Block\": 0,\n        \"eip158Block\": 0\n    }\n}\n```\n\n* Terminal Tab #1 - Initialise Private Network and configure Geth to save blockchain data with Genesis Block inside the chaindata/ folder, informing Geth where genesis.json blockchain configuration is located (cannot be in chaindata/)\n\n```\ngeth --datadir=./chaindata/ init ./genesis.json\n```\n\n* Terminal Tab #1 - Start Geth Node using ./chaindata/ folder. It starts the network with same Chain ID as defined in the genesis.json file. Geth listens for incoming connections on port 30303 using an IPC file geth.ipc that is created when it is running to allow processes to connect to Geth (i.e. with `geth attach`, MIST / Ethereum Wallet). With the Private Network it has no other Nodes and nothing to synchronise. Note: Verbosity of 3 is recommended.\n```\ngeth --datadir=./chaindata/ --verbosity 5\n```\n\n* Terminal Tab #2 - Use MIST to run Ethereum Wallet Dapp in MIST browser at http://wallet.ethereum.org. MIST binds Web3 to `window` object to inject it into the browser so Web3.js may be used to manage accounts (i.e. allows selecting one account from `web3.eth.accounts` to be visible in MIST via localhost:8545 by clicking the Manage Identity button), deploy or interact with contracts\n\n* Add MIST to PATH - https://trello.com/c/XaTEDu12/97-mist-setup-macos\n\n* Terminal Tab #2 - Start MIST after Geth running. Ensure to identify where the IPC file location of the Private Chain is to MIST (to avoid error `Fatal: Error starting protocol stack: listen udp :30303: bind: address already in use`).\n  \n  * Warning: Using loglevel \"trace\" uses creates a very large geth.log file quickly\n\n```\ncd /Users/Ls/code/blockchain/geth-node;\n\n/Applications/Mist.app/Contents/MacOS/mist --help\n\nopen -a mist --args --mode \"mist\" \\\n  --node \"geth\" \\\n  --gethpath \"/usr/local/bin/geth\" \\\n  --rpc \"/Users/Ls/code/blockchain/geth-node/chaindata/geth.ipc\" \\\n  --node-ipcpath \"/Users/Ls/code/blockchain/geth-node/chaindata/geth.ipc\" \\\n  --node-datadir \"/Users/Ls/code/blockchain/geth-node/chaindata/geth.ipc\" \\\n  --logfile \"/Users/Ls/code/blockchain/geth-node/geth.log\" \\\n  --loglevel \"trace\" \\\n  --skiptimesynccheck true\n```\n\n* Terminal Tab #3 - View Logs\n\n  ```\n  cd /Users/Ls/code/blockchain/geth-node;\n  tail -f ./geth.log;\n  ```\n\n* In MIST click \"LAUNCH APPLICATION\" button shown in the popup\n\n* Terminal Tab #2 - Identify the IPC file location to Geth after MIST launches and Launch Application has been clicked, to load the JavaScript RPC Geth Console (JSRE REPL) on the already running Geth instance (communication with Geth through RPC on port 8545).\n  * Note: MIST's default is `geth attach ipc:/Users/Ls/Library/Ethereum/geth.ipc`\n  * Reference: https://github.com/ethereum/go-ethereum/wiki/JavaScript-Console\n\n  * Custom Private Chain\n\n```\ngeth attach --help;\ngeth attach \"/Users/Ls/code/blockchain/geth-node/chaindata/geth.ipc\" \n```\n\n    * Outputs the following\n\n``` \nWelcome to the Geth JavaScript console!\n\ninstance: Geth/v1.7.3-stable/darwin-amd64/go1.9.2\n modules: admin: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\n\n\u003e web3.eth.accounts\n[]\n```\n\n* In MIST go to the Wallet Tab\n  * Click \"Add Account\"\n  * Click \"Create new account\"\n  * Enter a password (i.e. test123456)\n    * Note: This shows a popup: \n\n      \u003e \"Make sure you backup your keyfiles AND password! You can find your keyfiles folder using the main menu -\u003e Accounts -\u003e Backup -\u003e Accounts. Keep a copy of the \"keystore\" folder where you can't lose it!\"\n\n    * Note: It will create the Wallet file in the directory /Users/Ls/code/blockchain/geth-node/chaindata/keystore/UTC--2017-12-29xxxxxxxxxxx--\u003cACCOUNT_NUMBER_WITHOUT_0x_PREFIX\u003e\n  * Click the new account \"Main account (Etherbase) 0x\u003cACCOUNT_NUMBER\u003e\" and \n  then click \"AUTHORIZE\" to share the identity with Ethereum Wallet DApp (giving it permission to view public account information including accounts and balances)\n  * Now in the Wallet Tab under the heading \"WALLET CONTRACTS\" it says: \n\n    \u003e \"Once you have more than 1 Ether you can create more sophisticated contracts. Wallets are smart contracts that allow your funds to be controlled by multiple accounts. They can have an optional daily limit on withdrawals to increase security. Create your own custom contracts on the Contracts tab.\"\n\n* Terminal Tab #2 - Use Geth JavaScript console to show the Accounts using Web3.js:\n\n```\n\u003e web3.eth.accounts\n[\"0x\u003cACCOUNT_NUMBER\u003e\"]\n```\n\n* Terminal Tab #2 - Start Mining in the Private Network to earn Ether so we may create custom Contracts in the Contracts Tab of MIST. Enter the amount of threads it should start mining with:\n\n```\n\u003e miner.start(1); \n```\n  \n* Optional Alternative: Try downloading EthMiner, which also supports GPU mining with `ethminer -G`. \n  * Reference: https://github.com/ethereum-mining/ethminer/releases\n\n* Wait about 5 minutes for the DAG to generate before CPU mining starts, since it must first generate the DAG (see `Generating DAG in progress` in Geth logs with a percentage complete shown i.e. `epoch=1 percentage=42`). Reference: https://github.com/ethereum/wiki/wiki/Mining\n\n* In MIST and Terminal Tab #1 - Check latest Block being mined until Account has an Ether balance of at least 1 ETH\n\n* Terminal Tab #2 - Stop Mining\n\n```\n\u003e miner.stop();\n```\n\n* In MIST, Deploy the FixedSupplyContract.sol code to the Private Network.\n  * Check how much Ether we have CPU mined (say 50 ETH)\n  * Go to \"Contracts\" tab\n    * Click \"Deploy New Contract\" button\n      * Select the new Account for the \"FROM\" field value\n      * Do not send any Ether\n      * Copy/Paste the Sample FixedSupplyContract.sol code into \"SOLIDITY CONTRACT SOURCE CODE\" text field value\n      * MIST compiles the Solidity Contract to Bytecode\n      * Select the \"Fixed Supply Token\" interface as the Contract to Deploy\n      * Click \"DEPLOY\"\n      * Click \"SEND TRANSACTION\"\n      * Go to Wallet Tab \u003e View \"LATEST TRANSACTIONS\"\n      * Re-start Mining\n        * Note: Each block mined for the transaction gives a block confirmation. After ~12 confirmations the contract is published on the Private Network\n\n* In MIST, \n  * Go to \"Contracts\" tab\n    * Select the Deployed Contract that was saved in the Wallet\n    * View the options available:\n      * Copy Contract Address\n      * Show Contract QR Code\n      * Show Contract JSON Interface (allows execution of the contract)\n      * \"Call\" Functions are under heading \"READ FROM CONTRACT\"\n      * \"Transaction\" Functions are under heading \"WRITE TO CONTRACT\" (i.e. `transfer`, `transferFrom`, `approve`)\n      * Copy the Transaction Hash\n\n* Terminal Tab #2 - JavaScript RPC Geth Console\n  * Reference: https://github.com/ethereum/wiki/wiki/JavaScript-API\n\n  * Show Transaction\n```\nvar tx = web3.eth.getTransaction('\u003cINSERT_TRANSACTION_HASH_OF_DEPLOYED_CONTRACT\u003e');\n```\n\n  * Estimate Gas\n```\nweb3.eth.estimateGas(tx);\n```\n\n  * Transaction Receipt\n```\nweb3.eth.getTransactionReceipt('\u003cINSERT_TRANSACTION_HASH_OF_DEPLOYED_CONTRACT\u003e', function(err, res) { console.log(JSON.stringify(res, null, 2)) });\n```\n\n* Terminal Tab #2 - JavaScript Node.js script using Web3.js\n  * Reference: \n    * Web3.js API 0.2x.x Docs - https://github.com/ethereum/wiki/wiki/JavaScript-API\n    * Web3.js API 1.0.0-beta.xx Docs - https://web3js.readthedocs.io/en/1.0/web3.html\n    * Web3.js Forums - https://forum.ethereum.org/categories/ethereum-js\n\n  * Install Node.js dependencies\n\n```\nrm -rf node_modules\n\nnpm install --save-dev \\\n  web3@1.0.0-beta.27 \\\n  net@1.0.2 \\\n  solc@0.4.19 \\\n  fs@0.0.1-security\n\nnpm install\n```\n\n  * Terminal Tab #2 - Deploy New Contract using Web3.js instead of via MIST\n\n```\nnode scripts/main.js\n```\n\n    * IMPORTANT NOTE: Errors with `authentication needed: password or unlock` were caused because the `unlockAccount` is a Promise that must be resolved before contract deployment.\n\n    * Terminal Tab #2 - Successfuly deployment should display:\n\n      * EXAMPLE OUTPUT\n        * `transactionHash` event (or `error` event)\n\n```\nWeb3.js version: 1.0.0-beta.27\nOS Platform: darwin\nGeth is not mining\nAccounts in Private Network: 57\nCoinbase Address:  0x487f2778ec7d0747d6e26af80148ec471a08b339\nGeth Node Listening: true\nContract gas estimate: 518329\nCreated New Account with address: 0x8d59cA1Edfb4b7644A875325A003E4CB0Ae06b9B\nNew Default address set to:  0x8d59cA1Edfb4b7644A875325A003E4CB0Ae06b9B\nPromise.all resolved with:  [ undefined,\n  undefined,\n  '0x8d59cA1Edfb4b7644A875325A003E4CB0Ae06b9B',\n  '0x487f2778ec7d0747d6e26af80148ec471a08b339' ]\nCoinbase Address Balance:  4985000000000000000000\nPromise.all resolved with:  [ '0x487f2778ec7d0747d6e26af80148ec471a08b339', true, true ]\nCreating contract instance defined in JSON interface object\nPromise resolved with FSTContract, and senderAddress:  0x487f2778ec7d0747d6e26af80148ec471a08b339\nSuccessfully submitted contract creation. Transaction hash: 0xdf1501e72dc8e11a6abee5fd215850804cfbf9a512719dccf3c9017b32d166a2\n```\n\n    * Terminal Tab #1 - Check Geth Console and it should display:\n\n```\n...\nINFO [12-31|12:47:33] Submitted contract creation fullhash=0xABC contract=0xDEF...\n```\n\n    * Terminal Tab #3 - Attached to the Geth Node JavaScript console. Verify that the Transaction Receipt does not exist for the Transaction Hash yet until mined (and returns `null`), then proceed to Mine some blocks before running `miner.stop()` to publish the contract on the blockchain: \n\n```\ngeth attach \"/Users/Ls/code/blockchain/geth-node/chaindata/geth.ipc\"\n\nweb3.eth.getTransactionReceipt('0xdf1501e72dc8e11a6abee5fd215850804cfbf9a512719dccf3c9017b32d166a2')\n\nminer.start(1);\n\nminer.stop()\n```\n\n    * Terminal Tab #2 - Watch the Bash terminal for the PromiEvents that we setup an event listener for to trigger when the contract is mined and deployed in a block, when a receipt is provided, and for each confirmation (i.e. ~20 confirmations).\n    We also subscribe to different events that we added to the Solidity smart contract (i.e. `Created`)\n\n      * EXAMPLE OUTPUT\n        * `confirmation` events\n        * `receipt` events\n        * Deployment of contract Promise resolved success\n\n```\nConfirmation no. and receipt:  0 { blockHash: '0x388ff4acef35c2cdf18fba6551f359f4c25c3f7aa6ef2c4d87069683678de6b5',\n  blockNumber: 126,\n  contractAddress: '0xe1EE909fAE2341B12b3CAe9bE90ae47e9D9e1568',\n  cumulativeGasUsed: 518521,\n  from: '0x487f2778ec7d0747d6e26af80148ec471a08b339',\n  gasUsed: 518521,\n  logsBloom: '0x00000000000000000000000000008000000000000000000000000000000000021080000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000',\n  root: '0xd70f83e1af93d9154a7d9cda888e9b11e11cc9942df5985a62dd25776ae2bee9',\n  to: null,\n  transactionHash: '0xdf1501e72dc8e11a6abee5fd215850804cfbf9a512719dccf3c9017b32d166a2',\n  transactionIndex: 0,\n  events: \n   { Created: \n      { address: '0xe1EE909fAE2341B12b3CAe9bE90ae47e9D9e1568',\n        blockNumber: 126,\n        transactionHash: '0xdf1501e72dc8e11a6abee5fd215850804cfbf9a512719dccf3c9017b32d166a2',\n        transactionIndex: 0,\n        blockHash: '0x388ff4acef35c2cdf18fba6551f359f4c25c3f7aa6ef2c4d87069683678de6b5',\n        logIndex: 0,\n        removed: false,\n        id: 'log_cc8b5cba',\n        returnValues: [Object],\n        event: 'Created',\n        signature: '0x102d25c49d33fcdb8976a3f2744e0785c98d9e43b88364859e6aec4ae82eff5c',\n        raw: [Object] } } }\nReceipt after mining with contract address: 0xe1EE909fAE2341B12b3CAe9bE90ae47e9D9e1568\nReceipt after mining with events: [object Object]\nContract instance with address:  0xe1EE909fAE2341B12b3CAe9bE90ae47e9D9e1568\nContract instance created at block number: 126\nOnce event received event:  null\nAll events received event:  null\n\n...\n\nConfirmation no. and receipt:  10 { blockHash: '0x388ff4acef35c2cdf18fba6551f359f4c25c3f7aa6ef2c4d87069683678de6b5',\n  blockNumber: 126,\n  contractAddress: '0xe1EE909fAE2341B12b3CAe9bE90ae47e9D9e1568',\n  cumulativeGasUsed: 518521,\n  from: '0x487f2778ec7d0747d6e26af80148ec471a08b339',\n  gasUsed: 518521,\n  logsBloom: '0x00000000000000000000000000008000000000000000000000000000000000021080000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000',\n  root: '0xd70f83e1af93d9154a7d9cda888e9b11e11cc9942df5985a62dd25776ae2bee9',\n  to: null,\n  transactionHash: '0xdf1501e72dc8e11a6abee5fd215850804cfbf9a512719dccf3c9017b32d166a2',\n  transactionIndex: 0,\n  events: \n   { Created: \n      { address: '0xe1EE909fAE2341B12b3CAe9bE90ae47e9D9e1568',\n        blockNumber: 126,\n        transactionHash: '0xdf1501e72dc8e11a6abee5fd215850804cfbf9a512719dccf3c9017b32d166a2',\n        transactionIndex: 0,\n        blockHash: '0x388ff4acef35c2cdf18fba6551f359f4c25c3f7aa6ef2c4d87069683678de6b5',\n        logIndex: 0,\n        removed: false,\n        id: 'log_cc8b5cba',\n        returnValues: [Object],\n        event: 'Created',\n        signature: '0x102d25c49d33fcdb8976a3f2744e0785c98d9e43b88364859e6aec4ae82eff5c',\n        raw: [Object] } } }\n```\n\n    * Check to see if a Transaction Receipt now exists for the Transaction Hash:\n\n```\nweb3.eth.getTransactionReceipt('0xdf1501e72dc8e11a6abee5fd215850804cfbf9a512719dccf3c9017b32d166a2')\n```\n\n\n  * Deploy New Contract using Web3.py instead of MIST\n\n    * References:\n      * https://github.com/pyenv/pyenv\n      * https://pypi.python.org/pypi/ethereum/2.1.5\n      * https://pypi.python.org/pypi/web3/4.0.0b5\n      * https://pypi.python.org/pypi/py-solc/2.1.0\n\n```\npyenv install 3.6.4rc1\npyenv versions\npyenv global 3.6.4rc1\npython -m pip install py-solc==2.1.0\npython -m solc.install v0.4.18\npython -m pip install web3==4.0.0b5 \npython -m pip install ethereum==2.1.5\n\npython scripts/main.py\n```\n\n* Experimental code snippets. \n  \n  * Install dependencies included for each file first \n\n```\nnpm install ethers\nnpm install ethjs-query\nnpm install ethjs-account\nnpm install ethereumjs-tx\nnpm install ethjs-provider-signer\n```\n  \n  * Run each experiment\n  \n```\nnode scripts/experiments/ethers-lib.js;\nnode scripts/experiments/ethjs-lib.js\n```\n\n* References:\n  * Udemy Ethereum Masterclass - https://www.udemy.com/ethereum-masterclass","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fltfschoen%2Fgeth-node","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fltfschoen%2Fgeth-node","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fltfschoen%2Fgeth-node/lists"}