Skip to content

Commit

Permalink
Update deps (#48)
Browse files Browse the repository at this point in the history
* add arbitrum

* fix action

* new deployment

* fix version

* improve script

* update deps

* fix content

* rm json
  • Loading branch information
julienbrg authored Dec 11, 2024
1 parent e413bf1 commit 5be1d6e
Show file tree
Hide file tree
Showing 12 changed files with 402 additions and 326 deletions.
19 changes: 12 additions & 7 deletions .env.template
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
# Signer Private Key (signer[0])
SIGNER_PRIVATE_KEY="88888"

# Optimism Mainnet
OPTIMISM_MAINNET_RPC_ENDPOINT_URL="https://mainnet.optimism.io"
OPTIMISM_MAINNET_PRIVATE_KEY="88888"
OP_ETHERSCAN_API_KEY="88888"

# Base Mainnet
BASE_MAINNET_RPC_ENDPOINT_URL="https://mainnet.base.org"
BASE_MAINNET_PRIVATE_KEY="88888"
BASE_ETHERSCAN_API_KEY="88888"

# Arbitrum One Mainnet
ARBITRUM_MAINNET_RPC_ENDPOINT_URL="88888"
ARBITRUM_ETHERSCAN_API_KEY="88888"

# Sepolia
SEPOLIA_RPC_ENDPOINT_URL="https://ethereum-sepolia.publicnode.com"
SEPOLIA_PRIVATE_KEY="88888"
SEPOLIA_RPC_ENDPOINT_URL="88888"
ETHERSCAN_API_KEY="88888"

# OP Sepolia
OP_SEPOLIA_RPC_ENDPOINT_URL="https://sepolia.optimism.io"
OP_SEPOLIA_PRIVATE_KEY="88888"
OP_SEPOLIA_RPC_ENDPOINT_URL="88888"

# Base Sepolia
BASE_SEPOLIA_RPC_ENDPOINT_URL="https://sepolia.base.org"
BASE_SEPOLIA_PRIVATE_KEY="88888"

# Arbitrum Sepolia
ARBITRUM_SEPOLIA_RPC_ENDPOINT_URL="88888"
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Node.js CI
name: Run unit tests

on:
push:
Expand Down
68 changes: 15 additions & 53 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# W3HC Hardhat Template

A comprehensive development environment for Ethereum-compatible networks using Hardhat.
A comprehensive Solidity contract development environment using Hardhat.

## Features

Expand All @@ -15,67 +15,35 @@ A comprehensive development environment for Ethereum-compatible networks using H
| Network | Chain ID | Documentation |
|---------|----------|---------------|
| Optimism Mainnet | 10 | [Documentation](https://docs.optimism.io/chain/networks#op-mainnet) |
| Base Mainnet | 8453 | [Documentation](https://docs.base.org/docs/network-information#base-mainnet) |
| Arbitrum One | 42161 | [Documentation](https://docs.arbitrum.io/welcome/get-started) |
| Sepolia Testnet | 11155111 | [Documentation](https://ethereum.org/nb/developers/docs/networks/#sepolia) |
| OP Sepolia Testnet | 11155420 | [Documentation](https://docs.optimism.io/chain/networks#op-sepolia) |
| Base Sepolia Testnet | 84532 | [Documentation](https://docs.base.org/docs/network-information/#base-testnet-sepolia) |
| Arbitrum Sepolia | 421614 | [Documentation](https://docs.arbitrum.io/welcome/get-started) |

## Contract Verification

| Network | Explorer URL | API URL | API Key Variable |
|---------|--------------|---------|-----------------|
| Sepolia | https://sepolia.etherscan.io | https://api-sepolia.etherscan.io/api | ETHERSCAN_API_KEY |
| Optimism | https://optimistic.etherscan.io | https://api-optimistic.etherscan.io/api | OP_ETHERSCAN_API_KEY |
| OP Sepolia | https://sepolia-optimism.etherscan.io | https://api-sepolia-optimistic.etherscan.io/api | OP_ETHERSCAN_API_KEY |
| Base Sepolia | https://sepolia.basescan.org | https://api-sepolia.basescan.org/api | BASE_ETHERSCAN_API_KEY |

## Contract Verification

| Network | Explorer URL | API URL | API Key Variable |
|---------|--------------|---------|-----------------|
| Sepolia | https://sepolia.etherscan.io | https://api-sepolia.etherscan.io/api | ETHERSCAN_API_KEY |
| Optimism | https://optimistic.etherscan.io | https://api-optimistic.etherscan.io/api | OP_ETHERSCAN_API_KEY |
| Base | https://basescan.org | https://api.basescan.org/api | BASE_ETHERSCAN_API_KEY |
| Arbitrum One | https://arbiscan.io | https://api.arbiscan.io/api | ARBITRUM_ETHERSCAN_API_KEY |
| Sepolia | https://sepolia.etherscan.io | https://api-sepolia.etherscan.io/api | ETHERSCAN_API_KEY |
| OP Sepolia | https://sepolia-optimism.etherscan.io | https://api-sepolia-optimistic.etherscan.io/api | OP_ETHERSCAN_API_KEY |
| Base Sepolia | https://sepolia.basescan.org | https://api-sepolia.basescan.org/api | BASE_ETHERSCAN_API_KEY |
| Arbitrum Sepolia | https://sepolia.arbiscan.io | https://api-sepolia.arbiscan.io/api | ARBITRUM_ETHERSCAN_API_KEY |

### Manual Contract Verification

When deploying, you may see this error:
```
ContractStatusPollingResponseNotOkError: The Etherscan API responded with a failure status.
Reason: Fail - Unable to verify. Unable to locate ContractCode at <address>
```

This is normal - it means the contract needs time to be indexed. Wait 1-2 minutes, then run:

```bash
npx hardhat verify --network <NETWORK_NAME> <CONTRACT_ADDRESS> "10000000000000000000000"
```

Where:
- `<NETWORK_NAME>`: `optimism`, `base`, `op-sepolia`, or `base-sepolia`
- `<NETWORK_NAME>`: `optimism`, `base`, `arbitrum`, `sepolia`, `op-sepolia`, `base-sepolia`, `arbitrum-sepolia`
- `<CONTRACT_ADDRESS>`: The address where your contract was deployed

Note: The constructor argument represents the initial supply in wei (e.g., "10000000000000000000000" for 10,000 tokens with 18 decimals)

If the verification fails with "Unable to locate ContractCode", wait a few minutes for the contract to be indexed by the block explorer and try again.

Alternative Manual Verification via Block Explorers:
- Optimism: https://optimistic.etherscan.io/verifyContract
- Base: https://basescan.org/verifyContract
- OP Sepolia: https://sepolia-optimism.etherscan.io/verifyContract
- Base Sepolia: https://sepolia.basescan.org/verifyContract

When verifying through block explorers:
1. Choose "Solidity (Single file)"
2. Fill in:
- Contract Address
- Compiler: v0.8.20
- License: GPL-3.0
- Optimization: Yes (200 runs)
- Contract code from Basic.sol
- Constructor Arguments: 10000000000000000000000

## Installation

1. Install dependencies:
Expand All @@ -88,36 +56,30 @@ pnpm install
cp .env.template .env
```

3. Update `.env` with your configuration:
```plaintext
# Required Configuration
OPTIMISM_MAINNET_RPC_ENDPOINT_URL="your_optimism_rpc_url"
OPTIMISM_MAINNET_PRIVATE_KEY="your_private_key"
OP_ETHERSCAN_API_KEY="your_api_key"
# Additional networks...
```
3. Update `.env` with your configuration.

## Usage

### Testing

Execute the test suite:
```bash
pnpm test
```

### Deployment

Deploy to supported networks:
```bash
pnpm deploy:<network>
```
Supported values for `<network>`: `sepolia`, `optimism`, `op-sepolia`, `base-sepolia`
Supported values for `<network>`: `optimism`, `base`, `arbitrum`, `sepolia`, `op-sepolia`, `base-sepolia`, `arbitrum-sepolia`

### Network Operations

Check wallet balance:
Check wallet ETH balances:
```bash
pnpm bal <network>
pnpm bal
```

Mint tokens:
Expand All @@ -140,4 +102,4 @@ pnpm send:<network> <amount>

## Support

Feel free to reach out to [Julien](https://github.com/julienbrg): [Farcaster](https://warpcast.com/julien-), [Element](https://matrix.to/#/@julienbrg:matrix.org), [Status](https://status.app/u/iwSACggKBkp1bGllbgM=#zQ3shmh1sbvE6qrGotuyNQB22XU5jTrZ2HFC8bA56d5kTS2fy), [Telegram](https://t.me/julienbrg), [Twitter](https://twitter.com/julienbrg), [Discord](https://discordapp.com/users/julienbrg), or [LinkedIn](https://www.linkedin.com/in/julienberanger/).
Feel free to reach out to [Julien](https://github.com/julienbrg) on [Farcaster](https://warpcast.com/julien-), [Element](https://matrix.to/#/@julienbrg:matrix.org), [Status](https://status.app/u/iwSACggKBkp1bGllbgM=#zQ3shmh1sbvE6qrGotuyNQB22XU5jTrZ2HFC8bA56d5kTS2fy), [Telegram](https://t.me/julienbrg), [Twitter](https://twitter.com/julienbrg), [Discord](https://discordapp.com/users/julienbrg), or [LinkedIn](https://www.linkedin.com/in/julienberanger/).
2 changes: 1 addition & 1 deletion contracts/Basic.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.20;
pragma solidity ^0.8.22;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

Expand Down
42 changes: 21 additions & 21 deletions deployments/op-sepolia/Basic.json

Large diffs are not rendered by default.

This file was deleted.

Large diffs are not rendered by default.

5 changes: 0 additions & 5 deletions funding.json

This file was deleted.

60 changes: 38 additions & 22 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,21 @@ import "@nomicfoundation/hardhat-toolbox"
import "@nomicfoundation/hardhat-verify"
import "hardhat-deploy"
import * as dotenv from "dotenv"
import "./tasks/mint"
import "./tasks/send"
dotenv.config()

const {
SIGNER_PRIVATE_KEY,
OPTIMISM_MAINNET_RPC_ENDPOINT_URL,
OPTIMISM_MAINNET_PRIVATE_KEY,
OP_ETHERSCAN_API_KEY,
BASE_MAINNET_RPC_ENDPOINT_URL,
BASE_MAINNET_PRIVATE_KEY,
BASE_ETHERSCAN_API_KEY,
ARBITRUM_MAINNET_RPC_ENDPOINT_URL,
ARBITRUM_ETHERSCAN_API_KEY,
SEPOLIA_RPC_ENDPOINT_URL,
SEPOLIA_PRIVATE_KEY,
ETHERSCAN_API_KEY,
OP_SEPOLIA_RPC_ENDPOINT_URL,
OP_SEPOLIA_PRIVATE_KEY,
BASE_SEPOLIA_RPC_ENDPOINT_URL,
BASE_SEPOLIA_PRIVATE_KEY
ARBITRUM_SEPOLIA_RPC_ENDPOINT_URL
} = process.env

const config: HardhatUserConfig = {
Expand All @@ -39,47 +36,56 @@ const config: HardhatUserConfig = {
SEPOLIA_RPC_ENDPOINT_URL ||
"https://ethereum-sepolia.publicnode.com",
accounts:
SEPOLIA_PRIVATE_KEY !== undefined ? [SEPOLIA_PRIVATE_KEY] : []
SIGNER_PRIVATE_KEY !== undefined ? [SIGNER_PRIVATE_KEY] : []
},
optimism: {
chainId: 10,
url:
OPTIMISM_MAINNET_RPC_ENDPOINT_URL ||
"https://mainnet.optimism.io",
accounts:
OPTIMISM_MAINNET_PRIVATE_KEY !== undefined
? [OPTIMISM_MAINNET_PRIVATE_KEY]
: []
SIGNER_PRIVATE_KEY !== undefined ? [SIGNER_PRIVATE_KEY] : []
},
base: {
chainId: 8453,
url: BASE_MAINNET_RPC_ENDPOINT_URL || "https://mainnet.base.org",
accounts:
BASE_MAINNET_PRIVATE_KEY !== undefined
? [BASE_MAINNET_PRIVATE_KEY]
: []
SIGNER_PRIVATE_KEY !== undefined ? [SIGNER_PRIVATE_KEY] : []
},
arbitrum: {
chainId: 42161,
url:
ARBITRUM_MAINNET_RPC_ENDPOINT_URL ||
"https://arb1.arbitrum.io/rpc",
accounts:
SIGNER_PRIVATE_KEY !== undefined ? [SIGNER_PRIVATE_KEY] : []
},

"op-sepolia": {
chainId: 11155420,
url:
OP_SEPOLIA_RPC_ENDPOINT_URL ||
"https://ethereum-sepolia.publicnode.com",
accounts:
OP_SEPOLIA_PRIVATE_KEY !== undefined
? [OP_SEPOLIA_PRIVATE_KEY]
: []
SIGNER_PRIVATE_KEY !== undefined ? [SIGNER_PRIVATE_KEY] : []
},
"base-sepolia": {
chainId: 84532,
url: BASE_SEPOLIA_RPC_ENDPOINT_URL || "https://sepolia.base.org",
accounts:
BASE_SEPOLIA_PRIVATE_KEY !== undefined
? [BASE_SEPOLIA_PRIVATE_KEY]
: []
SIGNER_PRIVATE_KEY !== undefined ? [SIGNER_PRIVATE_KEY] : []
},
"arbitrum-sepolia": {
chainId: 421614,
url:
ARBITRUM_SEPOLIA_RPC_ENDPOINT_URL ||
"https://sepolia-rollup.arbitrum.io/rpc",
accounts:
SIGNER_PRIVATE_KEY !== undefined ? [SIGNER_PRIVATE_KEY] : []
}
},
solidity: {
version: "0.8.20",
version: "0.8.22",
settings: {
optimizer: {
enabled: true,
Expand All @@ -94,10 +100,12 @@ const config: HardhatUserConfig = {
apiKey: {
optimism: OP_ETHERSCAN_API_KEY || "",
base: BASE_ETHERSCAN_API_KEY || "",
arbitrum: ARBITRUM_ETHERSCAN_API_KEY || "",
sepolia: ETHERSCAN_API_KEY || "",
optimisticEthereum: OP_ETHERSCAN_API_KEY || "",
"op-sepolia": OP_ETHERSCAN_API_KEY || "",
"base-sepolia": BASE_ETHERSCAN_API_KEY || ""
"base-sepolia": BASE_ETHERSCAN_API_KEY || "",
"arbitrum-sepolia": ARBITRUM_ETHERSCAN_API_KEY || ""
},
customChains: [
{
Expand All @@ -115,6 +123,14 @@ const config: HardhatUserConfig = {
apiURL: "https://api-sepolia.basescan.org/api",
browserURL: "https://basescan.org/"
}
},
{
network: "arbitrum-sepolia",
chainId: 421614,
urls: {
apiURL: "https://api-sepolia.arbiscan.io/api",
browserURL: "https://sepolia.arbiscan.io"
}
}
]
}
Expand Down
29 changes: 18 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,27 +1,33 @@
{
"name": "w3hc-hardhat-template",
"version": "0.1.0",
"description": "",
"main": "index.js",
"type": "commonjs",
"scripts": {
"test": "hardhat test",
"compile": "hardhat compile",
"deploy:optimism": "hardhat deploy --network optimism --reset",
"deploy:base": "hardhat deploy --network base --reset",
"deploy:arbitrum": "hardhat deploy --network arbitrum --reset",
"deploy:sepolia": "hardhat deploy --network sepolia --reset",
"deploy:op-sepolia": "hardhat deploy --network op-sepolia --reset",
"deploy:base-sepolia": "hardhat deploy --network base-sepolia --reset",
"deploy:arbitrum-sepolia": "hardhat deploy --network arbitrum-sepolia --reset",
"mint:optimism": "hardhat mint --network optimism --amount",
"mint:base": "hardhat mint --network base --amount",
"mint:arbitrum": "hardhat mint --network arbitrum --amount",
"mint:sepolia": "hardhat mint --network sepolia --amount",
"mint:op-sepolia": "hardhat mint --network op-sepolia --amount",
"mint:base-sepolia": "hardhat mint --network base-sepolia --amount",
"mint:arbitrum-sepolia": "hardhat mint --network arbitrum-sepolia --amount",
"send:optimism": "hardhat send --wallet 0xD8a394e7d7894bDF2C57139fF17e5CBAa29Dd977 --network optimism --amount",
"send:base": "hardhat send --wallet 0xD8a394e7d7894bDF2C57139fF17e5CBAa29Dd977 --network base --amount",
"send:arbitrum": "hardhat send --wallet 0xD8a394e7d7894bDF2C57139fF17e5CBAa29Dd977 --network arbitrum --amount",
"send:sepolia": "hardhat send --wallet 0xD8a394e7d7894bDF2C57139fF17e5CBAa29Dd977 --network sepolia --amount",
"send:op-sepolia": "hardhat send --wallet 0xD8a394e7d7894bDF2C57139fF17e5CBAa29Dd977 --network op-sepolia --amount",
"send:base-sepolia": "hardhat send --wallet 0xD8a394e7d7894bDF2C57139fF17e5CBAa29Dd977 --network base-sepolia --amount",
"bal": "npx hardhat run scripts/check-my-balance.ts --network",
"send:arbitrum-sepolia": "hardhat send --wallet 0xD8a394e7d7894bDF2C57139fF17e5CBAa29Dd977 --network arbitrum-sepolia --amount",
"bal": "npx hardhat run scripts/check-my-balance.ts",
"prettier": "prettier --write \"**/*.ts\"",
"prettier-check": "prettier --check \"**/*.ts\""
},
Expand All @@ -40,16 +46,16 @@
"@nomicfoundation/hardhat-verify": "^2.0.12",
"@typechain/ethers-v6": "^0.5.1",
"@typechain/hardhat": "^9.1.0",
"@types/chai": "^4.2.0",
"@types/chai": "^4.3.20",
"@types/cli-color": "^2.0.6",
"@types/mocha": "^10.0.10",
"@types/node": "^22.9.3",
"chai": "^4.2.0",
"hardhat": "^2.22.16",
"hardhat-gas-reporter": "^1.0.8",
"prettier": "^2.8.8",
"@types/node": "^22.10.1",
"chai": "^4.5.0",
"hardhat": "^2.22.17",
"hardhat-gas-reporter": "^1.0.10",
"prettier": "^3.4.2",
"prettier-plugin-solidity": "^1.4.1",
"solidity-coverage": "^0.8.13",
"solidity-coverage": "^0.8.14",
"ts-node": "^10.9.2",
"typechain": "^8.3.2",
"typescript": "^5.7.2"
Expand All @@ -58,8 +64,9 @@
"@nomiclabs/hardhat-ethers": "npm:hardhat-deploy-ethers@^0.4.2",
"@openzeppelin/contracts": "^5.1.0",
"cli-color": "^2.0.4",
"dotenv": "^16.4.5",
"dotenv": "^16.4.7",
"ethers": "^6.13.4",
"hardhat-deploy": "^0.12.0"
"hardhat-deploy": "^0.12.4",
"hardhat-deploy-ethers": "0.4.2"
}
}
Loading

0 comments on commit 5be1d6e

Please sign in to comment.