我使用了 web3 v1.10.0,我可以在 metmask 确认窗口中禁用网站建议费用。但将web3版本更新到4.0.3后,网站建议的费用又出现了。有人可以告诉我在最新版本中禁用网站建议费用的方法吗?
const web3 = new Web3(window.ethereum);
const contract = new web3.eth.Contract(erc20ABI, contractAddress);
contract.methods
.transfer(destinationAdrs, (depositAmt * 1000000).toString())
.send({ from: sourceAdrs, gas: "21000", maxPriorityFeePerGas: null, maxFeePerGas: null })
.then(function (receipt) {
console.log(receipt);
}).catch(function (error) {
console.log(error);
});
谢谢你
文档说
1.x 中所有返回或接受 null 的 API 级别接口,请使用 4.x 中未定义
在 1.x 中,对于无类型、0x0 和 0x1 类型的交易, maxPriorityFeePerGas 和 maxFeePerGas 设置为 null。对于 0x2 类型 交易时,gasPrice 设置为 null。在 4.x 中,这些属性不再 除非提供,否则存在
因此,尝试将
maxPriorityFeePerGas
和 maxFeePerGas
更新为 undefined
而不是 null
。我认为这可以解决问题。