# CypherD - Backend ## Prerequisites - Understand Nestjs - a typescript based Backend MVC Framework [Module](https://docs.nestjs.com/modules) , [Controllers](https://docs.nestjs.com/controllers) , [Providers](https://docs.nestjs.com/providers) , [Validations](https://docs.nestjs.com/techniques/validation) - Understand [local-db](https://lenn.gitbook.io/db-local/) - A simple alternative to database with simple JSON. - Understand REST Architecture, HTTP Verbs and Response Codes ### Points to Consider: - API endpoints must follow REST Architectural Patterns and Guidelines (https://www.codecademy.com/article/what-is-rest ) - Variable Names , Function Names, Class Names should be Meaningful. ## Problem Statement: Create a RESTful API ### 1. An Endpoint to Get the aggregate token balances of an address in the following chains: Ethereum, Fantom, and Polygon. - [ ] Integrate with CovalentHq - https://api.covalenthq.com/v1/1/address/0x52114fb7396dbe19096ffa343d18830f5d77b6c6/balances_v2/?key=<your_api_key> Sample Input: ``` 0x52114fb7396dbe19096ffa343d18830f5d77b6c6 ``` Sample Output : ``` { address: "0x52114fb7396dbe19096ffa343d18830f5d77b6c6", balances: { eth: [ { name: '', symbol:'', decimals:'', contractAddress:'', contractDeicmals:'', logo:'', balance: xx, balanceInUSD: xx, } ], polygon:[], fantom:[], }, totalBalanceInUSD: XXX } ``` ### 2. Watchlist Management Feature #### 2.1 An Endpoint to Get Master Coin list - Coingecko Integration - [ ] Integrate with following API to generate the master list of tokens https://api.coingecko.com/api/v3/coins/list - [ ] `id` field in the response should be used in upcoming APIs to track these coins through the watchlist Sample Output: ``` { coins: [ { "id": "matic-network", "symbol": "matic", "name": "Polygon" }, ] } ``` #### 2.2 An Endpoint to Create Watchlist with a name Validation : name should be alphanumeric with minimum of 5 characters and maximum of 20 Sample Input : ``` { name: "vitalikWatchlist" } ``` Sample Output : ``` { id: "24cf68e1-3ef1-403b-9851-44a90cb32816", name: "vitalikWatchlist", tokens: [] } ``` #### 2.3 Add tokens to Watchlist Validation : - `tokensToBeAdded` list should be validated with Coingecko List with the `id` field. - should ignore duplicates Sample Input : ``` { tokensToBeAdded: [ "matic-network"] } ``` Sample Output: ``` { id: "24cf68e1-3ef1-403b-9851-44a90cb32816", name: "vitalikWatchlist", tokens: ["matic-network"] } ``` #### 2.4 Delete tokens from Watchlist Sample Input ``` { tokensToBeDeleted: ["matic-network""] } ``` Sample Output ``` { id: "24cf68e1-3ef1-403b-9851-44a90cb32816", name: "vitalikWatchlist", tokens: [] } ``` #### 2.5 An Endpoint to Get Watchlist by its id Sample Output ``` { id: "24cf68e1-3ef1-403b-9851-44a90cb32816", name: "vitalikWatchlist", tokens: ["matic-network", "gravity-finance"] } ``` #### 2.6 An Endpoint to Delete Watchlist by its id ### References : https://www.coingecko.com/en/api/documentation https://www.covalenthq.com/platform/#/auth/register/ - For Api key generation https://www.covalenthq.com/docs/api - CovalentHQ Docs https://www.codecademy.com/article/what-is-rest | chain | id | |--|--| | ethereum | 1 | | polygon | 137 | | fantom | 250 |