Day 2: Setting Up Your Ethereum Development Environment and Transferring ETH with Node.js

·

Welcome to Day 2 of our comprehensive guide: 5 Days to Master Ethereum dApp Development. Today, we’ll walk you through setting up your Ethereum development environment and executing your first ETH transfer using Node.js. By the end of this tutorial, you’ll have successfully sent test ETH on both the Ropsten testnet and a local blockchain, giving you hands-on experience with real-world Ethereum interactions.

Whether you're building decentralized applications (dApps) or exploring blockchain development, mastering environment setup is crucial. Let’s dive in.


Why Start with the Ropsten Test Network?

Before jumping into complex local configurations, we recommend starting with the Ropsten test network. It mirrors the Ethereum mainnet but uses test ETH—so there’s no risk to your real funds. This approach simplifies learning because:

Once Ropsten is working, setting up a local environment becomes much easier.

👉 Get started with Ethereum development tools and resources today.


Step-by-Step: Running Your First ETH Transfer on Ropsten

1. Generate a Test Wallet Using a Mnemonic Phrase

To begin, you need an Ethereum wallet for testing. We’ll use a 12-word mnemonic phrase to generate one.

After generation, note down the first derived address (Account[0]). You’ll use this to receive test ETH.

🔐 Security Tip: Never use this wallet for real funds. Test environments are public and insecure by design.

2. Request Test ETH from a Faucet

Now that you have an address, you need test ETH to work with.

This faucet provides free Ether specifically for developers testing on Ropsten. Wait a few moments for the transaction to confirm.

3. Connect to the Ethereum Network via Infura

To interact with Ethereum programmatically, your code needs access to the blockchain via JSON-RPC.

That’s where Infura comes in—a reliable API service that provides RPC endpoints without running your own node.

You’ll use this URL in your Node.js script to connect remotely to the Ropsten network.

4. Run the Transfer Code

We’ve prepared a ready-to-use demo repository to simplify setup:

git clone https://github.com/netpi/ethereum-demo.git
cd ethereum-demo
npm install

Ensure you're using Node.js v8.17.0 or higher, as Web3 libraries require compatible versions.

Next, configure the environment:

Update ropsten.config.js

// ropsten.config.js
module.exports = {
  mnemonic: "your twelve-word mnemonic here",
  rpcurl: "wss://ropsten.infura.io/v3/your-infura-project-id"
};

Replace the placeholder values with your actual mnemonic and Infura URL.

Execute the Transfer Script

Run the following command:

node transferEth.js

This script sends 0.01 ETH from Account[0] to Account[1] (both derived from your mnemonic). If successful, you’ll see output like:

{
  "blockHash": "0x47a243a7d3cf9e1a82d2dfb16bb4db65c248ebd8b5188510ae39be3ddfb80633",
  "blockNumber": 8008669,
  "from": "0x15e35634f38f416830aaf09e35b323b516af6d36",
  "to": "0x75d60374fd1740d1bcdc033084deaaa57a7d8321",
  "value": "0.01",
  "transactionHash": "0x2bf9563c4b094d09ad252bce7ffca5f93438ee0797b3c94be5513e9cc77422d8",
  "status": true
}

🎉 Success! You've just executed your first Ethereum transaction via code.

You can verify it on Ropsten Etherscan by pasting the transactionHash into https://ropsten.etherscan.io.


Set Up a Local Ethereum Development Environment

Now that you’ve seen how things work on a live testnet, let’s move to local development—ideal for rapid iteration and debugging.

1. Use Ganache for Local Blockchain Simulation

Ganache is a personal blockchain for Ethereum development. It provides:

Steps:

Ganache will generate consistent accounts every time, making testing predictable.

The default RPC server runs at: http://127.0.0.1:7545


2. Configure Your Project for Local Testing

Duplicate your configuration file:

cp ropsten.config.js local.config.js

Update local.config.js:

// local.config.js
module.exports = {
  mnemonic: "your twelve-word mnemonic",
  rpcurl: "http://127.0.0.1:7545"
};

Then, modify transferEth.js to load the local config:

// const config = require('./ropsten.config.js'); // Ropsten
const config = require('./local.config.js'); // Local

Run the script again:

node transferEth.js

You should see similar output, confirming the transaction occurred on your local chain.


3. Verify Transactions in Ganache

Return to the Ganache interface:

This confirms your local environment works perfectly.

👉 Explore powerful blockchain development tools and APIs to accelerate your dApp journey.


Core Keywords for SEO and Developer Discovery

To ensure visibility and relevance, here are the core keywords naturally integrated throughout this guide:

These terms align with common search queries from developers entering the Web3 space.


Frequently Asked Questions (FAQ)

Q: Can I use other testnets besides Ropsten?

Yes, alternatives like Goerli and Sepolia are now more commonly used since Ropsten has been deprecated post-Merge. However, for educational purposes, Ropsten remains widely documented. For new projects, consider Goerli or Sepolia with compatible faucets.

Q: Is my mnemonic safe during testing?

Your mnemonic is safe only if used in isolated test environments. Never reuse test mnemonics on mainnet wallets or share them online. Always assume anything on testnets is public.

Q: Why do I need Infura instead of running my own node?

Running a full Ethereum node requires significant disk space and bandwidth. Infura abstracts this complexity by offering scalable API access—perfect for development and small-scale applications.

Q: What is the purpose of Web3.js?

Web3.js is a JavaScript library that allows frontend or backend apps to interact with Ethereum nodes via RPC calls. It enables functions like reading blockchain data, sending transactions, and deploying smart contracts.

Q: How does Ganache help in dApp development?

Ganache provides instant feedback, predictable states, and controllable time (via mining control), making it ideal for writing, testing, and debugging smart contracts before deploying to live networks.

Q: Can I deploy real dApps using this setup?

Absolutely! Once tested locally and on testnets, you can deploy your dApp to the Ethereum mainnet by switching configurations—just update your RPC URL and use a funded mainnet wallet.


Final Thoughts

By completing today’s exercises, you’ve achieved two major milestones:

  1. Successfully transferred ETH on the Ropsten testnet using code.
  2. Built and tested transactions on a local blockchain using Ganache.

You now have a solid foundation for deeper exploration into Web3.js, smart contract programming, and decentralized application architecture—all critical skills in modern blockchain development.

In tomorrow’s session, we’ll break down how transferEth.js works under the hood, explore HD wallet derivation, and start writing our first Solidity smart contract.

Keep building—and remember, every expert was once a beginner.

👉 Accelerate your blockchain development with advanced tools and insights from OKX.