-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.js
29 lines (21 loc) · 840 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
const HDWalletProvider = require('@truffle/hdwallet-provider');
const Web3 = require('web3');
const { abi, evm } = require('./compile');
require('dotenv').config();
const MNEMONIC = process.env.MNEMONIC;
const INFURA_KEY = process.env.INFURA_KEY;
const INITIAL_MESSAGE = 'Hi there!';
const GAS = '1000000';
const provider = new HDWalletProvider(MNEMONIC, INFURA_KEY);
const web3 = new Web3(provider);
const deploy = async () => {
const accounts = await web3.eth.getAccounts();
console.log('Attempting to deploy from account', accounts[0]);
const result = await new web3.eth.Contract(abi)
.deploy({ data: evm.bytecode.object })
.send({ gas: GAS, from: accounts[0] });
console.log('Contract deployed to', result.options.address);
console.log('interface', JSON.stringify(abi));
provider.engine.stop();
};
deploy();