From a72de4874be1162f9d4009f73d3e5f53fb7dfdcd Mon Sep 17 00:00:00 2001 From: qbzzt Date: Tue, 22 Jun 2021 08:12:50 -0500 Subject: [PATCH] Usability updates (#23037) * Usability updates I spent some time getting it wrong and writing notes about it so other people will get it right the first time. * Update index.md * Update index.md * Update index.md * Update index.md --- docs/_getting-started/index.md | 75 +++++++++++++++++++++------------- 1 file changed, 46 insertions(+), 29 deletions(-) diff --git a/docs/_getting-started/index.md b/docs/_getting-started/index.md index 6787fac01f..b5a3cd594a 100644 --- a/docs/_getting-started/index.md +++ b/docs/_getting-started/index.md @@ -44,11 +44,12 @@ You can connect a Geth node to several different networks using the network name These include the main Ethereum network, [a private network](getting-started/private-net) you create, and three test networks that use different consensus algorithms: -- **Ropsten**: Proof-of-work test network -- **Rinkeby**: Proof-of-authority test network -- **Görli**: Proof-of-authority test network +-   **Ropsten**: Proof-of-work test network +-   **Rinkeby**: Proof-of-authority test network +-   **Görli**: Proof-of-authority test network -For this guide, we use the Görli network. +For this guide, we use the Görli network. The default port is 30303, so you need to enable at least +outgoing access from your node to that port. ### Sync modes @@ -57,15 +58,17 @@ argument that determines what sort of node it is in the network. These are: -- **Full**: Downloads all blocks (including headers, transactions, and receipts) and - generates the state of the blockchain incrementally by executing every block. -- **Fast** (Default): Downloads all blocks (including headers, transactions and - receipts), verifies all headers, and downloads the state and verifies it against the - headers. -- **Light**: Downloads all block headers, block data, and verifies some randomly. +- **Full**: Downloads all blocks (including headers, transactions, and receipts) and +generates the state of the blockchain incrementally by executing every block. +- **Fast**: Downloads all blocks (including headers, transactions and +receipts), verifies all headers, and downloads the state and verifies it against the +headers. +- **Snap** (Default): Same functionality as fast, but with a faster algorithm. +- **Light**: Downloads all block headers, block data, and verifies some randomly. For this tutorial, we use a `light` sync: + ## Start Clef Start Clef, setting the keystore and chain id (goerli is 5) for the network we want to connect to: @@ -76,15 +79,20 @@ clef --keystore /keystore --chainid 5 To begin with, you see errors about a missing keystore, and we fix that soon. +Under Linux the default Geth data directory is `~/.ethereum` + ## Start Geth -The command below also enables the [Geth RPC interface](clef/tutorial) -(which we cover below), and sets Clef as the transaction signer. +Open another command line window and run command below, which also enables the +[Geth RPC interface](clef/tutorial) (see below), and sets Clef as the transaction signer. ```shell geth --goerli --syncmode "light" --http --signer=/clef.ipc ``` +By default Clef's location under Linux is `~/.clef`, but the signer's location cannot +include a `~` so replace it with your home directory. + ## Get ETH Unless you have Ether in another account on the Görli network, you can use a @@ -112,6 +120,9 @@ Connect to the IPC console on a node from another terminal window: geth attach ``` +You can see the IPC location in the output of the network node `geth` process. By default, when using +Görli, it is `~/.ethereum/goerli/geth.ipc`. + ### Check account balance ```javascript @@ -121,47 +132,53 @@ web3.fromWei(eth.getBalance(""),"ether") Getting the balance of an account does not require a signed transaction, so Clef does not ask for approval, and Geth returns the value. +Note that this step requires the initial synchronization to end. If you get an error message, return to the +console with the network node Geth and wait until it is synchronized. You +know that your Geth is synchronized when it is only importing a small number of blocks (one or two, usually) +at a time. + ### Send ETH to account Send 0.01 ETH from the account that you added ETH to with the Görli faucet, to the second account you created: ```javascript -eth.sendTransaction({from:"",to:"", value: web3.toWei(0.01,"ether")}) +eth.sendTransaction({from:"",to:"", value: web3.toWei(0.01,"ether")}) ``` -This action does require signing the transaction, so Clef prompts you to approve it, and -if you do, asks you for the password you are sending the ETH from. If the password is -correct, Geth proceeds with the transaction. +This action does require signing the transaction, so go to the command line window with Clef running +to see that Clef prompts you to approve it, and when you do, asks you for the password for the account you are +sending the ETH from. If the password is correct, Geth proceeds with the transaction. To check, get the account balance of the second account: ```javascript -web3.fromWei(eth.getBalance(""),"ether") +web3.fromWei(eth.getBalance(""),"ether") ``` ## Using RPC ### Connect to RPC -You can use standard HTTP requests to connect to a Geth node using the RPC APIs, for example: +You can use standard HTTP requests to connect to a Geth node using the RPC APIs, using +this syntax: ```shell curl -X POST http://:8545 \ - -H "Content-Type: application/json" \ - --data'{"jsonrpc":"2.0", "method":"", "params":[], "id":1}' +    -H "Content-Type: application/json" \ +   --data'{"jsonrpc":"2.0", "method":"", "params":[], "id":1}' ``` ### Check account balance ```shell curl -X POST http://:8545 \ - -H "Content-Type: application/json" \ - --data '{"jsonrpc":"2.0", "method":"eth_getBalance", "params":["","latest"], "id":1}' +    -H "Content-Type: application/json" \ +   --data '{"jsonrpc":"2.0", "method":"eth_getBalance", "params":["","latest"], "id":1}' ``` -Getting the balance of an account does not require a signed transaction, -so Clef does not ask for approval, and Geth returns the value. +Getting the balance of an account does not require a signed transaction, so Geth returns the value without invoking +Clef. Note that the value returned is in hexadecimal and WEI. To get the ETH value, convert to decimal and divide by 10^18. ### Send ETH to accounts @@ -169,18 +186,18 @@ Send 0.01 ETH from the account that you added ETH to with the Görli faucet, to ```shell curl -X POST http://:8545 \ - -H "Content-Type: application/json" \ - --data '{"jsonrpc":"2.0", "method":"eth_sendTransaction", "params":[{"from": "","to": "","value": "0x9184e72a"}], "id":1}' +    -H "Content-Type: application/json" \ +   --data '{"jsonrpc":"2.0", "method":"eth_sendTransaction", "params":[{"from": "","to": "","value": "0x9184e72a"}], "id":1}' ``` This action does require signing, so Clef prompts you to approve it, and if you do, -asks you for the password you are sending the ETH from. If the password is correct, +asks you for the password of the account from which you are sending the ETH. If the password is correct, Geth proceeds with the transaction. To check, get the account balance of the second account: ```shell curl -X POST http://:8545 \ - -H "Content-Type: application/json" \ - --data '{"jsonrpc":"2.0", "method":"eth_getBalance", "params":["","latest"], "id":1}' +    -H "Content-Type: application/json" \ +    --data '{"jsonrpc":"2.0", "method":"eth_getBalance", "params":["","latest"], "id":1}' ```