25

Transaction was not mined within 750 seconds, please make sure your transaction...

 2 years ago
source link: https://learnblockchain.cn/question/2716
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Transaction was not mined within 750 seconds, please make sure your transaction was properly sent. Be aware that it might still be mined!

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

回答问题即可获得 5 经验值,回答被采纳后即可获得 10 学分。
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”,初学者求教


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK