forked from jchai002/crypto-payment-gateway
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.js
49 lines (42 loc) · 1.46 KB
/
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
var WellCrowdsale = artifacts.require('../contracts/WellCrowdsale.sol');
function latestTime() {
return web3.eth.getBlock('latest').timestamp;
}
function ether(n) {
return new web3.BigNumber(web3.toWei(n, 'ether'))
}
const duration = {
seconds: function(val) { return val},
minutes: function(val) { return val * this.seconds(60) },
hours: function(val) { return val * this.minutes(60) },
days: function(val) { return val * this.hours(24) },
weeks: function(val) { return val * this.days(7) },
years: function(val) { return val * this.days(365)}
}
const BigNumber = web3.BigNumber;
// 1 wei --> 1200 TestToken
const rate = 1200;
// start one week from now
const startTime = latestTime()+duration.minutes(1);
// run for one week
const endTime = startTime + duration.weeks(1);
module.exports = function(deployer, network, accounts) {
return liveDeploy(deployer, accounts);
};
async function liveDeploy(deployer, accounts) {
const address = accounts[0];
console.log("Contract arguments: ", {
startTime: startTime,
endTime: endTime,
rate: rate,
address: address
});
// Deploy the crowdsale
return deployer.deploy(WellCrowdsale, startTime, endTime, rate, address).then(async() => {
// Wait until its depoyed
const contract = await WellCrowdsale.deployed();
// Lookup and print the token associated with the crowdsale contract
const token = await contract.token.call();
console.log('Token address: ', token);
});
}