-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy path3_deploy_lottery.js
26 lines (24 loc) · 1.04 KB
/
3_deploy_lottery.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
global.artifacts = artifacts;
global.web3 = web3;
const GOATConfig = require('../GOATlib/GOATConfig');
var CasinoExchange = global.artifacts.require("./CasinoExchange.sol");
var Lottery = global.artifacts.require("Lottery");
module.exports = function(deployer, network, accounts) {
//deploy the lottery contract
return deployer.deploy(Lottery, {from: GOATConfig.accounts.casinoOwner}).then(function(){
return Promise.all([
//get deployed exchange and request casinoToken address from it
CasinoExchange.deployed().then(function(CasinoExchangeInstance){
return CasinoExchangeInstance.casinoToken.call()
}),
//wait for lottery to be deployed
Lottery.deployed()
]).then(function(promises){
return ((function(CasinoTokenAddress, LotteryInstance){
//initialize the lottery with the address of the token
console.log("initializing lottery with token address: ", CasinoTokenAddress)
return LotteryInstance.initLottery.sendTransaction(CasinoTokenAddress, {from: GOATConfig.accounts.casinoOwner})
}).apply(null, promises))
})
})
};