This is a Tron Wallet Service built with Bun and Elysia, providing functionality for creating and managing Tron wallets, as well as handling deposits and withdrawals. test mnemonic in .env.example has some tron on nile testnet for testing purposes
- Bun installed on your system
-
Clone the repository:
git clone https://github.com/yourusername/tron-wallet-service.git cd tron-wallet-service
-
Install dependencies:
bun install
-
Create a
.env
file in the root directory and add your environment variables:PORT=3000 FULL_NODE=https://nile.trongrid.io MNEMONIC="pottery sorry maple plunge video jar post time diagram clip fiber coil"
To start the service, run:
bun run index.ts
The server will start running on http://localhost:3000
(or the port specified in your .env
file).
To deploy this service, you can use a platform that supports Bun applications, such as Railway or Fly.io. Here are general steps for deployment:
- Set up an account on your chosen platform.
- Install the platform's CLI tool if required.
- Configure your project for deployment (this may involve creating a
Procfile
or similar configuration file). - Deploy your application using the platform's deployment commands.
For example, using Railway:
- Install the Railway CLI:
npm i -g @railway/cli
- Login to your Railway account:
railway login
- Initialize your project:
railway init
- Deploy your project:
railway up
Always refer to the specific platform's documentation for the most up-to-date deployment instructions.
- URL:
/create-wallet
- Method:
POST
- Body:
{ "index": number }
- Response:
{ "address": string, "privateKey": string }
- URL:
/parent-wallet
- Method:
GET
- Response:
{ "address": string }
- URL:
/deposit/trx
- Method:
POST
- Body:
{ "to": string, "amount": number }
- Response:
{ "success": boolean, "transaction": object }
- URL:
/withdraw/trx
- Method:
POST
- Body:
{ "to": string, "amount": number, "fromIndex": number }
- Response:
{ "success": boolean, "transaction": object }
- URL:
/balance/:address
- Method:
GET
- Response:
{ "trx": string }
- Ensure that your private keys and mnemonics are securely stored and never exposed.
- Implement proper authentication and authorization mechanisms before deploying this service in a production environment.
- Use HTTPS in production to encrypt data in transit.
- Regularly update dependencies to patch any security vulnerabilities.