# Registering a Currency

Money2 ships with a list of [Common Currencies](/common-currencies.md) however there are times when you may want to add additional currencies (e.g. digital currencies) or change the defaults for an existing Common Currency.

### Common Currencies

Common Currencies are pre-loaded into the currency Registry in Money2.  You can not modify a Common Currency but you can replace it's entry in the Money2 registry.

This means that when parsing a string containing an isoCode or using Currencies().find the modified Currency will be returned.

### Register a Currency

When creating custom Currencies you have two choices, register the currency , with the benefit that you can access it like any other currency, or create and manage the currency in your own code.

Both methods are useful at different times so use the one that best suits your use case.

```dart
import 'package:money2/money2.dart';
import 'package:test/test.dart';

void main() {
 test('register currency', () {
      /// Create currency and replace the CommonCurrency with our
      /// own one.
      final usd = Currency.create('USD', 2);
      Currencies().register(usd);

      /// Change the registered euro currency to have 4 decimal places
      /// Note: CommonCurrencies can't be changed but the registry can.
      final euro = CommonCurrencies().euro.copyWith(decimalDigits: 4);
      Currencies().register(euro);
      final euro4 = Currencies().parse('EUR1500.0');
      expect(euro4.decimalDigits, equals(4));

      /// register a new currency with 8 decimals.
      final doge =
          Currency.create('DODG', 8, symbol: 'Ð', pattern: 'S0.00000000');
      Currencies().register(doge);

      // find a registered currency.
      final nowUseIt = Currencies().find('DODG');
      expect(nowUseIt, isNotNull);
      if (nowUseIt != null) {
        final cost = Money.fromIntWithCurrency(1000000000, nowUseIt);
        expect(cost.toString(), equals('Ð10.00000000'));
      }
    });
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://money2.onepub.dev/registering-a-currency.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
