forked from iwasaki-kenta/canteen
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdeploy.js
More file actions
24 lines (18 loc) · 833 Bytes
/
deploy.js
File metadata and controls
24 lines (18 loc) · 833 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import Web3 from 'web3'
import Canteen from './build/contracts/Canteen.json'
const web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:8545'))
const account = web3.eth.accounts.wallet.add('0xc87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3')
const contract = new web3.eth.Contract(Canteen.abi)
const transaction = contract.deploy({data: Canteen.unlinked_binary});
web3.eth.estimateGas({data: Canteen.unlinked_binary})
.then(estimatedGas => {
console.log(`Estimated Gas Required: ${estimatedGas}`)
transaction
.send({
from: account.address,
gas: estimatedGas
})
.on('transactionHash', hash => console.log(`Transaction Hash: ${hash}`))
.on('receipt', receipt => console.log(`Contract Address: ${receipt.contractAddress}`))
}
)