Solana 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 Browser

To detect whether your browser is running Coin98 Extension, please use:

if (window.ethereum.isCoin98 || window.coin98) {
console.log('Coin98 Extension is installed!');
}

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 Solana] account(s).

// Connect & get accounts
window.coin98.sol.request({method: 'sol_accounts'});
// Alias for connection
window.coin98.sol.request({method: 'sol_requestAccounts'});
//Check if dapp connected
window.coin98.sol.isConnected();

To disconnect Coin98 Extension Wallet

To disconnect Coin98 Extension, please use:

window.coin98.sol.disconnect()

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

window.coin98.sol.request({
method: 'sol_accounts'
}).then(accounts => {
if(accounts[0]){
//Do something with accounts
}
else{
//Wallet not found
}
});

Check Wallet whether Exists or Not

return Promise<{data: Boolean}>

// Example
window.coin98.sol.request({method: 'has_wallet', params: ['sol']})
.then(() => {
// Wallet Exists
})
.catch(e => {
// Wallet not found
});

Sign Transaction

return: Promise<Object({publicKey, signature:bs58})>

// Example Sign Transaction
const transaction = SystemProgram.transfer({ ... });
window.coin98.sol.request({
method: 'sol_sign',
params: [transaction]
}).then(response=> {
// Example
const { publicKey, signature } = response;
// Do something here
});

Sign Message

Promise<Object>: { publicKey, signature }

window.coin98.sol.request({
method: 'sol_sign',
params: [String]})
.then(({publicKey, signature}) => {
// Do something with signature
});

Verify Signature Message

Promise<String | Boolean>

window.coin98.sol.request({
method: 'sol_verify',
params: [Signature: String, Msg: String | Nullable]
}).then(result => {
// Result = If Msg is provided: true/ false
// Result = If Msg is nulled: Decode signature to original msg
})

Transfer

return Promise<hash>

window.coin98.sol.request({
method: 'transfer',
params: [{
to: <Address>,
amount: <Number>
}]
});

RPC Request

return Promise<SolanaRPC>

Currently only support HTTP method

Reference: Solana RPC Method

window.coin98.sol.request({method: '<Your Method>', params: [args1,....]})

Example: using getBalance method

window.coin98.sol.request({
method: 'getBalance',
params: ['<ADDRESS>']
})

To handle events

List of events

Currently we only support some action event from wallet extension

window.coin98.sol.on('event_name', callback);
//Example
window.coin98.sol.on('close', () => window.location.reload());
window.coin98.sol.on('accountsChanged', () => window.location.reload());

Events

Trigger

accountsChanged

Receive when active account 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