> For the complete documentation index, see [llms.txt](https://dev-docs.dcentwallet.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dev-docs.dcentwallet.com/in-app-browser/stellar-network.md).

# Stellar network

## Stellar network <a href="#stellar-network" id="stellar-network"></a>

D'CENT wallet supports Stellar dapps through [Stellar Wallets Kit](https://stellarwalletskit.dev/) — the standard way Stellar dapps connect to wallets. D'CENT ships an official **`DcentModule`** for the Kit, so integrating with D'CENT is the same as integrating with any other Kit-supported wallet: register the module, and the rest of your wallet-connection code doesn't need to know it's talking to D'CENT specifically.

* Minimum version: `@creit.tech/stellar-wallets-kit@2.5.0` or later.
* npm : <https://www.npmjs.com/package/@creit.tech/stellar-wallets-kit>

#### Supported Networks <a href="#supported-networks" id="supported-networks"></a>

The following is the D'CENT in-app browser's supported Stellar network list.

| Network          | Network Passphrase                               |
| ---------------- | ------------------------------------------------ |
| PUBLIC (Mainnet) | `Public Global Stellar Network ; September 2015` |
| TESTNET          | `Test SDF Network ; September 2015`              |

**How to Switch the Network**

By clicking the "network" icon on the right top corner of the "discovery" tab, you can switch the blockchain network for the dapp browser.

For more details, please see the D'CENT user guide.

* Switch Network User Guide : <https://userguide.dcentwallet.com/native-service/dapp-browser/switch-blockchain-network>

#### Register the D'CENT module <a href="#register-the-dcent-module" id="register-the-dcent-module"></a>

**Zero-config: `defaultModules()` / `sep43Modules()`**

`DcentModule` is already included in both the Kit's `defaultModules()` and `sep43Modules()` helpers. If your dapp already uses either helper, upgrading the Kit to `v2.5.0`+ is the only change needed — D'CENT will appear in the wallet list automatically.

```javascript
import { StellarWalletsKit, Networks } from '@creit.tech/stellar-wallets-kit';
import { defaultModules } from '@creit.tech/stellar-wallets-kit/modules/utils';

// v2.x uses the static `init` API (v1.x used `new StellarWalletsKit({ ... })`).
// Follow the Stellar Wallets Kit docs for your installed version.
StellarWalletsKit.init({
  network: Networks.PUBLIC,
  modules: defaultModules(), // includes DcentModule automatically (v2.5.0+)
});
```

**Manual module list**

If you build the `modules` array by hand instead of using `defaultModules()`, import `DcentModule` from the `/modules/dcent` subpath and add it alongside the other wallets you support.

```javascript
import { StellarWalletsKit, Networks } from '@creit.tech/stellar-wallets-kit';
import { AlbedoModule } from '@creit.tech/stellar-wallets-kit/modules/albedo';
import { LobstrModule } from '@creit.tech/stellar-wallets-kit/modules/lobstr';
import { xBullModule } from '@creit.tech/stellar-wallets-kit/modules/xbull';
import { DcentModule, DCENT_ID } from '@creit.tech/stellar-wallets-kit/modules/dcent';

StellarWalletsKit.init({
  network: Networks.PUBLIC,
  modules: [
    new DcentModule(), // add the D'CENT module to your init script
    new AlbedoModule(),
    new LobstrModule(),
    new xBullModule(),
  ],
  // selectedWalletId: DCENT_ID, // optional — pre-select D'CENT instead of showing a picker
});
```

**Auto-selection inside D'CENT's in-app browser**

`DcentModule` reports itself as a **platform wrapper** (`isPlatformWrapper()`) whenever the dapp is running inside D'CENT's own mobile in-app browser. The Kit uses this to skip the wallet picker and connect straight to D'CENT, so users don't have to pick a wallet they're already inside of.

#### Connect to Wallet <a href="#connect-to-wallet" id="connect-to-wallet"></a>

The simplest way to connect is the Kit's built-in wallet picker modal. It lists every registered module (including D'CENT), lets the user pick one, requests access, and resolves with the connected address.

```javascript
try {
  const { address } = await StellarWalletsKit.authModal();
  console.log('Connected address:', address);
} catch (error) {
  console.error('Connection failed or the user closed the modal:', error);
}
```

If you're building your own wallet-selection UI instead of using the Kit's modal, drive the same flow manually:

```javascript
// List the registered wallets and whether each one is currently available.
const wallets = await StellarWalletsKit.refreshSupportedWallets();
// wallets: [{ id, name, type, icon, isAvailable, isPlatformWrapper, url }, ...]

StellarWalletsKit.setWallet(DCENT_ID); // e.g. after the user picks "D'CENT Wallet"

const { address } = await StellarWalletsKit.fetchAddress(); // requests access + fetches from the wallet
```

Once connected, `StellarWalletsKit.getAddress()` returns the address from the Kit's memory without re-prompting the wallet.

```javascript
const { address } = await StellarWalletsKit.getAddress();
```

#### Get the current network <a href="#get-the-current-network" id="get-the-current-network"></a>

To get the network the currently selected wallet is on, you can use the following code.

```javascript
const { network, networkPassphrase } = await StellarWalletsKit.getNetwork();
```

#### Sign Transaction <a href="#sign-transaction" id="sign-transaction"></a>

By using `signTransaction`, you can ask the connected wallet to sign a Stellar transaction. The transaction is passed as a base64-encoded XDR string together with the network passphrase and the signer address. The Kit returns the **signed XDR**, and your dapp submits it to the network (Horizon or Soroban RPC).

```javascript
import {
  TransactionBuilder,
  Networks,
  Operation,
  Asset,
  Horizon,
} from '@stellar/stellar-sdk';

const server = new Horizon.Server('https://horizon.stellar.org');
const account = await server.loadAccount(address);

const tx = new TransactionBuilder(account, {
  fee: '100',
  networkPassphrase: Networks.PUBLIC,
})
  .addOperation(
    Operation.payment({
      destination: 'G...DESTINATION',
      asset: Asset.native(),
      amount: '1.5',
    }),
  )
  .setTimeout(180)
  .build();

// Ask the connected wallet (e.g. D'CENT) to sign the transaction.
const { signedTxXdr, signerAddress } = await StellarWalletsKit.signTransaction(
  tx.toXDR(),
  {
    networkPassphrase: Networks.PUBLIC,
    address, // signer address
  },
);

// Submit the signed transaction yourself.
const signedTx = TransactionBuilder.fromXDR(signedTxXdr, Networks.PUBLIC);
const result = await server.submitTransaction(signedTx);
console.log('Transaction hash:', result.hash);
```

**Sign Soroban authorization entries and messages**

For Soroban smart-contract dapps, D'CENT also implements authorization-entry signing and message signing through the same Kit methods.

```javascript
// Sign a Soroban authorization entry (base64 XDR of a HashIdPreimage).
const { signedAuthEntry, signerAddress } = await StellarWalletsKit.signAuthEntry(authEntryXdr, {
  address,
  networkPassphrase: Networks.PUBLIC,
});

// Sign an arbitrary message.
const { signedMessage, signerAddress } = await StellarWalletsKit.signMessage(message, {
  address,
  networkPassphrase: Networks.PUBLIC,
});
```

#### Reference <a href="#reference" id="reference"></a>

* Stellar Wallets Kit : <https://stellarwalletskit.dev/>
* Stellar Wallets Kit D'CENT module PR : <https://github.com/Creit-Tech/Stellar-Wallets-Kit/pull/98>
* @creit.tech/stellar-wallets-kit (npm) : <https://www.npmjs.com/package/@creit.tech/stellar-wallets-kit>
* Stellar SDK (@stellar/stellar-sdk) : <https://www.npmjs.com/package/@stellar/stellar-sdk>
