EVM compatible networks
How to integrate with D'CENT wallet for dapps on EVM compatible networks.
D'CENT mobile app's in-app browser injects window.ethereum as a provider. If your dapp is based on EVM compatible network, you can interact with D'CENT wallet through window.ethereum provider.

Supported Networks

The following is the D'CENT in-app browser's supported network list which can use window.ethereum provider. Additional networks (https://chainid.network/) will be added to this list in the future.
Chain ID
Network
1
Ethereum Mainnet
3
Ethereum Testnet Ropsten
4
Ethereum Testnet Rinkeby
5
Ethereum Testnet Goerli
42
Ethereum Testnet Kovan
56
Binance Smart Chain Mainnet
97
Binance Smart Chain Testnet
137
Polygon (previously Matic) Mainnet
80001
Polygon Testnet Mumbai
30
RSK Mainnet
31
RSK Testnet
16
Flare Testnet Coston
19
Songbird Mainnet
128
HECO Chain Mainnet
100
Gnosis Chain (prev. xDai Chain) Mainnet
250
Fantom Mainnet Opera
50
XinFin Network Mainnet
42220
Celo Mainnet
321
KCC Mainnet

How to Switch the Network

By clicking the "network" icon on the right top corner of "discovery" tab, you can switch the blockchain network for dapp browser.
For more details, please see D'CENT user guide.

If your dapp is already integrated with MetaMask

D'CENT wallet's provider uses EIP-1193 & EIP-1102 interface.
MetaMask also uses the same provider interface (not exactly the same, but almost the same). This means if your dapp is already integrated with MetaMask, it's very easy to integrate with D'CENT wallet.
For your reference, you can also find the MetaMask's developer guide in the link below.

How to detect in-app browser

In order to check if your dapp running on EVM networks is supported by the dapp-browser, you need to check whether window.ethereum is defined.
1
if (typeof window.ethereum !== 'undefined') {
2
console.log("It's in-app browser");
3
}
Copied!

How to check D'CENT provider

Most of dapp browsers for EVM networks use the same interface window.ethereum. You can check whether the dapp browser is D'CENT wallet's in-app browser with the following code.
1
if (window.ethereum.isDcentWallet === true) {
2
console.log("It's D'CENT wallet's in-app browser")
3
}
Copied!

Connect to Wallet

You can use the following code in order to connect to D'CENT wallet's account.
1
ethereum.request({ method: 'eth_requestAccounts' })
Copied!
You can also use the old style code.
1
ethereum.enable()
Copied!

Wallet Connection UI

If the connection to wallet is requested, you can see the popup like below.

Get the current network

To get the current network ID, you can use the following code.
1
ethereum.request({ method: 'net_version' })
Copied!
You can also use the old style code.
1
ethereum.networkVersion
Copied!

Get the current account's address

To get the address of the current account, you can use the following code.
1
ethereum.request({ method: 'eth_accounts' })
Copied!

Send Transaction

By using ethereum.request method to call eth_sendTransaction, you can send the transaction. The following is the example code to show how to send the transaction.
1
const transactionParameters = {
2
nonce: '0x00', // ignored
3
gasPrice: '0x9184e72a000', // customizable by user
4
gas: '0x76c0', // customizable by user
5
to: '0x0000000000000000000000000000000000000000',
6
from: '0xb60e8dd61c5d32be8058bb8eb970870f07233154', // current account's address
7
value: '0x9184e72a',
8
data: '0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675',
9
};
10
11
const txHash = await ethereum.request({
12
method: 'eth_sendTransaction',
13
params: [transactionParameters],
14
});
Copied!