Stellar network
How to integrate with D'CENT wallet for dapps on Stellar network.
D'CENT mobile app's in-app browser injects window.freighterApi as a provider for the Stellar network. If your dapp is based on Stellar, you can interact with D'CENT wallet through the window.freighterApi provider, the same interface used by the Freighter wallet.
Unlike EVM networks (which expose a D'CENT-specific window.ethereum), D'CENT implements the Freighter API and the SEP-43 (Standard Web Wallet API Interface) standard for Stellar. This means dapps that are already integrated with Freighter, either directly or through Stellar Wallets Kit, work with D'CENT without code changes.
Supported Networks
The following is the D'CENT in-app browser's supported Stellar network list which can use the window.freighterApi provider.
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
If your dapp is already integrated with Freighter
D'CENT wallet's Stellar provider implements the Freighter API and the SEP-43 standard interface.
Freighter API : https://docs.freighter.app/
@stellar/freighter-api (npm) : https://www.npmjs.com/package/@stellar/freighter-api
SEP-43 Standard Web Wallet API Interface : https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0043.md
Freighter exposes its API through the window.freighterApi object, and the @stellar/freighter-api package reads from that object automatically. D'CENT injects the same object, so if your dapp is already integrated with Freighter, it's very easy to integrate with D'CENT wallet.
For your reference, you can also find Freighter's developer guide in the link below.
Freighter Developer Guide : https://docs.freighter.app/
If your dapp uses Stellar Wallets Kit
Most modern Stellar dapps connect through Stellar Wallets Kit. Because D'CENT exposes the Freighter API (window.freighterApi and the legacy window.freighter), the Kit's Freighter module detects D'CENT through its isConnected() probe and routes signing requests to it. No D'CENT-specific module is required: register the Freighter module in your Kit setup and D'CENT becomes selectable (shown as "Freighter").
When the user selects "Freighter" inside D'CENT's in-app browser, the Kit communicates with D'CENT through the injected Freighter API described below.
How to detect in-app browser
In order to check if your dapp running on Stellar is supported by the dapp browser, you need to check whether window.freighterApi is defined.
How to check D'CENT provider
Several Stellar dapp browsers expose the same window.freighterApi interface. You can check whether the dapp browser is D'CENT wallet's in-app browser with the following code.
D'CENT also exposes a dedicated provider handle, which you can use as an alternative detection point.
Connect to Wallet
You can use the following code in order to connect to a D'CENT wallet account. requestAccess() prompts the user for approval and returns the selected account address.
You can also check the connection and permission state without prompting the user.
Wallet Connection UI
If the connection to the wallet is requested, a connection approval popup appears.
Get the current network
To get the current network and its passphrase, you can use the following code.
For full network details (passphrase, Horizon URL, and Soroban RPC URL), use the following code.
Get the current account's address
To get the address of the current account, you can use the following code.
Sign Transaction
By using signTransaction, you can ask D'CENT 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. D'CENT returns the signed XDR, and your dapp submits it to the network (Horizon or Soroban RPC).
Sign Soroban authorization entries and messages
For Soroban smart-contract dapps, D'CENT also implements authorization-entry signing and message signing.
Reference
Freighter API documentation : https://docs.freighter.app/
@stellar/freighter-api (npm) : https://www.npmjs.com/package/@stellar/freighter-api
SEP-43 Standard Web Wallet API Interface : https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0043.md
Stellar Wallets Kit : https://stellarwalletskit.dev/
Stellar SDK (@stellar/stellar-sdk) : https://www.npmjs.com/package/@stellar/stellar-sdk
Last updated