Created
December 24, 2017 20:02
-
-
Save thestuntcoder/dca55f86e3a9c5e614e2a9c0efb4435c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
var Web3 = require('web3'); | |
var solc = require('solc'); | |
var fs = require('fs'); | |
var web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545")); | |
//replace this with whatever is your local user address | |
var userAddress = '0x143a7c5eb8cf1c4f72460b8d29d686b3399bb0f9'; | |
var compiledCode = solc.compile(fs.readFileSync('Miles.sol').toString()); | |
var abi = compiledCode.contracts[':Miles'].interface; | |
var bcode = "0x" + compiledCode.contracts[':Miles'].bytecode; | |
var MilesContract = new web3.eth.Contract( | |
JSON.parse(abi), | |
userAddress | |
// '0x1234567890123456789012345678901234567891' | |
); | |
var deployedContract = MilesContract.deploy({ data: bcode }).send({ | |
from: userAddress, | |
gas: 1500000, | |
gasPrice: '3' | |
}); | |
MilesContract.methods.addMiles().send({ | |
from: userAddress | |
}); | |
MilesContract.methods.totalMiles().call().then(console.log); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment