-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdeploy.js
More file actions
26 lines (23 loc) · 1.03 KB
/
deploy.js
File metadata and controls
26 lines (23 loc) · 1.03 KB
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 Preferences = require("preferences");
const HDWalletProvider = require('truffle-hdwallet-provider');
const Web3 = require('web3');
const { interface, bytecode } = require('./compile.js');
const provider = new HDWalletProvider(
//Mnemonic
"onion over warrior aware lava crisp hope purpose easy sense purse morning",
//Infura Rinkeby API Key
'https://rinkeby.infura.io/ED9vOUpLhJwFOiFGcBRM'
);
const web3 = new Web3(provider);
const deploy = (async() => {
//Get a list of all accounts
const accounts = await web3.eth.getAccounts();
var result = await new web3.eth.Contract (JSON.parse(interface))
result = await result.deploy({ data: bytecode, arguments: [] })
result = await result.send({ from: accounts[0], gas: '3000000' });
console.log("Contract deployed at ", result.options.address);
console.log("ABI: ",result.options.jsonInterface);
var prefs = new Preferences('cryptodoc');
prefs.address = result.options.address;
prefs.abi = JSON.stringify(result.options.jsonInterface);
})();