Search icon
Subscription
0
Cart icon
Close icon
You have no products in your basket yet
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Ethereum Projects for Beginners

You're reading from  Ethereum Projects for Beginners

Product type Book
Published in Jul 2018
Publisher Packt
ISBN-13 9781789537406
Pages 106 pages
Edition 1st Edition
Languages

Changing our application with a better payment application


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 call a pot. This is used to collect the creatorFees. The conversion rate is the rate that is used to multiply...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}