Wallet Management API
Get Wallet Details
Retrieves comprehensive wallet information including tokens and network details.
Endpoint
http
GET /api/wallet/{wallet}Parameters
wallet(integer): Wallet ID
Response
json
{
"status": "success",
"message": "Wallet details fetched successfully",
"data": {
"id": 1,
"name": "My Wallet",
"address": "0x0b88b41fdc5b2127c4082145fc34828b7d20a301",
"description": "Main wallet for trading",
"is_mainnet": true,
"created_at": "2024-01-01 00:00:00",
"updated_at": "2024-01-01 00:00:00",
"wallet_tokens": [
{
"id": 1,
"name": "Ethereum",
"symbol": "ETH",
"decimals": 18,
"is_native": true,
"is_active": true,
"is_testnet": false,
"contract": "0x0000000000000000000000000000000000000000"
}
],
"network": {
"id": 1,
"name": "Ethereum Mainnet",
"rpc_url": "https://mainnet.infura.io/v3/...",
"chain_id": 1,
"currency_symbol": "ETH",
"block_explorer": "https://etherscan.io"
}
}
}Security Note
private_key and mnemonic are hidden from API responses for security reasons.
Example Request
bash
curl -H "Authorization: Bearer {token}" \
https://zafira-app.vratts.com/api/wallet/1Get Wallet Balance
Retrieves wallet balance and token information.
Endpoint
http
GET /api/wallet/{wallet}/balanceParameters
wallet(integer): Wallet ID
Response
json
{
"status": "success",
"message": "Wallet balance fetched successfully",
"data": {
"balance": "1.23456789",
"tokens": [
{
"id": 1,
"name": "Ethereum",
"symbol": "ETH",
"decimals": 18,
"is_native": true,
"is_active": true,
"is_testnet": false,
"contract": "0x0000000000000000000000000000000000000000",
"balance": "1.23456789"
}
]
}
}Example Request
bash
curl -H "Authorization: Bearer {token}" \
https://zafira-app.vratts.com/api/wallet/1/balanceGet Wallet Tokens
Retrieves all tokens associated with the wallet.
Endpoint
http
GET /api/wallet/{wallet}/tokensParameters
wallet(integer): Wallet ID
Response
json
{
"status": "success",
"message": "Wallet tokens fetched successfully",
"data": [
{
"id": 1,
"name": "Ethereum",
"symbol": "ETH",
"decimals": 18,
"is_native": true,
"is_active": true,
"is_testnet": false,
"contract": "0x0000000000000000000000000000000000000000",
"created_at": "2024-01-01 00:00:00",
"updated_at": "2024-01-01 00:00:00"
},
{
"id": 2,
"name": "USD Coin",
"symbol": "USDC",
"decimals": 6,
"is_native": false,
"is_active": true,
"is_testnet": false,
"contract": "0xA0b86a33E6441e8a9D0e2a1F7b8C9D0E1F2A3B4C5",
"created_at": "2024-01-01 00:00:00",
"updated_at": "2024-01-01 00:00:00"
}
]
}Example Request
bash
curl -H "Authorization: Bearer {token}" \
https://zafira-app.vratts.com/api/wallet/1/tokensWallet Model Details
Fields
id(integer): Unique wallet identifiername(string): Wallet display nameaddress(string): Wallet public addressdescription(string): Wallet descriptionis_mainnet(boolean): Whether wallet is on mainnet or testnetcreated_at(datetime): Wallet creation timestampupdated_at(datetime): Last update timestamp
Hidden Fields (for security)
private_key: Encrypted private keymnemonic: Encrypted mnemonic phraseuser_id: Associated user IDnetwork_id: Associated network ID
Relationships
user(): Belongs to User modelnetwork(): Belongs to Network modelwalletTokens(): Has many WalletToken modelstransactions(): Has many WalletTransaction modelscharges(): Has many Charge modelswebhooks(): Has many Webhook models
Error Handling
Common Errors
Wallet Not Found (404)
json
{
"status": "error",
"message": "Wallet not found",
"data": null
}Unauthorized Access (401)
json
{
"status": "error",
"message": "Unauthenticated",
"data": null
}Invalid Token (401)
json
{
"status": "error",
"message": "Invalid token",
"data": null
}Middleware
AccessWallet Middleware
The AccessWallet middleware validates wallet access by:
- Extracting the wallet ID from the route parameter
- Verifying the wallet exists in the database
- Injecting the wallet model into the request object
- Returning a 404 error if the wallet is not found
This middleware is applied to all wallet-related endpoints to ensure proper access control and data validation.
Next Steps
- Token Management - Manage wallet tokens
- Transaction Management - Handle transactions
- Charge Management - Create payment charges