Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Ethereum Projects for Beginners

You're reading from   Ethereum Projects for Beginners Build blockchain-based cryptocurrencies, smart contracts, and DApps

Arrow left icon
Product type Paperback
Published in Jul 2018
Publisher Packt
ISBN-13 9781789537406
Length 106 pages
Edition 1st Edition
Arrow right icon
Toc

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...

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 $19.99/month. Cancel anytime