Last active
March 17, 2021 01:05
-
-
Save boid-com/41b1f8a4704f6a22f439084c09ad3637 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const env = require('./.env') | |
const { api, rpc } = require('./eosjs')(env.keys, 'https://jungle3.greymass.com') | |
const watchAccounts = [ | |
'powerupwatch', | |
'vigorworker1', | |
'vigorworker2', | |
'vigorworker3', | |
'vigorworker4', | |
'vigorworker5', | |
] | |
const watcher = 'powerupwatch' | |
async function init() { | |
try { | |
for (const account of watchAccounts) { | |
console.log(account) | |
const existingCPU = (await api.rpc.get_account(account)).cpu_limit.available | |
console.log("Existing CPU:", Number(existingCPU).toLocaleString()) | |
if (existingCPU > 4000) continue | |
const transact = await api.transact({ | |
actions: [{ | |
account: 'eosio', | |
name: 'powerup', | |
authorization: [{ actor: watcher, permission: 'active' }], | |
data: { | |
payer: watcher, | |
receiver: account, | |
days: 1, | |
net_frac: 50000, | |
cpu_frac: 30000000000, | |
max_payment: "10.0000 EOS" | |
}, | |
}] | |
}, { | |
blocksBehind: 12, | |
expireSeconds: 15, | |
broadcast: true | |
}).catch(er => console.log(er.toString())) | |
if (transact) console.log(transact.transaction_id) | |
const cpuAfter = (await api.rpc.get_account(account)).cpu_limit.available | |
console.log("cpuAfter:", Number(cpuAfter).toLocaleString(), "\n") | |
} | |
} catch (error) { | |
console.error(error) | |
} | |
} | |
init() | |
setInterval(init, 30000) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment