Coin98 Labs
Search…
BinanceSmartChain DApps Integration
Welcome to Coin98 Extension Wallet Developer Guide. This documentation contains guides for developers to get started developing on Coin98 Extension Wallet.‌

To detect Coin98 Extension with BinanceSmartChain

To detect whether your browser is running Coin98 Extension, please use:
1
if(window.coin98 || window.binanceSmartChain || window.binanceSmartChain?.isCoin98){
2
console.log('Coin98 Extension is installed!');
3
}
Copied!
Notice: Coin98 Extension Testnet is under development and not available now. The Coin98 Extension on Ethereum JavaScript provider API is specified by EIP-1193. Supportwindow.ethereum + window.binanceSmartChain and removal window.web3

To connect Coin98 Extension Wallet

To connect Coin98 Extension means to access the user's [blockchain - like Ethereum] account(s).
1
// Connect & get accounts
2
window.binanceSmartChain.request({method: 'bsc_accounts'});
3
// Alias for connection
4
window.binanceSmartChain.request({method: 'bsc_requestAccounts'});
5
//Check if dapp connected
6
window.binanceSmartChain.isConnected();
Copied!
1
// Connect & get accounts
2
window.ethereum.request({method: 'eth_accounts'});
3
// Alias for connection
4
window.ethereum.request({method: 'eth_requestAccounts'});
5
//Check if dapp connected
6
window.ethereum.isConnected();
Copied!

To disconnect Coin98 Extension Wallet

To disconnect Coin98 Extension, please use:
1
window.binanceSmartChain.disconnect()
Copied!
1
window.ethereum.disconnect()
Copied!

To experience functions

Once your account is connected, let's start experiencing more functions.‌

Get Current Account

return Promise<Array[String]>
    If wallet can not be found, return [] instead of throw Error
1
window.binanceSmartChain.request({ method: 'bsc_accounts' }).then(accounts => {
2
if (accounts[0]) {
3
// Do something with accounts
4
} else {
5
// Wallet not found
6
}
7
})
Copied!

Check wallet whether exists or not

return Promise<{data: Boolean}>
1
window.binanceSmartChain.request({ method: 'has_wallet', params: ['binanceSmartChain'] })
2
// Example
3
window.binanceSmartChain.request({ method: 'has_wallet', params: ['binanceSmartChain'] }).then(() => {
4
// Wallet Exists
5
}).catch(e => {
6
// Wallet not found
7
})
Copied!

Sign Transaction

return: Promise<Signature | RPC: 2.0>
1
// Example Sign Transactionconst
2
const signature = window.binanceSmartChain.request({
3
method: 'bsc_signTransaction',
4
params: [
5
"undefined": "string",
6
"to": "string",
7
"gas": "string",
8
"gasPrice": "string",
9
"value": "string",
10
"data": "string",
11
"nonce": "string"
12
]
13
});
Copied!

Transfer

return Promise<hash>
1
window.binanceSmartChain.request({
2
method: 'bsc_sendTransaction',
3
params: [
4
{
5
undefined: 'string',
6
to: 'string',
7
gas: 'string',
8
gasPrice: 'string',
9
value: 'string',
10
data: 'string',
11
nonce: 'string'
12
}
13
]
14
})
Copied!

RPC Request

return Promise<binanceSmartChain RPC> Currently only support HTTP(s) method Reference: RPC Method
1
window.binanceSmartChain.request({method: '<Your Method>', params: [args1,....]})
Copied!

To handle events

List of events

Currently we only support some action event from wallet extension
1
window.binanceSmartChain.on('event_name', callback);
2
//Example
3
window.binanceSmartChain.on('close', () => window.location.reload());
4
window.binanceSmartChain.on('accountsChanged', () => window.location.reload());
Copied!
Events
Trigger
accountsChanged
Receive when active account changed in Extension
networkChanged
Receive when active network changed in Extension
chainChanged
Receive when active chain changed in Extension
disconnect
Receive when disconnect from Extension
close
Alias for disconnect event
Method
Description
on(event, callback)
Add event listener
off(event, callback)
Remove event listener
Last modified 7d ago