The Python backend uses FastAPI to drive compilation, deployment, and interaction with Solidity smart contracts.
This page provides a deeper look into the internal structure of the FastAPI backend.
This diagram shows how main.py, the config loader, FastAPI’s startup event, routers, contract services, and web3_connector.py integrate.
The “Contract Services” layer represents several modules working together:
deploy_contract.py– compilation & deploymentinbox_contract.py– contract interaction helperscontract_store.py– ABI/bytecode & metadata managementweb3_connector.py– RPC connection & Web3 helpers
Together, they handle all contract-related behaviour between the FastAPI routes and the Web3 RPC provider.
Keeping this logic in one layer means the API stays clean and the Web3 code stays contained, and also makes it easier to extend later (new contract types, DB integration, etc.).
Before building and running the backend, make sure you have followed the Setup Instructions to create the necessary configuration files and environment variables.
Navigate to the python-backend directory and build the Docker image using the following command:
cd /path/to/wildweb3/python-backend
docker build -t wildweb3-python-backend .Run the Docker container with the data directory mounted to ensure the config.toml file is available:
docker run -v /path/to/wildweb3/data:/app/data -p 8040:8040 wildweb3-python-backendReplace /path/to/wildweb3 with the actual path to your project root.
You can also run the backend directly from the command line by specifying the path to the configuration file using the --config argument:
cd python_backend
python main.py --config /path/to/wildweb3/data/config.tomlReplace /path/to/wildweb3 with the actual path to your project root.
This allows you to run the backend with different configuration files depending on the environment (e.g., Docker or local development).
To run the Python tests from the project root, use the following command:
PYTHONPATH=. python -m unittest discover -s testsThis command sets the PYTHONPATH environment variable to the project root and runs all the unit tests in the tests directory.
To lint the code using pylint from the project root, use the following command:
pylint python_backend testsThis command runs pylint on the python_backend directory and the tests directory, checking for coding standard violations and potential errors.
