-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdeploy.js
More file actions
31 lines (22 loc) · 927 Bytes
/
Copy pathdeploy.js
File metadata and controls
31 lines (22 loc) · 927 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
27
28
29
30
31
//for wallet interface
const HDWalletProvider = require('truffle-hdwallet-provider');
const Web3 = require('web3');
// get bytecode and interface
const {interface, bytecode} = require('./compile');
// work with the API by Infura to Rinkeby network, and the Mnemonic
const provider = new HDWalletProvider(
"senior oven seek shop solve worth general fiscal wave meat demise kiwi",
'https://rinkeby.infura.io/jHZbiuFORTISdLGOrQhk'
);
const web3 = new Web3(provider);
let accounts
const deploy = async () => {
accounts = await web3.eth.getAccounts();
console.log('Attempting to deploy from accout:', accounts[0])
const result = await new web3.eth.Contract(JSON.parse(interface))
.deploy({ data: bytecode, arguments: ['Toyota Motors', 'Japan']})
.send({gas:'3000000', from: accounts[0]})
console.log(interface);
console.log('Contract deployed to', result.options.address)
};
deploy()