A Practical Guide to Sending and Receiving ETH on Ethereum

·

Sending and receiving Ether (ETH) is a fundamental activity on the Ethereum network. Every interaction, from simple value transfers to complex smart contract executions, is packaged into a transaction and broadcast to the network. This guide provides a hands-on walkthrough for executing a basic ETH transfer.

Prerequisites for an ETH Transfer

Before initiating a transfer, ensure your local Geth client is running. This client acts as your gateway to the Ethereum network, allowing you to create, sign, and broadcast transactions.

If your node isn't running, start it with the following command. Remember to replace the example etherbase address with your own mining reward address.

cd ether-test
geth --datadir ./db/ --rpc --rpcaddr=127.0.0.1 --rpcport 8545 --rpccorsdomain "*" \
--rpcapi "eth,net,web3,personal,admin,shh,txpool,debug,miner" \
--nodiscover --maxpeers 30 --networkid 198989 --port 30303 \
--mine --minerthreads 1 \
--etherbase "0x53dc408a8fa060fd3b72b30ca312f4b3f3232f4f"

Step-by-Step: Initiating an ETH Transaction

1. Attach to Your Geth Node

Open a new terminal window and attach to your running Geth node using the following command:

cd ether-test
geth --datadir ./db attach ipc:./db/geth.ipc

This gives you an interactive JavaScript console to communicate with your node.

2. Temporarily Stop Mining

To observe the transaction process clearly, it's helpful to pause block mining initially. In the console, execute:

miner.stop()

3. Unlock the Sending Account

To sign the transaction, you must unlock the account holding the ETH. This decrypts the private key from your keystore file and holds it in memory temporarily for signing.

Important Security Note: The private key remains in memory only for the specified duration (300 seconds in this example) or until used. This is a critical security feature.

Execute the unlock command, replacing '123' with your account's password:

> personal.unlockAccount(eth.accounts[0], '123', 300)
true

4. Send the Transaction

Now, instruct your node to create and broadcast a transaction. This command sends 10 ETH from the first account in your wallet (eth.accounts[0]) to the second (eth.accounts[1]). The web3.toWei() function converts the value from Ether to Wei, the smallest denomination of ETH.

> eth.sendTransaction({from: eth.accounts[0], to: eth.accounts[1], value: web3.toWei(10, 'ether')})
"0x45b6be881cf86b79dc7ad8bf4d9cbfafc9aa191062411d6606a086bbc42042ed"

The long string returned is your Transaction Hash (TxHash). This unique identifier is used to track your transaction's status on the blockchain.

Checking Your Transaction Status

After broadcasting, your transaction enters the mempool—a waiting area for transactions yet to be included in a block.

Viewing the Mempool

Check the pool's status to see your transaction:

> txpool.status
{ pending: 1, queued: 0}

A pending: 1 status confirms your transaction is waiting to be picked up by a miner.

Inspecting the Pending Transaction

Use the TxHash to retrieve your transaction's details while it's still pending:

> eth.getTransaction("0x45b6be881cf86b79dc7ad8bf4d9cbfafc9aa191062411d6606a086bbc42042ed")
{
  blockHash: "0x0000000000000000000000000000000000000000000000000000000000000000",
  blockNumber: null,
  from: "0x53dc408a8fa060fd3b72b30ca312f4b3f3232f4f",
  gas: 90000,
  gasPrice: 18000000000,
  hash: "0x45b6be881cf86b79dc7ad8bf4d9cbfafc9aa191062411d6606a086bbc42042ed",
  input: "0x",
  nonce: 1,
  ... //other fields
}

Key fields to note:

Mining a Block to Confirm the Transaction

To get your transaction confirmed, restart mining to create a new block. The following command starts the miner, waits for one block to be mined, and then stops it automatically.

> miner.start(1); admin.sleepBlocks(1); miner.stop();
true

Post-Confirmation Checks

Once the block is mined, check the mempool again—it should be empty.

> txpool.status
{ pending: 0, queued: 0}

Now, query your transaction again using its hash. You will see that blockHash and blockNumber are now populated, proving it's been included in block #1450.

Finally, check the balance of the receiving account to confirm the 10 ETH arrived successfully.

> web3.fromWei(eth.getBalance(eth.accounts[1]), "ether")
10

Understanding the Mined Block

Let's examine the block that contained our transaction to understand its structure better.

> eth.getBlock(1450)
{
  difficulty: 230123,
  extraData: "0xd98301080e846765746888676f312e31302e338664617277696e",
  gasLimit: 1041578754,
  gasUsed: 21000,
  hash: "0xa24f29bab9117a48ef6a83588dfecbb991ff2605dcfffffd3d486edb5a3bfe23",
  logsBloom: "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
  miner: "0x53dc408a8fa060fd3b72b30ca312f4b3f3232f4f",
  mixHash: "0x9d9a14e1c4a87176f9c6625bf2a5d184c1a667204b0d0f21d638999b1a3da183",
  nonce: "0x4fca8e74a63f357a",
  number: 1450,
  parentHash: "0x7560ceea1bd16c86f383fc31a9185a4014a1703d94838956717a5696dcb9bff4",
  receiptsRoot: "0x61d0ae2203ef95f6e54d9fe14c6c3aa7bcdf9398be15b1f1d164502412863b92",
  sha3Uncles: "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
  size: 656,
  stateRoot: "0x905a8dfd9a0f2ee9f75b50397374fa63bf8119bda52ccb224e2f3bdd97ec4a86",
  timestamp: 1537092501,
  totalDifficulty: 255928573,
  transactions: ["0x45b6be881cf86b79dc7ad8bf4d9cbfafc9aa191062411d6606a086bbc42042ed"],
  transactionsRoot: "0xef95d6a816bb8b56cf47d337553283593a1daafce4d3e0b3c4930080fd59dd55",
  uncles: []
}

Key observations from this block:

👉 Explore more strategies for managing your cryptocurrency transactions

Frequently Asked Questions

What is a transaction hash (TxHash)?

A transaction hash is a unique 66-character identifier that is generated for every verified transaction on the blockchain. It acts like a receipt number, allowing you to look up the status, details, and confirmation count of your specific transfer on a block explorer.

Why do I need to unlock my account to send ETH?

Unlocking your account decrypts your private key from its encrypted storage on disk and holds it in memory temporarily. This private key is required to cryptographically sign the transaction, proving you are the owner of the funds. It is a vital security step that prevents unauthorized transactions.

What does 'pending' mean in the transaction pool?

A 'pending' transaction is one that has been successfully broadcast to the network but has not yet been included in a block by a miner. It is sitting in the mempool, waiting to be picked up. Network congestion and too low a gas price can cause transactions to remain pending for longer periods.

How long does an Ethereum transaction usually take?

On the main Ethereum network, transaction times can vary from seconds to minutes, depending on the gas price you pay. Higher gas prices incentivize miners to prioritize your transaction. On a private testnet like the one in this guide, where you control the mining, transactions are typically confirmed in the next block, which is very fast.

What is the 'value' field in a transaction?

The 'value' field specifies the amount of Ether to be transferred from the sender to the recipient. It is always denoted in Wei, the smallest unit of ETH (1 ETH = 1,000,000,000,000,000,000 Wei). Libraries like Web3.js provide tools to easily convert between ETH and Wei.

What is the difference between a transfer and a contract call?

A simple transfer, like the one in this guide, has an empty input field ("0x") and only moves ETH from A to B. A contract call has data in the input field, which is code instructing a smart contract to execute a function. Both are types of transactions but serve different purposes.