Skip to content

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/1

Get Wallet Balance

Retrieves wallet balance and token information.

Endpoint

http
GET /api/wallet/{wallet}/balance

Parameters

  • 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/balance

Get Wallet Tokens

Retrieves all tokens associated with the wallet.

Endpoint

http
GET /api/wallet/{wallet}/tokens

Parameters

  • 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/tokens

Wallet Model Details

Fields

  • id (integer): Unique wallet identifier
  • name (string): Wallet display name
  • address (string): Wallet public address
  • description (string): Wallet description
  • is_mainnet (boolean): Whether wallet is on mainnet or testnet
  • created_at (datetime): Wallet creation timestamp
  • updated_at (datetime): Last update timestamp

Hidden Fields (for security)

  • private_key: Encrypted private key
  • mnemonic: Encrypted mnemonic phrase
  • user_id: Associated user ID
  • network_id: Associated network ID

Relationships

  • user(): Belongs to User model
  • network(): Belongs to Network model
  • walletTokens(): Has many WalletToken models
  • transactions(): Has many WalletTransaction models
  • charges(): Has many Charge models
  • webhooks(): 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

Released under the MIT License.