5 Transaction was not mined within 750 seconds, please make sure your transaction was properly sent. Be aware that it might still be mined!

const Web3 = require('web3');
const path = require('path');
const fs = require('fs');
var Tx = require('ethereumjs-tx').Transaction;

const rpc_node = 'https://rinkeby.infura.io/v3/dfeb7e52cf2744a297718e4ad026b358'
//NFT

const collextAssetObject = fs.readFileSync(path.resolve('./lib/abi/CollextAssetObject.json'))
const assetObjectAbi = JSON.parse(collextAssetObject).abi;

const nft_contract_addr = '0x9a9413ed8d7358D79C2895e7A197C614d9E1E1a2';    //rinkeby

const web3 = new Web3(new Web3.providers.HttpProvider(rpc_node))

//NFT
const _instance = new web3.eth.Contract(assetObjectAbi, nft_contract_addr);

async function test(_url,_owner) {

  let result = await web3.eth.getTransactionCount("0x4cC1d4B275e9066dB9Ca1D76ff8c2984b1Db8e8C")
  console.log("result",result);
  let gas = await web3.eth.getGasPrice()
  console.log("gas",gas)
  var _data = _instance.methods.addNewTokenToOwner(_url,_owner).encodeABI();

  var txData = {

    nonce: web3.utils.toHex(result),

    gasLimit: web3.utils.toHex(300000),
    gasPrice: web3.utils.toHex(30),

    to: nft_contract_addr,

    value: '0x00',

    data: _data
  }

  let chain = await web3.eth.getChainId()
  console.log("chainId:",chain)

  var tx = new Tx(txData,{chain:"rinkeby"});
  const privateKey = “......”

  tx.sign(privateKey);

  var serializedTx = tx.serialize();

  web3.eth.sendSignedTransaction('0x' + serializedTx.toString('hex'), function (err, hash) {
    console.log(err)
  }).on('transactionHash', function (hash) {
    console.log("hash---",hash);
  }).on("receipt", function (receipt){
    console.log("receipt----",receipt);
  }).on('error', function (error) {
    console.log(error); 

  });

}

test("https://dweb.link/ipns/Qmd239NTdwgC4mJfmVHiQKqjixACJn9WXen7ogPtaqdAND/1.json","0xdE6E86aDd358986754884C834103cCEC74827a8e")

我想调用合约函数生成一个NFT,每次都是等好长时间之后,然后报错“Transaction was not mined within 750 seconds”,初学者求教

请先 登录 后评论

3 个回答

Tiny熊
  擅长:智能合约,以太坊
请先 登录 后评论
未仁
请先 登录 后评论
DEX
请先 登录 后评论
  • 3 关注
  • 1 收藏,4180 浏览
  • 未仁 提出于 2021-11-04 17:53