Stellar network
Stellar network
DCENT wallet supports Stellar dapps through Stellar Wallets Kit — the standard way Stellar dapps connect to wallets. DCENT ships an official DcentModule for the Kit, so integrating with DCENT 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 DCENT specifically.
- Minimum version:
@creit.tech/stellar-wallets-kit@2.5.0or later. - npm : https://www.npmjs.com/package/@creit.tech/stellar-wallets-kit
Supported Networks
The following is the DCENT 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 DCENT user guide.
- Switch Network User Guide : https://support.dcentwallet.com/getting-started
Register the DCENT module
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 — DCENT will appear in the wallet list automatically.
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.
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 DCENT module to your init script
new AlbedoModule(),
new LobstrModule(),
new xBullModule(),
],
// selectedWalletId: DCENT_ID, // optional — pre-select DCENT instead of showing a picker
});
Auto-selection inside DCENT's in-app browser
DcentModule reports itself as a platform wrapper (isPlatformWrapper()) whenever the dapp is running inside DCENT's own mobile in-app browser. The Kit uses this to skip the wallet picker and connect straight to DCENT, so users don't have to pick a wallet they're already inside of.
Connect to Wallet
The simplest way to connect is the Kit's built-in wallet picker modal. It lists every registered module (including DCENT), lets the user pick one, requests access, and resolves with the connected address.
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:
// 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 "DCENT 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.
const { address } = await StellarWalletsKit.getAddress();
Get the current network
To get the network the currently selected wallet is on, you can use the following code.
const { network, networkPassphrase } = await StellarWalletsKit.getNetwork();
Sign Transaction
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).
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. DCENT) 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, DCENT also implements authorization-entry signing and message signing through the same Kit methods.
// 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
- Stellar Wallets Kit : https://stellarwalletskit.dev/
- Stellar Wallets Kit DCENT 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