代码之家  ›  专栏  ›  技术社区  ›  Bablu Singh

与web3进行交易。js有时成功,有时出错

  •  4
  • Bablu Singh  · 技术社区  · 8 年前

    当我们进行任何交易时,每个交易都需要gas,所以我确定了多少gas来进行成功的交易,因为一段时间的交易是成功的,而另一段时间的交易是错误的

    “错误:返回的错误:燃气资金不足*价格+价值”

    Thanks in advance .
    
    
    exports.sendTransactions = (sender_account, to_account, p_key, value ) => {
      console.log("sendTRansactions", sender_account,  to_account , p_key , value );
      var admin = sender_account;
      var contract_address = to_account;
      var tx = {
        from: admin,
        to: contract_address,
        gas: 184000,
        data: "",
        value: value
      };
       return web3.eth.accounts.signTransaction(tx, p_key).then((hash) => {
         return web3.eth.sendSignedTransaction(hash.rawTransaction).then((receipt) => {
           return receipt
        }, (error) => {
          return error
          console.log(error);
          // reject(500);
        })
      }, (error) => {
        return error
        // reject(500);
      });
    }
    
    1 回复  |  直到 8 年前
        1
  •  3
  •   Bablu Singh    8 年前

    我刚才制作的气体在字符串中示例: 天然气:“184000”,

    这对我很有用。

    推荐文章