-
Notifications
You must be signed in to change notification settings - Fork 1
/
deploy.js
32 lines (25 loc) · 963 Bytes
/
deploy.js
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
const HDWalletProvider = require('truffle-hdwallet-provider');
const Web3 = require('web3');
const fs = require('fs-extra');
const path = require('path')
const Campaign = require('./build/Campaign.json');
const CampaignFactory = require('./build/CampaignFactory.json');
var provider = new HDWalletProvider(
'Your Account Memomnic',
'https://rinkeby.infura.io/YfN9MatBIrqHOPqfZz5l'
);
const web3 = new Web3(provider);
const deploy = async()=>{
const accounts = await web3.eth.getAccounts();
const result = await new web3.eth.Contract(JSON.parse(CampaignFactory.interface))
.deploy({data : CampaignFactory.bytecode})
.send({from : accounts[0],gas : '3000000'});
const data = {
"address" : result.options.address
};
const addressPath = path.resolve(__dirname,'build','address.json');
fs.ensureFileSync(addressPath);
fs.outputJsonSync(addressPath,data);
console.log(result.options.address);
};
deploy();