Now let's build a decentralized GUI application. Name the script twitter_dapp.py. Refer to the code file in the following GitLab link for the full code: https://gitlab.com/arjunaskykok/hands-on-blockchain-for-python-developers/blob/master/chapter_07/dapp/twitter_dapp.py:
from PySide2 import QtCore, QtWidgets
import web3
from web3 import Web3, HTTPProvider
from populus.utils.wait import wait_for_transaction_receipt
w3 = Web3(HTTPProvider('http://localhost:7545'))
...
...
if __name__ == '__main__':
import sys
app = QtWidgets.QApplication(sys.argv)
twitter_dapp = TwitterDapp()
twitter_dapp.show()
sys.exit(app.exec_())
Let's dissect this script line by line. Here, we import the necessary classes and set our web3 object to Ganache, which serves the smart contract in port 7545 of...