This application provides a RESTful API for managing tokens on the Stellar blockchain, built with Node.js, Express, and TypeScript.
Create and issue a new token on the Stellar network.
Endpoint: POST /api/stellar/create-token
Request Body:
{
"tokenCode": "MYTOKEN",
"amount": "1000",
"destinationAccount": "GABCD..."
}Response:
{
"success": true,
"message": "Successfully issued 1000 MYTOKEN to GABCD...",
"transactionHash": "abc123...",
"tokenDetails": {
"code": "MYTOKEN",
"issuer": "GXYZ...",
"asset": "MYTOKEN:GXYZ...",
"amount_issued": "1000",
"distributed_to": "GABCD..."
}
}Check the balance of a specific token for an account.
Endpoint: GET /api/stellar/balance?account=GABCD...&asset=MYTOKEN:GXYZ...
Response:
{
"account": "GABCD...",
"balances": [
{
"asset_type": "credit_alphanum4",
"asset_code": "MYTOKEN",
"asset_issuer": "GXYZ...",
"balance": "1000.0000000"
}
]
}API endpoints require authentication using a Stellar secret key stored in environment variables.
Create a .env file in the project root with the following variables:
STELLAR_SECRET_KEY=your_secret_key_here
STELLAR_NETWORK=TESTNET # or PUBLIC for mainnet
PORT=3000
NODE_ENV=development
Errors follow this format:
{
"success": false,
"error": "Error message",
"details": "Additional error details (if available)"
}-
Install dependencies:
npm install
-
Start development server:
npm run dev
-
Run tests:
npm test
-
Build the application:
npm run build
-
Start the server:
npm start
[Specify your license here]