Our token sale contract will handle the mechanics of buying and selling our token in ether. To do this, our token sale contract will have to communicate with our ERC-20 contract in order to perform transfers from our token sale contract's balance to the balances of participants. For this communication, the token sale contract must know which functions are supported in our ERC-20 contract. This can be done in one of two ways:
- Define an interface: We can use Solidity's interface keyword to define the parts of the ERC-20 contract that the token sale contract needs to use. We would make this declaration in the same file, above the token-sale contract body.
- Import the ERC-20 contract: We can use an import statement to include the entire ERC-20 contract. For our implementation, this is the method we'll use.
First, create a new...