You have to do something like this:
Token.sol
// This should be an abstract interface without implementation constractcontract Token { function mint(address _to, uint _amount) public returns (bool); // Rest of the ERC20 methodscode }
CrowdsaleToken.sol
import "Token.sol"; // This contract contains the implementation of ERC20 methods contract CrowdsaleToken is Token { function mint(address _to, uint _amount) public returns (bool) { balances[_to] = balances[_to] + _amount; return true; } // ImplementationRest of other ERC20the methodscode }
Crowdsale.sol
import "Token.sol"; // The Crowdsale interact with CrowdsaleToke through the // abstract interface Token contact Crowdsale { Token crowdsaleToken; // Address of the CrowdsaleToken function Crowdsale(address _crowdsaleToken) { // We receive the CrowdsaleToken addres as constructor param crowdsaleToken = Token(_crowdsaleToken); // We can use the CrowdsaleToken contract crowdsaleToken.mint(msg.sender, 0x31415926535); } // Other crowdsale methods }
The deployment is done in two steps
- Deploy CrowdsaleToken, await for the contract address
- Deploy Crowdsale and pass the CrowdsaleToken address as parameter
That is the basic idea.
Some frameworks like Truffle and Populus can be used to automate some of this tasks.