Skip to content

Commit 6e41655

Browse files
committed
Update 2_deploy_contracts.js
1 parent 2081760 commit 6e41655

File tree

1 file changed

+10
-17
lines changed

1 file changed

+10
-17
lines changed

migrations/2_deploy_contracts.js

+10-17
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,20 @@
11
const MyToken = artifacts.require("./MyToken.sol");
22
const MyTokenCrowdsale = artifacts.require("./MyTokenCrowdsale.sol");
33

4-
module.exports = function(deployer, network, accounts) {
4+
const web3 = require("web3-utils");
5+
6+
module.exports = (deployer, network, [owner]) => {
7+
58
const _name = "My Token TRC20";
69
const _symbol = "MYT";
710
const _decimals = 18;
811
const _initialSupply = 16000000;
912
const _rate = 500;
10-
const _wallet = accounts[0];
11-
12-
let token, crowdsale;
13+
const _crowdsaleTokens = web3.toWei("8000000", "ether");
14+
1315
return deployer
14-
.then(() => {
15-
return deployer.deploy(MyToken, _name, _symbol, _decimals, _initialSupply);
16-
})
17-
.then((instance) => {
18-
token = instance;
19-
return deployer.deploy(MyTokenCrowdsale, _rate, _wallet, MyToken.address, _wallet);
20-
})
21-
.then((instance) => {
22-
crowdsale = instance;
23-
token.transferOwnership(crowdsale.address);
24-
token.approve(crowdsale.address, _initialSupply * 10 ** 18 );
25-
});
26-
16+
.then(() => deployer.deploy(MyToken, _name, _symbol, _decimals, _initialSupply))
17+
.then(() => deployer.deploy(MyTokenCrowdsale, _rate, owner, MyToken.address, owner))
18+
.then(() => MyToken.deployed())
19+
.then(token => token.approve(MyTokenCrowdsale.address, _crowdsaleTokens ));
2720
};

0 commit comments

Comments
 (0)