Search icon CANCEL
Subscription
0
Cart icon
Close icon
You have no products in your basket yet
Save more on your purchases!
Savings automatically calculated. No voucher code required
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Hands-On Blockchain for Python Developers

You're reading from  Hands-On Blockchain for Python Developers

Product type Book
Published in Feb 2019
Publisher Packt
ISBN-13 9781788627856
Pages 450 pages
Edition 1st Edition
Languages
Concepts
Author (1):
Arjuna Sky Kok Arjuna Sky Kok
Profile icon Arjuna Sky Kok

Table of Contents (19) Chapters

Preface 1. Section 1: Blockchain and Smart Contracts
2. Introduction to Blockchain Programming 3. Smart Contract Fundamentals 4. Implementing Smart Contracts Using Vyper 5. Section 2: Web3 and Populus
6. Interacting with Smart Contracts Using Web3 7. Populus Development Framework 8. Building a Practical Decentralized Application 9. Section 3: Frontend Decentralized Applications
10. Frontend Decentralized Application 11. Section 4: Cryptocurrency and Wallets
12. Creating Token in Ethereum 13. Cryptocurrency Wallet 14. Section 5: Decentralized Filesystem
15. InterPlanetary - A Brave New File System 16. Using ipfsapi to Interact with IPFS 17. Implementing a Decentralized Application Using IPFS 18. Other Books You May Enjoy

Developing a commercial voting application

Let's upgrade our smart contract to a commercial one. To vote, the voter needs to pay a small amount of money. This is similar to American Idol, in which people vote for who they want to win by text-messaging their choice.

Go back to the voting_project directory and open a new file in the contracts directory and name this CommercialVoting.vy. Refer to the code file in the following GitLab link for the full code of this code block: https://gitlab.com/arjunaskykok/hands-on-blockchain-for-python-developers/blob/master/chapter_06/voting_project/contracts/CommercialVoting.vy:

struct Proposal:
name: bytes32
vote_count: int128

proposals: public(map(int128, Proposal))

voters_voted: public(map(address, int128))

manager: public(address)

...
...

@public
def withdraw_money():
assert msg.sender == self.manager

send(self.manager, self.balance...
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 €14.99/month. Cancel anytime}