Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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