-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.js
More file actions
30 lines (19 loc) · 837 Bytes
/
Copy pathdeploy.js
File metadata and controls
30 lines (19 loc) · 837 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
const HDWalletProvider = require('truffle-hdwallet-provider');
const Web3 = require('web3')
const { interface , bytecode } = require('./compile')
const provider = new HDWalletProvider(
'book elite flame birth jealous panda dolphin clutch purity carbon wear dawn',
'https://rinkeby.infura.io/v3/24632a499b634c5ca0618039379ef5bb'
)
const web3 = new Web3(provider)
let INIT_MSG = "Hi ! there ,"
const deploy = async () =>{
const accounts = await web3.eth.getAccounts();
console.log(`Attempting to deploy from account : ${accounts[0]}`)
//the contract
inbox = await new web3.eth.Contract(JSON.parse(interface))
.deploy({ data : bytecode , arguments : [INIT_MSG] })
.send({from : accounts[0] , gas:'1000000'})
console.log(`Contract deployed to : ${inbox.options.address}`)
}
deploy()