如何使用js将大量事务发送到ethereum

我试图用一个用js编写的程序向Ethereum发送大量事务。 我使用节点js,web3和infura ropsten。 问题是:如果我一次发送交易,他们中的大多数就会消失。 试图解决这个问题,我发送间隔交易。 它工作,但非常缓慢。 我花了小时只发送100笔交易。 有没有解决scheme如何使其工作更快,更正确? 我想在前一个开始挂起之后发送交易,但我不知道该怎么做。 函数sendRaw只在一段时间后才获取交易号。 该代码读取文件,获取地址,金额和可选数据,并使用智能合约的方法转移令牌。 这是代码:

function sendRaw(rawTx) { var privateKey = new Buffer(key, 'hex'); var transaction = new tx(rawTx); transaction.sign(privateKey); var serializedTx = transaction.serialize().toString('hex'); web3.eth.sendRawTransaction( '0x' + serializedTx, function(err, result) { if(err) { console.log(err); } else { console.log(result); Ntrans=result; } }); } var nonce = web3.eth.getTransactionCount(address); var gasPrice = web3.eth.gasPrice; var gasLimit = 90000; var fs = require("fs"); var buf1 = new Buffer(1024); var buf2 = new Buffer(1024); var buf3 = new Buffer(1024); var i = 0; var j = 0; var k = 0; var fd = fs.openSync('/home/kate/Desktop/file.txt', 'r+'); function recurs() { if(k==5) return -1; j = 0; do { fs.readSync(fd, buf1, j, 1, i); i++; j++; } while(buf1[j-1] != 32); AddressC = String(buf1.slice(0, j-1)) console.log(AddressC); j = 0; do { fs.readSync(fd, buf2, j, 1, i) i++; j++; } while(buf2[j-1]!=32); ValueT = Number(buf2.slice(0, j-1)) console.log(ValueT); j = 0; do { fs.readSync(fd, buf3, j, 1, i); i++; j++; } while(buf3[j-1]!=10); TxC = String(buf3.slice(0, j-1)); txOptions = { nonce: web3.toHex(nonce), gasLimit: web3.toHex(gasLimit), gasPrice: web3.toHex(gasPrice), to: contractAddress } console.log(TxC); console.log(txOptions); rawTx = txutils.functionTx(interface, 'foreignBuy', [AddressC, ValueT, TxC], txOptions); sendRaw(rawTx); k++; nonce++; /* while(web3.eth.getTransactionReceipt(Ntrans)=="null") { } */ } setTimeout(function(){ recurs(); }, 5000); } recurs();