0

I'm trying to create a crowdsale contract with open-zeppelin. I'm using SampleCrowdsale.sol. I believe the following line of code creates a token contract and mints the token upon receiving ether.

 function createTokenContract() internal returns (MintableToken) { return new SampleCrowdsaleToken(); } 

However, I rather want the crowdsale contract to mint a token in another mintable token contract. Is there any way the crowdsale contract can interact with an external token contract? Any suggestion or code snippet would be really helpful.

1 Answer 1

1

Yes what you need to do is first create your token in a separate contract. Then when you create your crowdsale you pass in the constructor the address of your token.

This is a sample taken from the Ethereum Crowdfund your idea

pragma solidity ^0.4.16; interface token { function mintToken(address receiver, uint amount); } contract Crowdsale { token public tokenReward; /** * Constrctor function */ function Crowdsale( address addressOfTokenUsedAsReward ) { tokenReward = token(addressOfTokenUsedAsReward); } } 
3
  • Thanks for guiding! However, doesn't it need some kind of authorization? I mean shouldn't this allow me to mint any existing token for which I've an address? Commented Dec 22, 2017 at 7:51
  • @qmFaisal Yes, if you're using the Ownership contract with your token then you can simply give ownership to the crowdsale contract. Just make sure you're capable of getting back the ownership of token and also that everything is secure. Commented Dec 22, 2017 at 15:11
  • @qmFaisal Btw you have asked a lot of questions without ever accepting one. Consider accepting answers that solve your problem. Commented Dec 22, 2017 at 18:25

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.