hardhat fork 16000000 运行为什么会是在16000002 还有为什么没有gasused字段
测试代码:
describe("test", function () {
async function dodeploy() {
const Tra = await ethers.getContractFactory("tra");
const tra = await Tra.deploy();
await tra.deployed();
}
describe("do",async function(){
it("do",async function(){
const myContract = await loadFixture(dodeploy);
const [owner] = await ethers.getSigners();
var tc = await network.provider.request({
method: "eth_getTransactionCount",
params: [owner.address],
});
var rawTx = {
nonce: tc,
gasPrice: 20787108203,
gasLimit: 200000,
to: myContract.address,
value: 0x00,
data: "0xd0c2863a"
}
var tx = new Tx(rawTx);
tx.sign(privateKey);
var serializedTx = tx.serialize();
const par = '0x' + serializedTx.toString('hex');
var tran = await network.provider.request({
method: "eth_sendRawTransaction",
params: [par],
});
const tif = await ethers.provider.getTransaction(tran)
console.log(tif);
})
});
});
hardhat.config.js 配置:
module.exports = {
solidity: "0.8.18",
settings: {
optimizer: {
enabled: true,
runs: 1000
}
},
networks: {
hardhat: {
chainId: 31337,//默认链id
forking: {
url: "https://eth-mainnet.nodereal.io/v1/1659dfb40aa24bbb8153a677b98064d7",
blockNumber: 16000000
}
}
}
};