[DOCS] Update dev mode tutorial (#20826)

* Update dev mode tutorial to include connecting to Remix

* Remove mention of ports

* Update Remix steps
This commit is contained in:
Chris Chinchilla 2020-05-12 10:45:14 +02:00 committed by GitHub
parent 790b2b1463
commit 9116d22de0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 23 additions and 10 deletions

View File

@ -3,7 +3,7 @@ title: Dev mode
sort_key: B sort_key: B
--- ---
Geth has a development mode which sets up a single node Ethereum test network with a number of options optimized for developing on local machines. You enable it with the `--dev` argument. Geth has a development mode that sets up a single node Ethereum test network with options optimized for developing on local machines. You enable it with the `--dev` argument.
Starting geth in dev mode does the following: Starting geth in dev mode does the following:
@ -12,13 +12,26 @@ Starting geth in dev mode does the following:
- Turns off discovery by other nodes - Turns off discovery by other nodes
- Sets the gas price to 0 - Sets the gas price to 0
- Uses the Clique PoA consensus engine with which allows blocks to be mined as-needed without excessive CPU and memory consumption - Uses the Clique PoA consensus engine with which allows blocks to be mined as-needed without excessive CPU and memory consumption
- Uses on-demand block generation, producing blocks when there are transactions waiting to be mined - Uses on-demand block generation, producing blocks when transactions are waiting to be mined
You can specify a data directory to maintain state between runs using the `--datadir` option, otherwise databases are ephemeral and in-memory: ## Start Geth in Dev Mode
You can specify a data directory to maintain state between runs using the `--datadir` option, otherwise, databases are ephemeral and in-memory:
```shell ```shell
$ mkdir test-chain-dir mkdir test-chain-dir
$ geth --dev --datadir test-chain-dir console ```
For this guide, start geth in dev mode, and enable [RPC](../_rpc/server.md) so you can connect other applications to geth. For this guide, we use Remix, the web-based Ethereum IDE, so also allow its domains to accept cross-origin requests.
```shell
geth --datadir test-chain-dir --rpc --dev --rpccorsdomain "https://remix.ethereum.org,http://remix.ethereum.org"
```
Connect to the IPC console on the node from another terminal window:
```shell
geth attach <IPC_LOCATION>
``` ```
Once geth is running in dev mode, you can interact with it in the same way as when geth is running in other ways. Once geth is running in dev mode, you can interact with it in the same way as when geth is running in other ways.
@ -29,7 +42,7 @@ For example, create a test account:
> personal.newAccount() > personal.newAccount()
``` ```
Then transfer ether from the coinbase to the new account: And transfer ether from the coinbase to the new account:
```shell ```shell
> eth.sendTransaction({from:eth.coinbase, to:eth.accounts[1], value: web3.toWei(0.05, "ether")}) > eth.sendTransaction({from:eth.coinbase, to:eth.accounts[1], value: web3.toWei(0.05, "ether")})
@ -41,8 +54,8 @@ And check the balance of the account:
> eth.getBalance(eth.accounts[1]) > eth.getBalance(eth.accounts[1])
``` ```
If you want to test your dapps with a realistic block time use the `--dev.period` option when you start dev mode: If you want to test your dapps with a realistic block time use the `--dev.period` option when you start dev mode with the `--dev.period 14` argument.
```shell ## Connect Remix to Geth
geth --dev --dev.period 14 console
``` With geth now running, open <https://remix.ethereum.org>. Compile the contract as normal, but when you deploy and run a contract, select _Web3 Provider_ from the _Environment_ dropdown, and add "http://127.0.0.1:8545" to the popup box. Click _Deploy_, and interact with the contract. You should see contract creation, mining, and transaction activity.