DEV Community

ilija
ilija

Posted on • Updated on

Web3 backend and smart contract development for Python developers: Musical NFTs part 1

In following set of posts I will be focused on Python based web3 backend development. This subject by itself is quite immense. It is Python web2 backend plus peculiarities of web3 world. This will include smart contract writing, testing and deployment to Polygon test-net Mumbai or similar with Brownie (later on
with Ape). Ones we have this in place we will move to DjangoREST backend and full integration with Google cloud platform services like Firestore (NoSQL database), Firebase storage and Google authentication. Also on the way we will integrate our web3 app with IPFS (via Pinata) for NFT metadata, Stripe (for potential NFT credit card buyers) and few other services. Finally ones all this is done we will deploy our app to Google App engine from where our APIs will be available.

Also we will have few alternative implementations of this project: full-stack Django with PostgreSQL. Then Django REST with React and Postgres. And finally Django REST, React and Google cloud services'.

What we will build?

We will make interface that can be used by client and through them provide interaction with smart contracts and normal backend functionalities like sign-up, login etc. Smart contracts will be coded in Solidity and main idea behind will be idea of musical NFTs. User can go and buy one or more NFT songs (ERC721) with credit card or with crypto and see some information about ownership in dashboard.

But first things first: diving equipment!

Let's talk shortly about equipment we plan to use for this deep dive and environment in which we will build. I'm working on Ubuntu 20.04.6 over Windows WSL and Im using Python 3.8.10. Then we will need to PIP install few packages and to create Python virtual environment. I'm using venv but you are free to use what ever you find most suitable for you. Then we will build our APIs with Django REST framework version 3.14.0 and develop smart contracts with Brownie. Backend interaction with deployed smart contract will be done through web3.py. For testing Pytest + few SDKs to manage our relation to Google cloud services and Stripe. As you can see our tech stack is quite conventional. Maybe in context when we work over Google cloud with NoSql database and Google authentication Django REST can be seen as overkill (because we don't use his ORM layer at all in first phase of project). And maybe from this point of view is logical to opt for some more light Python framework like FastAPI. But we will stick to Django because at certain point we will develop also this alternative versions of our app that use SQL database and have Django native authentication mechanism in place. For version control we will use Git and then project code will be available over Github.

Top comments (0)