-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.js
35 lines (28 loc) · 863 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
33
34
35
const HDWalletProvider = require('truffle-hdwallet-provider');
const Web3 = require('web3');
const compile = require('./compile');
const provider = new HDWalletProvider(
'fatal dragon lecture muscle announce thing mind undo analyst among cigar text',
'https://rinkeby.infura.io/hztpQ6ikuvm1cpdy6sjW'
);
const web3 = new Web3(provider);
const jsonInterface = JSON.parse(compile.interface);
const deploy = async () => {
try {
const accounts = await web3.eth.getAccounts();
console.log('attempting to deploy from the account:',accounts[0]);
const result = await new web3.eth.Contract(jsonInterface)
.deploy({
data : compile.bytecode ,
arguments : ['Hello World!']
})
.send({
gas : '30000000',
from : accounts[0]
});
console.log('contract deployed to :',result.options.address);
} catch(error){
console.log(error);
}
};
deploy();