- ZoneTribeWallet Backend
ZoneTribeWallet is a secure, scalable, and containerized RESTful API for managing cryptocurrency wallets and transactions. It supports wallet creation, funding, transaction history (with search and export), and blockchain integration (Ethereum Sepolia testnet). The backend is built with ASP.NET Core, Entity Framework Core, and Nethereum, and is ready for deployment via Docker.
Key Components:
- ASP.NET Core Web API: Main backend service.
- Entity Framework Core: ORM for SQL Server.
- Nethereum: Blockchain integration (Ethereum Sepolia).
- JWT Authentication: Secure user authentication.
- Docker: Containerization for backend and frontend.
- Background Service: Listens for blockchain events and updates the database.
High-Level Diagram:
[Frontend (React)] <--REST--> [Backend API (ASP.NET Core)]
|
v
[SQL Server Database]
|
v
[Ethereum Sepolia Testnet]
- .NET 8 SDK
- Docker
- SQL Server (local or Docker)
- (Optional) Node.js for frontend
- Clone the repository
git clone <your-repo-url> cd zone-tribe-wallet-backend/ZoneTribeWallet.API
- Configure the database connection
- Edit
appsettings.Development.jsonorappsettings.jsonwith your SQL Server connection string
- Apply Migrations
dotnet ef database update
- Run the backend
The API will be available at
dotnet run
http://localhost:5063/api.
- Build and run the Docker Compose
This will build the backend and frontend images and start the containers.
docker compose up --build
- Backend: http//localhost:8080/
- Frontend: http//localhost:3000/
Authentication
POST /api/auth/register: Register a new userPOST /api/auth/login: Authenticate a user and return a JWT token
Wallets
POST /api/Wallet/create: Create a new walletGET /api/Wallet/gets-wallets: Get all wallets for the authenticated user
Transactions
POST /api/Transaction/send-fund: Send funds from one wallet to anotherGET /api/Wallet/transactions/{walletAddress}: Get paginated transaction history for a wallet. Query parameters: -pageNumber: Page number for pagination (default: 1) -pageSize: Number of items per page (default: 20) -searchTerm: Search term to filter transactions by Transaction ID, date and Amount (optional)GET /api/Wallet/transactions/{walletAddress}/all: Get all transactions for export functionality
See test.http for ready-to-us HTTP requests to test the API endpoints.
| Column | Type | Description |
|---|---|---|
| Id | Guid | Primary key |
| UserId | string | Owner (ASP.NET Identity) |
| Address | string | Ethereum wallet address |
| PrivateKey | string | Encrypted private key |
| Balance | decimal | Wallet balance |
| Network | string | Blockchain network |
| Currency | string | Currency (e.g., ETH) |
| WalletName | string | User-defined name |
| CreatedAt | DateTime | Creation timestamp |
| Column | Type | Description |
|---|---|---|
| TransactionId | Guid | Primary key |
| WalletAddress | string | Associated wallet address |
| DateTime | DateTime | Transaction timestamp |
| Amount | decimal | Transaction amount |
| TransactionType | string | 'credit' or 'debit' |
| Status | string | 'successful', or 'failed' |
| BlockchainTransactionHash | string | Blockchain transaction hash |
- Uses Nethereum to interact with the Ethereum Sepolia testnet.
- All successful transactions are logged on-chain and in the SQL database.
- Private keys are encrypted before storage.
- Background service (
WalletEventListenerService) listens for new blocks and updates the database with received funds.
docker compose up --build- The backend runs on port
8080(seecompose.yaml). - The frontend (if present) runs on port
3000.
- Multi-stage build for efficient image size.
- Uses
mcr.microsoft.com/dotnet/aspnet:8.0-alpinefor runtime.
- Register a new user via
/api/auth/register. - Login via
/api/auth/loginto receive a JWT token.
- Use
/api/Wallet/createwith your user ID and desired wallet name. - The system generates an Ethereum wallet and stores the encrypted private key.
- Use
/api/Wallet/send-fundto send funds from your wallet to another Ethereum address. - Transactions are logged in both the database and the blockchain.
- Use
/api/Wallet/transactions/{walletAddress}for paginated results. - Use
/api/Wallet/transactions/{walletAddress}/allto export all transactions (CSV/PDF).
- Add
searchTermas a query parameter to filter by date, amount, or transaction ID.
- Use the
/allendpoint to fetch all transactions for export.
- Real-Time Updates: Enable SignalR for live transaction notifications.
- Additional Blockchains: Add support for other networks by extending the blockchain service.
- Role-Based Access: Use ASP.NET Identity roles for admin/user separation.
- DbContext concurrency errors: Ensure each async operation uses its own scoped DbContext.
- Blockchain errors: Check your Infura or Ethereum node credentials and network status.
- Docker issues: Ensure ports are not in use and environment variables are set correctly.
This project is licensed under the MIT License.
For questions or support, please contact the project maintainer.