1. .env
PRIVATE_KEY=xxxxxxxxxxxxxxxxxxxxxx
URL = [<https://eth-rinkeby.alchemyapi.io/v2/>](<https://eth-rinkeby.alchemyapi.io/v2/EnmGj1RJuvhREtz-jLD30VsMConsWgEt>)api_key
ETHERSCAN_KEY="xxxxxxx"
  1. hardhat config
require('@nomiclabs/hardhat-ethers')
require('@nomiclabs/hardhat-waffle')
require('@nomiclabs/hardhat-etherscan')
require('dotenv').config()

const privateKey = process.env.PRIVATE_KEY
const endpoint = process.env.URL
const etherscanKey = process.env.ETHERSCAN_KEY
module.exports = {
  solidity: {
    version: '0.8.4',
  },
  networks: {
    rinkeby: {
      url: endpoint,
      accounts: [`0x${privateKey}`],
    },
  },
  etherscan: {
    apiKey: etherscanKey,
  },
}
  1. do it!!!

Result👇

https://rinkeby.etherscan.io/address/0x9bB958093B0cc151977aD85F7d085654f3838BC5#code

Error

https://zenn.dev/nook/articles/6f151c4b19b2ad