发生了交易定价错误,每当我尝试运行以下代码时。

huangapple go评论71阅读模式
英文:

transaction underpriced error occured whever i tried to run the below code

问题

const tx = {
    nonce: 5,
    gasPrice: 20000000000,
    gasLimit: 1000000,
    to: null,
    value: 0,
    data: "0x608060405234801561001057600",
    chainId: 1337,
};
// const signedTxResponse = await wallet.signTransaction(tx);
const sentTxResponse = await wallet.sendTransaction(tx);
// await sentTxResponse.wait(1);
console.log("sentTxResponse", sentTxResponse);

上述代码中出现了一个错误,它给出了一个"transaction underpriced"错误,错误信息为:"error: could not coalesce error"。我已经尝试过更改了gas限制和gas价格。

请注意,我只翻译了代码部分,没有包括您提供的错误信息。如果您需要有关错误信息的翻译或其他帮助,请提供详细信息。

英文:
const tx = {
    nonce: 5,
    gasPrice: 20000000000,
    gasLimit: 1000000,
    to: null,
    value: 0,
    data: "0x608060405234801561001057600",
    chainId: 1337,
  };
  // const signedTxResponse = await wallet.signTransaction(tx);
  const sentTxResponse = await wallet.sendTransaction(tx);
  // await sentTxResponse.wait(1);
  console.log("sentTxResponse", sentTxResponse);

i have an error for the above code its give me an transaction underpriced error error: could not coalesce error

(error={ "code": -32003, "message": "transaction underpriced", "stack": "Error: transaction underpriced\\n    at shouldReplace (/tmp/.mount_ganach8fQ6uV/resources/static/node/node_modules/ganache/dist/node/1.js:2:119740)\\n    at TransactionPool.prepareTransaction (/tmp/.mount_ganach8fQ6uV/resources/static/node/node_modules/ganache/dist/node/1.js:2:122311)" }, code=UNKNOWN_ERROR, version=6.4.0)  

i tried to change the gas limit and gas price

答案1

得分: 0

const nonce = await wallet.getNonce();
const tx = {
nonce: nonce,
gasPrice: 20000000000,
gasLimit: 1000000,
to: null,
value: 0,
data: "0x608060405234801561001057600",
chainId: 1337,
};
// const signedTxResponse = await wallet.signTransaction(tx);
const sentTxResponse = await wallet.sendTransaction(tx);
// await sentTxResponse.wait(1);
console.log("sentTxResponse", sentTxResponse);

英文:
    const nonce = await wallet.getNonce()
    const tx = {
        nonce: nonce,
        gasPrice: 20000000000,
        gasLimit: 1000000,
        to: null,
        value: 0,
        data: "0x608060405234801561001057600",
        chainId: 1337,
      };
   // const signedTxResponse = await wallet.signTransaction(tx);
   const sentTxResponse = await wallet.sendTransaction(tx);
   // await sentTxResponse.wait(1);
   console.log("sentTxResponse", sentTxResponse);

huangapple
  • 本文由 发表于 2023年5月25日 17:09:41
  • 转载请务必保留本文链接:https://go.coder-hub.com/76330611.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定