-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdeploy.js
More file actions
41 lines (25 loc) · 894 Bytes
/
deploy.js
File metadata and controls
41 lines (25 loc) · 894 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const Web3 = require('web3');
const fs = require('fs');
const web3 = new Web3(new Web3.providers.HttpProvider('HTTP://127.0.0.1:7545'));
const {abi,bytecode} = require('./compile');
let blog;
let account = "0xb8E6BAaeeE33AA0fcfEC7D764119E7B8E705FF13";
let accountPvtKey = "55e10468de86511d1d2a7240df6676a076aed818819331643659322d677fd125";
const contract = new web3.eth.Contract(JSON.parse(abi));
console.log(abi);
blog = contract.deploy({data:bytecode,from:account,gas:"4630",gasLimit:"6385876"});
const call = async() => {
const createTransaction = await web3.eth.accounts.signTransaction(
{
data: blog.encodeABI(),
gas: await blog.estimateGas(),
},
accountPvtKey
);
const createReceipt = await web3.eth.sendSignedTransaction(
createTransaction.rawTransaction
);
console.log(createReceipt.contractAddress);
}
// console.log(blog);
call();