Secret Network 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 Secret Network Base Chain

To detect whether your browser is running Coin98 Extension, please use:
1
if (window.coin98) {
2
console.log('Coin98 Extension is installed!');
3
}
Copied!

Notice: Coin98 Extension Testnet is under development and not available now.

To connect Coin98 Extension Wallet

To connect Coin98 Extension means to access the user's [blockchain - like Secret Network] account(s).
1
// Connect only
2
const connection = window.coin98.cosmos('<chain: String>');
3
// Connect & get accounts
4
connection.request({ method: 'cosmos_accounts' });
5
// Check whether dapp connected or not
6
connection.isConnected();
Copied!
Currently chains support: ['terra','secret']

To disconnect Coin98 Extension Wallet

To disconnect Coin98 Extension, please use:
1
connection.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
connection.request({ method: 'cosmos_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
const hasWallet = connection.request({ method: 'has_wallet', params: ['<chain>'] });
Copied!

Execute contract function

return: Promise<Hash>
1
const signature = connection.request({
2
method: 'cosmos_execute',
3
params: ['<contractAddres: string>', '<executeMsg: string>'],
4
});
5
6
// Example Execute Contract
7
let cw20Contract =
8
'juno10rktvmllvgctcmhl5vv8kl3mdksukyqf2tdveh8drpn0sppugwwqjzz30z';
9
let execMsg =
10
'{"transfer":{"amount":"1","recipient":"juno1cx4nq77x3unvl2xsa9fmm9drxkexzkjnzwt2y7"}}';
11
12
const response = await connection.request({
13
method: 'cosmos_execute',
14
params: [cw20Contract, execMsg],
15
});
Copied!

To handle events

List of events

Currently we only support some action event from wallet extension
1
connection.on('event_name', callback);
2
//Example
3
connection.on('close', () => window.location.reload());
4
connection.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