The Ethereum Merge: What it Means for Developers
Tags: javascript, tutorial, opensource, blockchain
Published: 2022-11-16 13:19:22

The Ethereum merge has succeeded! Ethereum has moved from Proof of Work to the Proof of Stake consensus mechanism. Let's talk about what it means for developers.

## The New Testnets

The Kiln, Rinkeby, and Ropsten testnets are now being deprecated.

### Goerli & Sepolia: The two testnets that client developers will maintain post-merge.

Ethereum developers recommend Sepolia for users and developers who want a lightweight chain to sync to and interact with. Goerli is recommended for stakers to test protocol upgrades and developers who want to interact with a large existing state.

## Sepolia Characteristics

- Closed validator set, controlled by client & testing teams.
- New testnet, fewer applications deployed than other testnets.
- Fast to sync and running a node requires minimal disk space.

### Follow this guide to setup Sepolia:

https://learn.block6.tech/sepolia-testnet-cfe6623f05dc

### Steps to deploying on Sepolia:

Initialising the project.

```
mkdir hardhat-add && cd hardhat-add

npm init -y && npm install --save-dev hardhat dotenv @nomiclabs/hardhat-ethers && npx hardhat

```

The terminal output should show something like:

```
888    888                      888 888               888
888    888                      888 888               888
888    888                      888 888               888
8888888888  8888b.  888d888 .d88888 88888b.   8888b.  888888
888    888     "88b 888P"  d88" 888 888 "88b     "88b 888
888    888 .d888888 888    888  888 888  888 .d888888 888
888    888 888  888 888    Y88b 888 888  888 888  888 Y88b.
888    888 "Y888888 888     "Y88888 888  888 "Y888888  "Y888

👷 Welcome to Hardhat v2.11.2 👷‍

? What do you want to do? … 
❯ Create a JavaScript project
  Create a TypeScript project
  Create an empty hardhat.config.js
  Quit
```

Choose `Create an empty hardhat.config.js`

Generate source files:

```
mkdir contracts && mkdir scripts

touch contracts/Add.sol && touch scripts/deploy.js
```

Create a simple smart contract in Add.sol file:

```
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;

contract Add {
    function add(uint256 a, uint256 b) public pure returns (uint256) {
        return a + b;
    }
}
```

Create a simple deploy script in deploy.js file:

```
const hre = require("hardhat");

async function main() {

  const Add = await hre.ethers.getContractFactory("Add");
  const add = await Add.deploy();

  await add.deployed();

  console.log(
    `Add deployed to ${add.address}`
  );
}

main().catch((error) => {
  console.error(error);
  process.exitCode = 1;
});
```

Environment variables setup:

```
touch .env
```

Open the .env file and enter:

```
SEPOLIA_URL=https://rpc.sepolia.org
PRIVATE_KEY="YOUR_ACCOUNTS_PRIVATE_KEY"
```

Modify the hardhat.config.js file to:

```
require("dotenv").config();
require("@nomiclabs/hardhat-ethers");

const { SEPOLIA_URL, PRIVATE_KEY } = process.env;

module.exports = {
  solidity: "0.8.9",
  defaultNetwork: "sepolia",
  networks: {
    hardhat: {},
    sepolia: {
      url: SEPOLIA_URL,
      accounts: [`0x${PRIVATE_KEY}`],
    },
  },
};
```

Compile the Add.sol file with:

```
npx hardhat compile
```

You should see:

```
We have compiled 1 Solidity file successfully.
```

Deploy the contact with:

```
npx hardhat run scripts/deploy.js --network sepolia
```

You should see something like:

```
Add deployed to 0x1d1C7871a99527A06d0140b04f7e44E3Aff4c20D
// address will be different //
```

Go [here](https://sepolia.etherscan.io/) and search with your wallet account address.

Click `Contract Creation`

Click the contract tab and then click "Verify and Publish."

After filling out a short form, your contract should be published on the testnet blockchain.


## Goerli Characteristics

- Open validator set, stakers can test network upgrades.
- Large state for testing complex smart contract interactions.
- Longer to sync and requires more storage to run a node.

To get goerliETH, follow these links:

https://medium.com/@ethvalidator/a-quick-guide-on-how-to-get-test-eth-in-the-goerli-network-7066dc915989

goerlifaucet.com

### You'll also need an Alchemy account:

dashboard.alchemy.com

## Steps to deploying on Goerli:

Modify the `.env` file to:

```
SEPOLIA_URL=https://rpc.sepolia.org
GOERLI_URL=https://eth-goerli.g.alchemy.com/v2/NiATSzYny1Oy-6sqLiBqo7KZIitQHIh9
PRIVATE_KEY="YOUR_ACCOUNTS_PRIVATE_KEY"
```

Your goerli url may be different according to your dashboard.

Modify `the hardhat.config.js` file to:

```
require("dotenv").config();
require("@nomiclabs/hardhat-ethers");

const { SEPOLIA_URL, GOERLI_URL, PRIVATE_KEY } = process.env;

module.exports = {
  solidity: "0.8.9",
  defaultNetwork: "sepolia",
  networks: {
    hardhat: {},
    sepolia: {
      url: SEPOLIA_URL,
      accounts: [`0x${PRIVATE_KEY}`],
    },
    goerli: {
      url: GOERLI_URL,
      accounts: [`0x${PRIVATE_KEY}`],
    },
  },
};
```

Deploy by running the command:

```
npx hardhat run scripts/deploy.js --network goerli
```

The contract should now be deployed to the Goerli network, and you should be able to see it in etherscan.

The rest of the process remains the same as that of sepolia.

## Testing Your Frontend Code and Tooling

Most applications on Ethereum involve much more than on-chain contracts. Now is the time to ensure that your front-end code, tooling, deployment pipeline, and other off-chain components work as intended.

Now is the time to run a complete testing & deployment cycle on Sepolia or Goerli and report any issues with tools or dependencies to those projects' maintainers.

You can raise an issue on this [repository](https://github.com/eth-clients/merge-testnets/) in case of uncertainties.

## You don't have to do much.

The Ethereum developers designed the Merge to have only minimal impact on a subset of contracts deployed on Ethereum, none of which should be breaking. Most user API endpoints remain stable (unless you use proof-of-work specific methods such as `eth_getWork`).