炼金术错误:这是什么意思 -> maxFeePerGas 不能小于 maxPriorityFeePerGas



我正在学习本教程->https://docs.alchemy.com/alchemy/tutorials/sending-txs唯一的区别是,我正试图让测试水龙头

async function main() {
require('dotenv').config();
const { API_URL, PRIVATE_KEY } = process.env;
const { createAlchemyWeb3 } = require('@alch/alchemy-web3');
const web3 = createAlchemyWeb3(API_URL);
const myAddress = 'xxxx'; //TODO: replace this address with your own public address
const nonce = await web3.eth.getTransactionCount(myAddress, 'latest'); // nonce starts counting from 0
console.log(nonce);
const transaction = {
to: '0x9f1099b301716892d17d576387027cE5B73E2c20', // faucet address to return eth
value: 100,
gas: 30000,
maxFeePerGas: 1000000108,
nonce: nonce,
// optional data field to send message or execute smart contract
};
const signedTx = await web3.eth.accounts.signTransaction(
transaction,
PRIVATE_KEY
);
web3.eth.sendSignedTransaction(
signedTx.rawTransaction,
function (error, hash) {
if (!error) {
console.log(
'🎉 The hash of your transaction is: ',
hash,
"n Check Alchemy's Mempool to view the status of your transaction!"
);
} else {
console.log(
'❗Something went wrong while submitting your transaction:',
error
);
}
}
);
}
main();

当我运行代码时,我会收到此错误->Error: maxFeePerGas cannot be less than maxPriorityFeePerGas (The total must be the larger of the two) (tx type=2 hash=not available (unsigned) nonce=23 value=100 signed=false hf=london maxFeePerGas=1000000108 maxPriorityFeePerGas=2500000000)

更新:如果我用maxPriorityFeePerGas替换maxFeePerGas,则有效

我在概念上缺少什么

由于矿工的一些激励机制,maxPriorityFeePerGas的默认值似乎从1.0 gwei更改为2.5 gwei

有关详细信息,请关注本期。

因此,如果我们不设置maxPriorityFeePerGas参数,默认值2.5 gwei将大于maxFeePerGas,即我们设置的1.0 gwei,这违反了规则。

我们可以通过将maxPriorityFeePerGas设置为小于1.0 gwei或将maxFeePerGas更改为大于2.5 gwei来解决此问题。

最新更新