Skip to content

Commit

Permalink
script to loop tx's
Browse files Browse the repository at this point in the history
  • Loading branch information
Aodhgan committed May 12, 2021
1 parent e515592 commit d77c360
Showing 1 changed file with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions scripts/twoTransactions.js
@@ -0,0 +1,66 @@
const chalk = require('chalk');
const hardhat = require('hardhat')


function dim() {
console.log(chalk.dim.call(chalk, ...arguments))
}

function green() {
console.log(chalk.green.call(chalk, ...arguments))
}

async function fireTwoTransactions(){
dim("running fireTwoTransactions")

const {ethers } = hardhat

const signer = await hardhat.ethers.getNamedSigner("deployer")

dim("signer address is", signer._address)

const prizeStrategyUpkeep = await ethers.getContract("PrizeStrategyUpkeep", signer)
const { upkeepNeeded, performData } = await prizeStrategyUpkeep.checkUpkeep([])

dim("prize strategy at ", prizeStrategyUpkeep.address)

if(upkeepNeeded){
// fire first performUpkeep()
dim(`Sending performUpkeep 1`)
const unsignedTx1 = await prizeStrategyUpkeep.populateTransaction.performUpkeep([])
const gasLimit1 = ((await prizeStrategyUpkeep.estimateGas.performUpkeep([])).toNumber() * 2)
const gasPrice1 = ((await prizeStrategyUpkeep.gasPrice1.performUpkeep([])).toNumber())
console.log(`performUpkeep(). Gas limit: ${gasLimit1.toString()}`)
await relayer.sendTransaction({
to: unsignedTx1.to,
data: unsignedTx1.data,
gasLimit1,
gasPrice1
})

dim(`Sending performUpkeep 2`)
const unsignedTx = await prizeStrategyUpkeep.populateTransaction.performUpkeep([])
const gasLimit = ((await prizeStrategyUpkeep.estimateGas.performUpkeep([])).toNumber() * 2)
const gasPrice = ((await prizeStrategyUpkeep.gasPrice.performUpkeep([])).toNumber() * 2) // double the gasPrice vs first tx
console.log(`performUpkeep(). Gas limit: ${gasLimit.toString()}`)
await relayer.sendTransaction({
to: unsignedTx.to,
data: unsignedTx.data,
gasLimit,
gasPrice
})

}

}




async function run(){
while(true){
await fireTwoTransactions()
}
}

run()

0 comments on commit d77c360

Please sign in to comment.