Skip to content

Instantly share code, notes, and snippets.


s-tajima/call.js Secret

Created Nov 4, 2018
What would you like to do?
CODE BLUE 2018 Smart Contract Hacking Challenge Write Up
const fs = require('fs');
const Web3 = require('web3');
const web3 = new Web3("__ETHEREUM_NODE__")
var abi = fs.readFileSync('./contract.abi.json', 'utf8');
var account = web3.eth.accounts.privateKeyToAccount(__PRIVATE_KEY__);
web3.eth.defaultAccount = account.address;
var contract = new web3.eth.Contract(JSON.parse(abi), "0x64ba926175Bc69bA757eF53A6D5EF616889C9999");
var value = web3.utils.toWei('0.001', 'ether')
var gas = 200000
var guess = 4
contract.methods.do_guess(guess).send({from: account.address, value: value, gas: gas})
.on('transactionHash', function(hash){
console.log("transaction hash: ", hash);
.on('receipt', function(receipt){
console.log("receipt: ", receipt);
.on('confirmation', function(confirmationNumber, receipt){
console.log("confirmationNumber: ", confirmationNumber);
.on('error', console.error);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.