A simple Django backend service that interacts with an ERC-721 standard contract on the Ethereum blockchain (Rinkeby testnet) and allows users to interact with it via a REST API.
Language: Python 3.10.5
Web framework: Django 3.2.13
Blockchain library: Web3.py 5.29.2
Install poetry to manage virtualenv and dependencies:
pip install poetryFirst setup virtualenv:
poetry installThen apply migration (if you haven't done this yet):
poetry run python manage.py migrate And now you can run the server:
poetry run python manage.py runserverTo launch docker just enter:
make up_buildTo make migrations:
make migrate- Docker Image
- Image Building
- Compose
- SQLite Database (Models)
- Swagger (drf-yasg)
- Views
- /tokens/create
- /tokens/list
- Pagination
- /tokens/total_supply
- Configuration (.env)
- Integration with web3
- DJANGO_PORT - Port that django will use (docker only)
- DOCKER_EXPOSE_PORT - External port (docker only)
- INFURA_PROJECT_ID - Infura project id. Used by Web3.py to make RPC calls
- SERVER_ETH_ADDRESS - Ethereum address that will be used by server to sign transactions
- PRIVATE_KEY - Private key for server
- CONTRACT_ADDRESS - Ethereum address of target smart contract
- GAS_TOKEN_CREATE - The amount of gas for token minting (default:
400000)
/admin- Django admin panel/swagger- Swagger docs/tokens/create- Create NFT token/tokens/list- List created tokens/tokens/total_supply- NFT contract total supply