Skip to content

Instantly share code, notes, and snippets.

@Gim6626
Last active March 27, 2018 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Gim6626/4a1a2970976b24c0a7d048f15c7c7e42 to your computer and use it in GitHub Desktop.
Save Gim6626/4a1a2970976b24c0a7d048f15c7c7e42 to your computer and use it in GitHub Desktop.
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