Skip to content

Instantly share code, notes, and snippets.

@0GiS0
Created June 24, 2019 06:16
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 0GiS0/61e16c702854b30e1a2732b901eda990 to your computer and use it in GitHub Desktop.
Save 0GiS0/61e16c702854b30e1a2732b901eda990 to your computer and use it in GitHub Desktop.
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