Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Hands-On Blockchain for Python Developers
  • Table Of Contents Toc
Hands-On Blockchain for Python Developers

Hands-On Blockchain for Python Developers - Second Edition

By : Arjuna Sky Kok
close
close
Hands-On Blockchain for Python Developers

Hands-On Blockchain for Python Developers

By: Arjuna Sky Kok

Overview of this book

We are living in the age of decentralized fi nance and NFTs. People swap tokens on Uniswap, borrow assets from Aave, send payments with stablecoins, trade art NFTs on OpenSea, and more. To build applications of this kind, you need to know how to write smart contracts. This comprehensive guide will help you explore all the features of Vyper, a programming language designed to write smart contracts. You’ll also explore the web3.py library. As you progress, you’ll learn how to connect to smart contracts, read values, and create transactions. To make sure your foundational knowledge is strong enough, the book guides you through Ape Framework, which can help you create decentralized exchanges, NFT marketplaces, voting applications, and more. Each project provides invaluable insights and hands-on experience, equipping you with the skills you need to build real-world blockchain solutions. By the end of this book, you’ll be well versed with writing common Web3 applications such as a decentralized exchange, an NFT marketplace, a voting application, and more.
Table of Contents (27 chapters)
close
close
Lock Free Chapter
1
Part 1:Blockchain and Smart Contract
5
Part 2: Web3 and Ape Framework
9
Part 3: Graphical User Interface Applications
12
Part 4: Related Technologies
16
Part 5: Cryptocurrency and NFT
19
Part 6: Writing Complex Smart Contracts
23
Part 7: Building a Full-Stack Web3 Application

Functions

A function in Vyper is exactly like a function in a Python program. You group statements inside a code block unit and execute them anytime you want. The code block is the function. You’ve seen functions in Storage.vy. There are two functions in that file, the store function and the retrieve function.

As you did with the store function, you can create a function to set the values for the variables that you’ve declared. Then, you can call the function after deploying the smart contract to the blockchain. However, this brings us to the question, wouldn’t it be better if there was a function that would be executed automatically when the smart contract is deployed? There is a special function, called __init__, just like in Python!

Create StorageInit.vy and add the following code to it:

# @version ^0.3.0
my_grandma_wallet: address
author: String[100]
fib_list: int16[5]
fib_dynamic_array: DynArray[int128, 5]
struct Permission:
    ...
CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
Hands-On Blockchain for Python Developers
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist download Download options font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon