Closed
Description
📌 Issue: Implement Blockchain Controller to Expose API Endpoints
🔹 Description
Expose RESTful API endpoints for blockchain interactions, allowing external services to fetch NFT balances, metadata, and execute token transfers via the ERC-1155 contract on StarkNet Testnet.
📂 Project Structure
- Controller:
src/modules/blockchain/controllers/blockchain.controller.ts
- Service:
src/modules/blockchain/services/starknet.service.ts
- DTOs:
src/modules/blockchain/dtos/transfer.dto.ts
🛠️ Tasks
- Create
blockchain.controller.ts
to handle HTTP requests. - Implement the following API endpoints:
- GET
/blockchain/balance/:account/:tokenId
→ Returns the balance of a specific token for a given account. - GET
/blockchain/token/:tokenId
→ Returns metadata for a specific token. - POST
/blockchain/transfer
→ Transfers a token between two accounts.
- GET
- Ensure request validation using DTOs.
- Implement error handling for invalid requests.
- Integrate the controller with
StarknetService
. - Write unit tests to validate:
- Correct responses for balance and metadata retrieval.
- Successful transfers via API.
- Handling of invalid input parameters.
- Generate API documentation using Swagger/OpenAPI.
✅ Acceptance Criteria
- The API should correctly expose blockchain-related functionalities.
- Swagger documentation must be available for all endpoints.
- API must handle errors gracefully and provide meaningful responses.
- Unit tests must pass before merging.