-
-
Save s-tajima/970901318960c038291ff90f4404fe35 to your computer and use it in GitHub Desktop.
CODE BLUE 2018 Smart Contract Hacking Challenge Write Up
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 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.accounts.wallet.add(account); | |
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