keep-starknet-strange / vault

Empower Your Assets, Redefine Control.
https://vlt.finance
MIT License
18 stars 16 forks source link

Implement /get_balance Endpoint #32

Closed LucasLvy closed 1 month ago

LucasLvy commented 3 months ago

Description

We need to implement the /get_balance endpoint in the Vault backend. This endpoint is responsible for retrieving the current USD balance of an account.

Details

Request Parameters:

Response:

{
    "balance": "0x1234567890abcdef"
}

Notes:

The balance is returned as a hexadecimal string representing the USD balance of the account.

Example

// Import necessary modules
import fastify from 'fastify';

// Create Fastify instance
const app = fastify({ logger: true });

// Define the get_balance endpoint
app.get('/get_balance', async (request, reply) => {
    try {
        const { address } = request.query;

        // Retrieve balance logic goes here

        // Return balance response
        return { balance: '0x1234567890abcdef' };
    } catch (error) {
        // Handle errors
        console.error('Error retrieving balance:', error);
        return reply.status(500).send({ error: 'Internal Server Error' });
    }
});

// Start the server
app.listen(3000, '0.0.0.0', (err, address) => {
    if (err) throw err;
    console.log(`Server listening on ${address}`);
});

Tasks:

EjembiEmmanuel commented 2 months ago

@LucasLvy can I work on this?

Dprof-in-tech commented 2 months ago

hi @LucasLvy Please Assign this to me