diff options
Diffstat (limited to 'runTimer.js')
-rw-r--r-- | runTimer.js | 102 |
1 files changed, 102 insertions, 0 deletions
diff --git a/runTimer.js b/runTimer.js new file mode 100644 index 0000000..3981687 --- /dev/null +++ b/runTimer.js @@ -0,0 +1,102 @@ +const Web3 = require('@cobinhood/web3'); +const { mnemonicToSeed } = require('bip39'); +const { fromMasterSeed } = require('ethereumjs-wallet/hdkey'); +const { mnemonic } = require('./secret'); +const lottery = require('./build/contracts/Lottery.json'); +const address = '0xd6141c8099670fe22a67eea3224d559c5d05aa55'; + +const web3 = new Web3('https://testnet-rpc.dexon.org'); +// const times = [ +// 1555570800, // 4/18 15:00 +// 1555581600, // 4/18 18:00 +// 1555592400, // 4/18 21:00 +// 1555603200, // 4/19 0:00 +// 1555614000, // 4/19 3:00 +// 1555624800, // 4/19 6:00 +// 1555635600, // 4/19 9:00 +// 1555646400, // 4/19 12:00 +// 1555657200, // 4/19 15:00 +// 1555668000, // 4/19 18:00 +// 1555678800, // 4/19 21:00 +// 1555689600, // 4/20 0:00 +// 1555700400, // 4/20 3:00 +// 1555711200, // 4/20 6:00 +// 1555722000, // 4/20 9:00 +// 1555732800, // 4/20 12:00 +// 1555743600, // 4/20 15:00 +// 1555754400, // 4/20 18:00 +// 1555765200, // 4/20 21:00 +// 1555776000, // 4/21 0:00 +// 1555786800, // 4/21 3:00 +// 1555797600, // 4/21 6:00 +// 1555808400, // 4/21 9:00 +// 1555819200, // 4/21 12:00 +// 1555830000, // 4/21 15:00 +// 1555840800, // 4/21 18:00 +// 1555851600, // 4/21 21:00 +// 1555862400, // 4/22 0:00 +// 1555873200, // 4/22 3:00 +// 1555884000, // 4/22 6:00 +// 1555894800, // 4/22 9:00 +// 1555905600, // 4/22 12:00 +// 1555916400, // 4/22 15:00 +// 1555927200, // 4/22 18:00 +// 1555938000, // 4/22 21:00 +// 1555948800, // 4/23 0:00 +// 1555959600, // 4/23 3:00 +// 1555970400, // 4/23 6:00 +// 1555981200, // 4/23 9:00 +// 1555992000, // 4/23 12:00 +// 1556002800, // 4/23 15:00 +// 1556013600, // 4/23 18:00 +// 1556024400, // 4/23 21:00 +// 1556035200, // 4/24 0:00 +// 1556046000, // 4/24 3:00 +// 1556056800, // 4/24 6:00 +// 1556067600, // 4/24 9:00 +// 1556078400, // 4/24 12:00 +// 1556089200, // 4/24 15:00 +// 1556100000, // 4/24 18:00 +// 1556110800, // 4/24 21:00 +// 1556121600, // 4/25 0:00 +// 1556132400, // 4/25 3:00 +// 1556143200, // 4/25 6:00 +// 1556154000, // 4/25 9:00 +// 1556164800, // 4/25 12:00 +// ]; + +const times = [ + 1554636900, + 1554636910, + 1554636920, +]; + +let account; +let contract; + +const runTime = time => { + if ((time + 5) > (Date.now() / 1000)) { + setTimeout(() => runTime(time), 5000); + return; + } + + contract.methods.reveal(time).send({ + from: account.address, + gas: 1000000, + }); + + console.log('Revealed for: ', time); +}; + +mnemonicToSeed(mnemonic) + .then(seed => { + const hdWallet = fromMasterSeed(seed); + const key = hdWallet.derivePath('m/44\'/237\'/0\'/0/0'); + const privateKey = `0x${key._hdkey._privateKey.toString('hex')}`; + + web3.eth.accounts.wallet.add(privateKey); + account = web3.eth.accounts.privateKeyToAccount(privateKey); + contract = new web3.eth.Contract(lottery.abi, address); + + times.forEach(runTime); + }); |