### Production Setup with Tracing Mode Source: https://github.com/safe-global/safe-transaction-service/blob/main/README.md Instructions for setting up the Safe Transaction Service in production mode with tracing enabled. This involves copying a sample environment file, configuring essential parameters like secret keys and Ethereum node URLs, building Docker images, and starting the service. ```bash cp .env.tracing.sample .env # Configure .env with: # DJANGO_SECRET_KEY # ETHEREUM_NODE_URL # ETHEREUM_TRACING_NODE_URL # Optional: ETH_INTERNAL_NO_FILTER=1 docker-compose build --force-rm docker-compose up ``` -------------------------------- ### Docker Installation and Configuration Source: https://github.com/safe-global/safe-transaction-service/blob/main/docker_instructions.txt Commands to add the 'docker' group, add the current user to the 'docker' group, and restart the Docker daemon. Ensure you log out and back in for changes to take effect. ```bash sudo groupadd docker sudo gpasswd -a ${USER} docker sudo service docker restart ``` -------------------------------- ### Development Setup with Virtual Environment Source: https://github.com/safe-global/safe-transaction-service/blob/main/README.md Instructions for setting up the Safe Transaction Service development environment using a Python virtual environment. This includes creating the environment, installing dependencies, and setting up pre-commit hooks. ```bash python -m venv venv source venv/bin/activate pip install -r requirements-dev.txt pre-commit install -f cp .env.dev .env ./run_tests.sh ``` -------------------------------- ### Development Setup with Docker Source: https://github.com/safe-global/safe-transaction-service/blob/main/README.md Instructions for setting up the Safe Transaction Service development environment using Docker Compose. This simplifies the setup process by managing dependencies and services through Docker. ```bash docker-compose --profile develop up ``` -------------------------------- ### Troubleshooting gRPC Installation on Apple Silicon Source: https://github.com/safe-global/safe-transaction-service/blob/main/README.md Provides a solution for installing the `grpc` dependency on Apple Silicon systems by setting specific environment variables before installation. ```bash export GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=1 export GRPC_PYTHON_BUILD_SYSTEM_ZLIB=1 pip install grpc ``` -------------------------------- ### Dockerfile for Nginx Webserver Source: https://github.com/safe-global/safe-transaction-service/blob/main/docs/docker_ec2.rst A Dockerfile to set up an Nginx webserver container. It starts from an Ubuntu base image, updates packages, and installs Nginx. It is configured to forward logs to a Docker log collector. ```dockerfile FROM ubuntu:14.04 ENV REFRESHED_AT 2015-02-11 # get the nginx package and set it up RUN ["apt-get", "update"] RUN ["apt-get", "-y", "install", "nginx"] # forward request and error logs to docker log collector ``` -------------------------------- ### Production Setup for L2 Event Indexing Source: https://github.com/safe-global/safe-transaction-service/blob/main/README.md Configuration steps for deploying the Safe Transaction Service in a production environment, specifically for L2 networks utilizing event indexing. This involves copying a sample environment file, configuring node URLs and secret keys, and building/running Docker containers. ```bash cp .env.l2.sample .env # Edit .env file to add ETHEREUM_NODE_URL and DJANGO_SECRET_KEY docker-compose build --force-rm docker-compose up ``` -------------------------------- ### Safe Transaction Service Docker Compose Commands Source: https://github.com/safe-global/safe-transaction-service/blob/main/docker_instructions.txt Commands to build the Docker images and run the Safe Transaction Service using docker-compose. Also includes how to run a container in bash mode. ```bash sudo docker-compose build sudo docker-compose up sudo docker-compose run web bash ``` -------------------------------- ### Testing Service Setup Source: https://github.com/safe-global/safe-transaction-service/blob/main/README.md A command to test if the Safe Transaction Service is running correctly by making a request to the '/api/v1/about/' endpoint. ```curl curl 'http://localhost:8000/api/v1/about/' ``` -------------------------------- ### Running an OpenEthereum Node for Göerli Source: https://github.com/safe-global/safe-transaction-service/blob/main/README.md Command to start an OpenEthereum node configured for the Göerli testnet with tracing enabled. This is a prerequisite for certain configurations of the Safe Transaction Service. ```bash openethereum --chain goerli --tracing on --db-path=/media/ethereum/openethereum --unsafe-expose ``` -------------------------------- ### Dockerfile for Web Application Source: https://github.com/safe-global/safe-transaction-service/blob/main/docs/docker_ec2.rst A Dockerfile to build a container for a Python web application. It sets up an Ubuntu base image, installs necessary packages including Python 3 and build essentials, configures user permissions, and installs project dependencies from requirements.txt. ```dockerfile FROM ubuntu:14.04 ENV REFRESHED_AT 2015-01-13 # update packages and prepare to build software RUN ["apt-get", "update"] RUN ["apt-get", "-y", "install", "build-essential", "vim", "git", "curl"] RUN ["locale-gen", "en_GB.UTF-8"] # install latest python RUN ["apt-get", "-y", "build-dep", "python3-dev", "python3-imaging"] RUN ["apt-get", "-y", "install", "python3-dev", "python3-imaging", "python3-pip"] # prepare postgreSQL support RUN ["apt-get", "-y", "build-dep", "python3-psycopg2"] # move into our working directory # ADD must be after chown see http://stackoverflow.com/a/26145444/1281947 RUN ["groupadd", "python"] RUN ["useradd", "python", "-s", "/bin/bash", "-m", "-g", "python", "-G", "python"] ENV HOME /home/python WORKDIR /home/python RUN ["chown", "-R", "python:python", "/home/python"] ADD ./ /home/python # manage requirements ENV REQUIREMENTS_REFRESHED_AT 2015-02-25 RUN ["pip3", "install", "-r", "requirements.txt"] # uncomment the line below to use container as a non-root user USER python:python ``` -------------------------------- ### Docker Compose Configuration Source: https://github.com/safe-global/safe-transaction-service/blob/main/docs/docker_ec2.rst An example docker-compose.yml file for setting up development environments. It defines services for database, webapp, and webserver, including build contexts, commands, volumes, and links between services. ```yaml database: build: database webapp: build: webapp: command: /usr/bin/python3.6 manage.py runserver 0.0.0.0:8000 # dev setting # command: gunicorn -b 0.0.0.0:8000 wsgi:application # production setting volumes: - webapp/your_project_name:/path/to/container/workdir/ links: - database webserver: build: webserver ports: - "80:80" - "443:443" links: - webapp ``` -------------------------------- ### Configuring Docker for Host OpenEthereum Node Source: https://github.com/safe-global/safe-transaction-service/blob/main/README.md Updates to the '.env' file to point the Dockerized Safe Transaction Service to a locally running OpenEthereum node. ```bash ETHEREUM_NODE_URL=http://172.17.0.1:8545 ETHEREUM_TRACING_NODE_URL=http://172.17.0.1:8545 ``` -------------------------------- ### Setting Environment Variables for E2E Tests Source: https://github.com/safe-global/safe-transaction-service/blob/main/README.md How to set necessary environment variables for running end-to-end tests, including Ethereum node URLs for mainnet and 4337 bundler. ```bash export ETHEREUM_MAINNET_NODE="https://erigon-node-mainnet.dev/" export ETHEREUM_4337_BUNDLER_URL="https://eth-sepolia.g.alchemy.com/v2/$API_KEY" ./run_tests.sh ``` -------------------------------- ### Docker Compose Build and Run Commands Source: https://github.com/safe-global/safe-transaction-service/blob/main/docs/docker_ec2.rst Commands to build and run the webserver container using Docker Compose. This assumes a `production.yml` file is present. ```bash sudo docker-compose -f production.yml build webserver sudo docker-compose -f production.yml up ``` -------------------------------- ### Project Dependencies Source: https://github.com/safe-global/safe-transaction-service/blob/main/requirements-test.txt Lists the Python packages and their versions required for the Safe Transaction Service project. ```text coverage==7.10.2 django-stubs==5.1.3 django-test-migrations==1.4.0 factory-boy==3.3.3 faker==37.5.3 mypy==1.17.0 pytest==8.4.1 pytest-celery==1.2.0 pytest-django==4.11.1 pytest-env==1.1.5 pytest-rerunfailures==15.1 pytest-sugar==1.0.0 ``` -------------------------------- ### Creating a Superuser for Admin Interface Source: https://github.com/safe-global/safe-transaction-service/blob/main/README.md Command to create a superuser account for accessing the Django administration interface of the Safe Transaction Service. ```bash docker exec -it safe-transaction-service-web-1 python manage.py createsuperuser ``` -------------------------------- ### Project Dependencies Source: https://github.com/safe-global/safe-transaction-service/blob/main/requirements-dev.txt Lists the Python package dependencies required for the Safe Transaction Service project, including production and testing requirements. ```python requirements.txt requirements-test.txt ``` -------------------------------- ### Loading Default Safe Contracts Metadata Source: https://github.com/safe-global/safe-transaction-service/blob/main/README.md Environment variable or command to load default Safe contract information, such as descriptions and logos, into the service. ```bash ENABLE_SAFE_SETUP_CONTRACTS=1 # or python manage.py setup_safe_contracts --force-update-contracts ``` -------------------------------- ### Dockerfile for Safe Transaction Service Source: https://github.com/safe-global/safe-transaction-service/blob/main/docs/docker_ec2.rst This Dockerfile sets up the Nginx web server for the Safe Transaction Service. It configures logging, volumes, exposes ports, and sets up Nginx site configurations. ```dockerfile RUN ln -sf /dev/stdout /var/log/nginx/access.log RUN ln -sf /dev/stderr /var/log/nginx/error.log VOLUME ["/var/cache/nginx"] EXPOSE 80 443 # load nginx conf ADD ./site.conf /etc/nginx/sites-available/your_cookiecutter_project RUN ["ln", "-s", "/etc/nginx/sites-available/your_cookiecutter_project", "/etc/nginx/sites-enabled/your_cookiecutter_project"] RUN ["rm", "-rf", "/etc/nginx/sites-available/default"] #start the server CMD ["nginx", "-g", "daemon off;"] ``` -------------------------------- ### Interaction Methods for Safe Transaction Service Source: https://github.com/safe-global/safe-transaction-service/blob/main/README.md Lists the primary ways to interact with the Safe Transaction Service: Safe{Core} API Kit, safe-eth-py, and Safe CLI. The Safe CLI offers a 'tx-service' mode for offchain signature gathering. ```APIDOC Interaction Methods: - Safe{Core} API Kit: https://github.com/safe-global/safe-core-sdk/tree/main/packages/api-kit - Safe-eth-py: https://github.com/safe-global/safe-eth-py - Safe CLI: - Usage: `tx-service` mode for offchain signatures. - Repository: https://github.com/safe-global/safe-cli ``` -------------------------------- ### Development Tools Source: https://github.com/safe-global/safe-transaction-service/blob/main/requirements-dev.txt Specifies the development tools and linters used for maintaining code quality and consistency in the Safe Transaction Service project. ```shell flake8 ipdb ipython isort pre-commit pylint pylint-django ``` -------------------------------- ### Reorganization Handling in Safe Transaction Service Source: https://github.com/safe-global/safe-transaction-service/blob/main/README.md Explains how the service handles blockchain reorganizations by marking blocks as 'not confirmed' and re-indexing if a block hash changes before reaching the desired confirmation depth. The `ETH_REORG_BLOCKS` environment variable configures the confirmation depth. ```python ETH_REORG_BLOCKS = 10 # Example configuration for reorg depth ``` -------------------------------- ### Chain Support Requirements for Safe Transaction Service Source: https://github.com/safe-global/safe-transaction-service/blob/main/README.md Details that adding a chain to the service requires dedicated infrastructure and a proper RPC endpoint, as outlined in the Safe{Core} documentation. ```APIDOC Chain Support: - Requires dedicated infrastructure. - Requires a proper RPC endpoint. - See: https://docs.safe.global/api-supported-networks - See: https://docs.safe.global/safe-core-api/rpc-requirements ``` -------------------------------- ### Checking and Fixing Indexing Problems Source: https://github.com/safe-global/safe-transaction-service/blob/main/README.md Python management commands for diagnosing and resolving indexing issues within the Safe Transaction Service. These commands help ensure transaction and transfer data consistency between the database and the blockchain. ```python python manage.py check_index_problems python manage.py reindex_master_copies --from-block-number X --addresses 0x111 0x222 python manage.py reindex_erc20 --from-block-number X --addresses 0x111 0x222 ``` -------------------------------- ### Nginx Configuration for Proxying Source: https://github.com/safe-global/safe-transaction-service/blob/main/docs/docker_ec2.rst A basic Nginx configuration file (`site.conf`) that forwards traffic to a backend application server (e.g., webapp_1 on port 8000). This is used within the Dockerfile. ```nginx # see http://serverfault.com/questions/577370/how-can-i-use-environment-variables-in-nginx-conf#comment730384_577370 upstream localhost { server webapp_1:8000; } server { location / { proxy_pass http://localhost; } } ``` -------------------------------- ### Python Project Dependencies Source: https://github.com/safe-global/safe-transaction-service/blob/main/requirements.txt This snippet lists the core Python dependencies for the Safe Transaction Service project, including web3, Django, and related libraries. These packages are essential for the service's functionality, handling blockchain interactions, web framework features, and asynchronous task management. ```python asgiref==3.7.2 boto3==1.39.3 cachetools==5.5.2 celery==5.5.3 django==5.0.13 django-cache-memoize==0.2.1 django-celery-beat==2.8.1 django-cors-headers==4.7.0 django-db-geventpool==4.0.8 django-debug-toolbar django-debug-toolbar-force django-environ==0.12.0 django-extensions==4.1 django-filter==25.1 django-imagekit==5.0.0 django-model-utils==5.0.0 django-redis==5.4.0 django-s3-storage==0.15.0 django-timezone-field==7.1 dj ``` -------------------------------- ### ERC20 Token Indexing Requirements Source: https://github.com/safe-global/safe-transaction-service/blob/main/README.md States that for an ERC20 token to be indexed by the service, it must implement `name()`, `symbol()`, `decimals()`, and `balanceOf()`. Tokens failing these checks are ignored and added to the `TokenNotValid` model. ```APIDOC ERC20 Token Indexing: - Requirements: Must implement `name()`, `symbol()`, `decimals()`, and `balanceOf()`. - Consequences of failure: Ignored by the service and added to the `TokenNotValid` model. ``` -------------------------------- ### Django Database Settings Source: https://github.com/safe-global/safe-transaction-service/blob/main/docs/docker_ec2.rst Configuration for Django's database settings, specifying a PostgreSQL connection. This snippet is intended to be used within a Django project's settings file. ```python DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': 'postgres', 'USER': 'postgres', 'HOST': 'database', 'PORT': 5432, } } ``` -------------------------------- ### Swagger UI Customization Source: https://github.com/safe-global/safe-transaction-service/blob/main/safe_transaction_service/templates/drf-yasg/swagger-ui.html Customizes the appearance of the Swagger UI, including the favicon, top bar background color, download button style, input field border, and logo replacement. ```html {% extends "drf-yasg/swagger-ui.html" %} {% load static %} {% block favicon %} {% endblock %} {% block main\_styles %} .swagger-ui .topbar {background-color: black;} .swagger-ui .topbar .download-url-wrapper .download-url-button {background-color: #008c73;} .swagger-ui .topbar .download-url-wrapper input\[type=text\] {border: 2px solid #008c73;} .topbar-wrapper img\[alt="Swagger UI"\], .topbar-wrapper span { visibility: collapse; } .topbar-wrapper .link:before { content: url("{% static 'safe/logo.png' %}"); } {% endblock %} ``` -------------------------------- ### SafeContract Model 'banned' Field Explanation Source: https://github.com/safe-global/safe-transaction-service/blob/main/README.md Explains that the 'banned' field in the SafeContract model is used to exclude Safes with unsupported MasterCopies or unverified proxies causing indexing issues. Banned Safes are not removed, and indexing can resume once issues are resolved. ```APIDOC SafeContract Model: - 'banned' field: Prevents indexing of Safes with unsupported MasterCopy or problematic unverified proxies. - Functionality: Does not remove Safes; allows resuming indexing after issue resolution. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.