-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.js
More file actions
31 lines (24 loc) · 1.01 KB
/
Copy pathdeploy.js
File metadata and controls
31 lines (24 loc) · 1.01 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
27
28
29
30
31
require("dotenv").config();
const Web3 = require("web3");
//Factory.json file contains my compiled Factory.sol file
const contract = require("./build/contracts/GalaTokenTimeLock.json");
const PrivateKeyProvider = require("truffle-privatekey-provider");
const tokenAddress = process.argv[2];
const time = '0';
if (process.argv[3]) {
time = process.argv[3];
}
const privateKey = process.env.PRIVATE_KEY;
const web3url = process.env.WEB3URL;
const provider = new PrivateKeyProvider(privateKey, web3url);
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(contract.abi)
.deploy({ data: contract.bytecode, arguments: [tokenAddress, '0'] })
.send({ gas: "2000000", from: accounts[0] });
//This will display the address to which your contract was deployed
console.log("Contract deployed to: ", result.options.address);
};
deploy();