可以的, 使用 hardhat-network-helpers
代码:
import { time } from "@nomicfoundation/hardhat-network-helpers";
async function main() {
// 增加时间出块
await helpers.time.increase(3600);
// 从新时间戳`newTimestamp`出块
await helpers.time.increaseTo(newTimestamp);
// 设置时间不出块
await helpers.time.setNextBlockTimestamp(newTimestamp);
}
main();
参考文档:https://hardhat.org/hardhat-network/docs/reference#hardhat-network-methods