-
Notifications
You must be signed in to change notification settings - Fork 1
/
deploy.js
29 lines (21 loc) · 927 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
//purpose of this folder is to deploy compiled code to the network
//thorugh instance of this we are able to connect to infura node with wallet
const HDWalletProvider=require('truffle-hdwallet-provider');
const Web3=require('web3');
//compiled contract into bytecode and interface
const {evm,abi}=require('./compile');
const provider=new HDWalletProvider(
//mneumonic with infura rinkeby endopoint
'economy cheap survey survey unknown gesture orange carpet audit suspect rough announce',
'https://rinkeby.infura.io/v3/e8078e317212477ea40f124aa8949a9b'
);
const web3=new Web3(provider);
const deploy=async()=>{
const accounts=await web3.eth.getAccounts()
console.log("Deploying from acount",accounts[0])
const result=await new web3.eth.Contract(abi)
.deploy({data:evm.bytecode.object})
.send({gas:'1000000',from:accounts[0]})
console.log('Contract deployed to',result.options.address)
}
deploy()