Created
June 24, 2019 06:16
-
-
Save 0GiS0/61e16c702854b30e1a2732b901eda990 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
const Web3 = require('web3'); | |
let web3 = new Web3(new Web3.providers.HttpProvider("HTTP://127.0.0.1:7545")); | |
web3.eth.getAccounts().then(accounts => { | |
//Get the account which create the contract | |
let creatorAccount = accounts[0]; | |
//Deploy contract | |
const contract = new web3.eth.Contract(abi); | |
contract.deploy({ | |
data: '0x' + bytecode | |
}).send({ | |
from: creatorAccount, | |
gas: 1500000, | |
gasPrice: '30000000000000' | |
}, (error, transactionHash) => { | |
if(error){ | |
console.log(`error: ${error}`); | |
} | |
else{ | |
console.log(`transaction hash: ${transactionHash}`); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment