This section will focus on us improving our code. This will include adding functionalities such as depositing ether, gaining tokens, and withdrawing ether in exchange of tokens and also a creator fee.
We will work on the same code that was used for the previous section and continue to build on it.
As we do not want to give away free tokens in exchange for deposited ether, we will eliminate the following line of code completely:
function MetaCoin() public {
balances[tx.origin] = 10000;
}
We begin by setting a creator. To do this, we will need to define an address creator and a creatorFee as follows:
contract MetaCoin {
mapping (address => uint) balances;
address creator;
uint creatorFee = 1;
uint collectedFees = 0;
uint conversionRate = 5;
uint CURRENCY_MULTIPLIER = 10**18;
The collectedFees is what one might...