Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases now! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
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

Using tokens and executing logic

You might be wondering how a third person could execute a call upon receiving tokens. Actually, it is ridiculously easy. This can be done in JavaScript using the Web3 library provided by Ethereum. The following is a smart contract shown on remix. We have explored remix earlier:

A smart contract

This just increments an integer, checks whether it's less than 10, and returns true if it is; it returns false otherwise. You can just use JavaScript VM for this problem. On compiling and running, if you click the SampleFunc, there will be a new entry added in the gray area. If you click on Details, you will see an input entry—you can copy this. This will be your third parameter for this function. You can execute this like any other function.

Now, if you send tokens using the ERC827 smart contract, this function will be executed.

But what...

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