Phoenix Wallet

Assets

Defining and managing different types of value in Phoenix Wallet

Assets represent the types of value that can be stored in wallets. An asset could be a real currency (USD, EUR), a virtual currency, loyalty points, or any other unit of value your application needs to track.

Asset Structure

FieldTypeDescription
codestringUnique identifier (e.g., USD, POINTS)
tenant_idstringParent tenant identifier
namestringHuman-readable name
scaleintegerNumber of decimal places (0-18)
statusenumACTIVE or INACTIVE
metadataobjectCustom key-value pairs
created_attimestampCreation timestamp

Asset Codes

Asset codes are unique identifiers within a tenant. We recommend following these conventions:

TypeConventionExamples
ISO CurrenciesISO 4217 codesUSD, EUR, GBP, JPY
CryptoCommon symbolsBTC, ETH, USDC
Points/RewardsDescriptive uppercasePOINTS, REWARDS, CREDITS
CustomApp-specificGOLD_COINS, GEMS, XP

Asset codes are case-sensitive and must be unique within a tenant. Once created, an asset code cannot be changed.

Decimal Scale

The scale field defines how many decimal places the asset supports. All amounts are stored as integers, and the scale determines their interpretation:

AssetScaleStored ValueActual Value
USD215099$150.99
JPY01509915,099
BTC81000000001.00000000 BTC
POINTS0500500 points
GOLD412345612.3456 gold

Choose your scale carefully. Once an asset is created and has transactions, changing the scale would require migrating all historical data. We recommend:

  • Scale 2 for most fiat currencies
  • Scale 0 for points and whole-number systems
  • Scale 8 for crypto assets

Creating an Asset

curl -X POST https://api.phoenixwallet.io/v1/assets \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "code": "POINTS",
    "name": "Loyalty Points",
    "scale": 0,
    "metadata": {
      "conversion_rate": "100_points_per_dollar",
      "category": "loyalty"
    }
  }'

Response:

{
  "code": "POINTS",
  "tenant_id": "ten_01HV8X9Y2KPQRS3T4UV5WX6YZ7",
  "name": "Loyalty Points",
  "scale": 0,
  "status": "ACTIVE",
  "metadata": {
    "conversion_rate": "100_points_per_dollar",
    "category": "loyalty"
  },
  "created_at": "2024-01-15T10:30:00Z"
}

Common Asset Configurations

Fiat Currency (USD)

{
  "code": "USD",
  "name": "US Dollar",
  "scale": 2,
  "metadata": {
    "symbol": "$",
    "type": "fiat"
  }
}

Loyalty Points

{
  "code": "POINTS",
  "name": "Reward Points",
  "scale": 0,
  "metadata": {
    "earn_rate": "1_per_dollar",
    "redemption_rate": "100_points_per_dollar"
  }
}

In-Game Currency

{
  "code": "GEMS",
  "name": "Game Gems",
  "scale": 0,
  "metadata": {
    "type": "premium_currency",
    "purchasable": true
  }
}

Promotional Credits

{
  "code": "PROMO_USD",
  "name": "Promotional Credits",
  "scale": 2,
  "metadata": {
    "type": "promotional",
    "restrictions": "non_withdrawable"
  }
}

Asset Operations

List Assets

curl https://api.phoenixwallet.io/v1/assets \
  -H "Authorization: Bearer $API_KEY"

Get Asset Details

curl https://api.phoenixwallet.io/v1/assets/POINTS \
  -H "Authorization: Bearer $API_KEY"

Deactivate an Asset

Deactivating an asset prevents new lots from being created with it, but existing balances remain accessible:

curl -X POST https://api.phoenixwallet.io/v1/assets/POINTS/deactivate \
  -H "Authorization: Bearer $API_KEY"

Multi-Asset Wallets

A single wallet can hold multiple assets simultaneously. Each asset's balance is tracked independently:

{
  "wallet_id": "wal_01HV8X9Y2KPQRS3T4UV5WX6YZ7",
  "balances": [
    {
      "asset_code": "USD",
      "available": "15000",
      "scale": 2
    },
    {
      "asset_code": "POINTS",
      "available": "2500",
      "scale": 0
    },
    {
      "asset_code": "PROMO_USD",
      "available": "1000",
      "scale": 2
    }
  ]
}
  • Wallets - Containers that hold asset balances
  • Lots - How assets are organized into balance tranches
  • Policies - Rules that can be applied per asset