# hardhat 本地网络导致合约部署夯死的问题 **Published by:** [石小龙](https://paragraph.com/@0x994cd38723375a0eb0d55fcbc1e2a862fd49d007/) **Published on:** 2025-03-12 **URL:** https://paragraph.com/@0x994cd38723375a0eb0d55fcbc1e2a862fd49d007/hardhat-3 ## Content waitConfirmations: CONFIRMATIONS await Lock.deploymentTransaction().wait(2) 类似于上面的等待区块确认的代码都是导致合约部署的阻塞 而这种阻塞现象只发生在network属性是“hardhat” 或者 “localhost”的情况下,如果是测试网则不会出现这样的情况 原因是本地网络不会自动出块,这个块是受到新的链上交互行为才会激发,而本地网络除了你自己用就没有别人用了;所以永远也等不到区块确认 测试网络有无数人交互,那么,自然很快N个区块就被确认了 本地网解决部署被阻塞的三个方案: 1、条件判断,如果是本地网络,不等待区块确认 2、另起一个终端,执行N次合约部署(每一次算一个区块) 3、另起一个终端,执行N次虚拟区块的挖掘 const helper = require("@nomicfoundation/hardhat-network-helpers") await helper.mine(10); ## Publication Information - [石小龙](https://paragraph.com/@0x994cd38723375a0eb0d55fcbc1e2a862fd49d007/): Publication homepage - [All Posts](https://paragraph.com/@0x994cd38723375a0eb0d55fcbc1e2a862fd49d007/): More posts from this publication - [RSS Feed](https://api.paragraph.com/blogs/rss/@0x994cd38723375a0eb0d55fcbc1e2a862fd49d007): Subscribe to updates