Very1Fake / rnb-backend-test

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

R'n'B Backend Test

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.

Tech Stack

Language: Python 3.10.5

Web framework: Django 3.2.13

Blockchain library: Web3.py 5.29.2

Usage

Prerequisites

Install poetry to manage virtualenv and dependencies:

pip install poetry

Launch

Local

First setup virtualenv:

poetry install

Then 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 runserver

Docker

To launch docker just enter:

make up_build

To make migrations:

make migrate

Features

  • 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

.ENV file configuration

  • 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)

Endpoints

  • /admin - Django admin panel
  • /swagger - Swagger docs
  • /tokens/create - Create NFT token
  • /tokens/list - List created tokens
  • /tokens/total_supply - NFT contract total supply

About


Languages

Language:Python 94.7%Language:Shell 2.1%Language:Makefile 1.6%Language:Dockerfile 1.6%