当我使用estimateGas()时,无法部署我的合约



当我使用estimateGas()时,我无法部署我的合约,实际上estimateGas()和错误中使用的gas是相同的。为什么会发生这种情况?如何解决这个问题?

我代码:

const deployedContract = await deployTx.send({
from: signer.address,
gas: await deployTx.estimateGas(),
}).once("transactionHash", (txhash) => {
console.log(`Mining deployment transaction ...`);
console.log(txhash);
});

错误:

receipt: {
blockHash: '0x6330753afbeae8ac63fc4056d9f26ea8eec15cfcf6a4cfcf34f4fd2ada55620c',
blockNumber: 10781483,
contractAddress: '0x2801e146eB41339F060BbF2b2dd87cE970e5cAec',
cumulativeGasUsed: 5421372,
effectiveGasPrice: 4154546093,
from: '0xa458b7e161aa47c268053004fd0b25b7a2fa66f0',
gasUsed: 2442757,
logsBloom: '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
status: false,
to: null,
transactionHash: '0x9e5f0d788ce28e3f5d35ee80e911d3f23f984d3d7d98271e82582b6045534acc',
transactionIndex: 11,
type: '0x2',
events: {}
}
}

您的代码中没有错误。

合约已成功部署到交易收据的contractAddress属性中显示的地址0x2801...

estimateGas()只是要求你连接的节点(在你的情况下很可能是一个本地模拟器)估计交易将花费多少gas。

最新更新