Last active
March 27, 2018 14:25
-
-
Save Gim6626/4a1a2970976b24c0a7d048f15c7c7e42 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
let eth_secrets = require('./eth_secrets'); | |
let Web3 = require('web3'); // Requires web3 0.* version, does not work with web3 1.* | |
let sleep = require('system-sleep'); | |
let web3 = new Web3(); | |
web3.setProvider(new web3.providers.HttpProvider('http://localhost:8545')); | |
let address = process.argv[2]; | |
let abi = JSON.parse(process.argv[3]); | |
let adc = web3.eth.contract(abi).at(address); | |
web3.personal.unlockAccount(web3.personal.listAccounts[0], eth_secrets.main_eth_account_passphrase); | |
adc.payForWork({from: web3.personal.listAccounts[0], gas: 999999} ); // TODO: Estimate gas | |
sleep(60 * 1000); // TODO: Correctly wait till transaction ends | |
if (adc.state() == 'Ad payed') { | |
console.log('Ad was payed'); | |
} else if (adc.state() == 'Not enough tokens to pay for work') { | |
console.log('Error: Not enough tokens to pay for work'); | |
} else { | |
console.log('Error: Unknown error'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment