Data types

Let's create a more complex smart contract and name it donation.vy, as follows. You can refer to the followng GitLab link for the full code: https://gitlab.com/arjunaskykok/hands-on-blockchain-for-python-developers/blob/master/chapter_03/donation.vy:

struct DonaturDetail:    sum: uint256(wei)    name: bytes[100]    time: timestampdonatur_details: public(map(address, DonaturDetail))......@publicdef withdraw_donation():    assert msg.sender == self.donatee    send(self.donatee, self.balance)

Compile and deploy the smart contract as before. Don’t forget to remove all of your files in the build/contracts directory and restart your Ganache if you reuse the project directory.

Take a look at the following lines:

struct DonaturDetail: sum: uint256(wei) ...

Get Hands-On Blockchain for Python Developers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.