# 實作 Mainnet fork with hardhat/Ganache-cli run local ethereum mainnet fork and connect MetaMask. ### 以hardhat run reference: https://hardhat.org/hardhat-network/guides/mainnet-forking.html 1. 到 https://www.alchemy.com/ 註冊 2. Apps -> view key 拿取key 3. terminal run ``` npx hardhat node --fork https://eth-mainnet.alchemyapi.io/v2/<key> ```  4. 連上 metamask 如果新增網路,chain ID = 31337. metamask --> 匯入帳戶 --> 貼上run 出來的private key就會成功如下  ### 以Ganache-cli run ``` ganache-cli -d -f https://eth-mainnet.alchemyapi.io/v2/<key> -p 7545 ``` connect to metamask, chain ID = 1337.    ###### tags: `Solidity`
×
Sign in
Email
Password
Forgot password
or
Sign in via Google
Sign in via Facebook
Sign in via X(Twitter)
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
Continue with a different method
New to HackMD?
Sign up
By signing in, you agree to our
terms of service
.