# Currency

> Currency formatting on both sides and authoritative balance operations on the server.

## Formatting — client and server

<table>
<thead>
  <tr>
    <th>
      Export
    </th>
    
    <th>
      Returns
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        FormatCurrency(value, formatter)
      </code>
    </td>
    
    <td>
      Formatted string using the named formatter
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        GetCurrencyFormatter(formatter)
      </code>
    </td>
    
    <td>
      Formatter configuration table
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        GetCurrencyNuiConfig()
      </code>
    </td>
    
    <td>
      NUI-safe configuration: <code>
        defaultFormatter
      </code>
      
      , <code>
        defaultCurrency
      </code>
      
      , <code>
        formatters
      </code>
      
      , <code>
        currencies
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        GetDefaultCurrency()
      </code>
    </td>
    
    <td>
      Default currency name
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        FormatCurrencyAmount(value, currency, symbol?)
      </code>
    </td>
    
    <td>
      Formatted string using the currency's formatter; optional display-symbol override
    </td>
  </tr>
</tbody>
</table>

```lua
local currency = exports["sky_base"]:GetDefaultCurrency()
local label = exports["sky_base"]:FormatCurrencyAmount(1250, currency)
```

Formatting changes the display only. It does not transfer money or select a society account.

## Player balances — server only

<table>
<thead>
  <tr>
    <th>
      Export
    </th>
    
    <th>
      Returns
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        GetCurrencyBalance(source, currency)
      </code>
    </td>
    
    <td>
      Numeric balance
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        HasCurrency(source, currency, amount)
      </code>
    </td>
    
    <td>
      Boolean
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        AddCurrency(source, currency, amount)
      </code>
    </td>
    
    <td>
      Boolean success
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        RemoveCurrency(source, currency, amount)
      </code>
    </td>
    
    <td>
      Boolean success
    </td>
  </tr>
</tbody>
</table>

`source` is the player's server ID. `currency` identifies a configured currency. Your server integration must authorize the operation and determine the amount itself.

```lua [server.lua]
local currency = exports["sky_base"]:GetDefaultCurrency()
local paid = exports["sky_base"]:RemoveCurrency(playerId, currency, 100)
if not paid then
    print("Payment was not completed")
end
```

Use the configured currency for your server. For shared job accounts use [Jobs Base society money](/docs/base/jobs-base/server-exports/society-money); for invoices use [Sky Billing](/docs/base/jobs-base/server-exports/billing).
