我正在尝试在nodejs中使用time.sleep(1)
之类的东西,
这是我的代码
const Web3 = require('web3')
const web3 = new Web3('ws://127.0.0.1:8546')
async function main() {
const batch = new web3.BatchRequest();
for (let i = 0; i < 1; i++) {
for (let i = 0; i < 1000; i++) {
const tx = web3.eth.sendTransaction.request(
{
from: web3.utils.toChecksumAddress("0xa00ce1f7fbf8298f4163ab23de8752942bdff98e"),
to: web3.utils.toChecksumAddress("0xa00ce1f7fbf8298f4163ab23de8752942bdff98e"),
gas: 21000,
gasPrice: 1000000000,
value: 1
}
)
batch.add(tx)
}
batch.execute();
// time.sleep(1) should go here
}
}
main()
谢谢!