This project is a Crypto Payment System API built with FastAPI and Etherscan API. It allows creates wallets for users to make transactions to, submit transactions, and monitor transaction statuses. It only supports Ethereum at the moment. The project uses uv for fast and reliable Python package management.
- User registration and authentication
- Wallet creation and management
- Transaction submission and monitoring
- Rate limiting to prevent abuse
- CORS support for frontend integration
- Python 3.12+
- PostgreSQL
- Redis
- Docker (for containerized deployment)
- uv (Python package manager)
Create a .env file in the project root with the following variables:
DATABASE_URL=postgresql+asyncpg://user:password@db/crypto_payments
MNEMONIC=your_mnemonic_seed_phrase
CELERY_BROKER_URL=redis://redis:6379/0
CELERY_RESULT_BACKEND=redis://redis:6379/0
ETHERSCAN_API_KEY=your_etherscan_api_key
To run the project using Docker, use the following commands:
docker compose up --buildThis will start the PostgreSQL, Redis, FastAPI, and Celery services. The application runs as a non-root user for security, and uses uv for fast Python package management.
- Install uv (if not already installed):
curl -LsSf https://astral.sh/uv/install.sh | sh- Install dependencies using uv:
uv sync- To generate or update
requirements.txt(for Docker builds):
uv pip freeze > requirements.txtThen, add ; sys_platform == 'win32' after the pywin32 line in requirements.txt if it exists.
so, it goes from something like
pywin32==310
to
pywin32==310 ; sys_platform == 'win32'
- Run the FastAPI application:
uv run uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload- Start the Celery worker and beat:
uv run celery -A app.celery_app.celery worker --loglevel=info
uv run celery -A app.celery_app.celery beat --loglevel=infoPOST /users/: Register a new userPOST /auth/login: Login and obtain a tokenPOST /payments/initiate: Initiate a new walletPOST /payments/submit: Submit a transactionGET /payments/transactions/{transaction_id}: Get transaction statusGET /payments/my-wallets: Get all wallets for the current user
To run the tests, use the following command:
pytestContributions are welcome! Please open an issue or submit a pull request.
This project is licensed under the MIT License.