Skip to content

Instantly share code, notes, and snippets.

@mason276752
Created July 6, 2021 07:08
Show Gist options
  • Save mason276752/596b8e289399bf4e6d0dd34b2d4a51d0 to your computer and use it in GitHub Desktop.
Save mason276752/596b8e289399bf4e6d0dd34b2d4a51d0 to your computer and use it in GitHub Desktop.
sendETHtx
const ethers = require('ethers')
const randomWallet = new ethers.Wallet.createRandom()
let address = ""
const chainId= 0
const count = 1000
const wsUrl = "ws://xxx.xxx.xxx.xxx:xxxx"
const txs = [];
(async () => {
// genTx
for (const i = 0; i < count; i++) {
const tx = await randomWallet.signTransaction({
chainId: chainId,
to: address,
value: "0x00",
nonce: i,
gasPrice: "0x0",
gasLimit: 210000
})
txs.push(tx);
(i % (count / 10)) === 0 && console.log((i / (count / 100)) + "%")
}
console.log("100%")
// sendTx
const provider = new ethers.providers.WebSocketProvider(wsUrl)
const startTime = Date.now()
txs.forEach((tx) => {
provider.sendTransaction(tx).catch((e) => e).then(console.log)
})
const endTime = Date.now()
console.log("time:" + (endTime - startTime))
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment