Solana DApps Intergration

Welcome to Coin98 Extension Wallet Developer Guide. This documentation contains guides for developers to get started developing multiple chains on Coin98 Extension Wallet.

Detecting Coin98 Extension Browser

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

if (typeof window.coin98 !== 'undefined') {
console.log(‘Coin98 Extension is installed!');
}

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

Connecting to Coin98 Extension Wallet

Connecting to Coin98 Extension means to access the user's [blockchain - like Solana] account(s).

const connectObject={
name:"Luna Dex",
logo:"https://coin98.s3-ap-southeast-1.amazonaws.com/lunaIcon.png"
}
const account = await window.coin98.connect(connectObject)
/* This would return a list of current connected accounts and their status
Example {
address,
isActive,
name
}
*/
// If your account is connected and session remains connected you can check by
const isConnected = await window.coin98.isConnected()
if (isConnected) {
// Call get() to get current connected account
window.coin98.get()
}

Disconnecting Coin98 Extension Wallet

To disconnect Coin98 Extension, please use:

window.coin98.disconnect()

Experience functions

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

Get current account

window.coin98.get()

Switch active account

window.coin98.activeWallet(address)

Place order

const exampleOrder={
address: "CNHAHgZUrC7xDtiLq6hpjLwdgGiYqZAVyQLdVD2WigjH", // Owner address
price: 1.5, // Price you want to buy or sell
size: 100, // Amount you want to buy or sell
fromSize: 150, // Amount based on your size (Ex: 1.5 * 100 / USDC Price)
side: "buy", //"buy" or "sell"
selectedPair: {
address: "CDdR97S8y96v3To93aKvi3nCnjUrbuVSuumw8FLvbVeg", // Address of Serum Market (SRM/USDC)
programId: "EUqojwWA2rd19FZrzeBncJsm38Jm1hEhE3zsmX3bRc2o", // Program ID of Serum Market (SRM/USDC)
pairCoin:{
walletAddress: "3FGr6QtuQxdpu4F2bNKfhp77SMh8BwkgCZoR8jGWnjLT", //SOL or SPL wallet address
address: "SRMuApVNdxXokk5GT7XD5cUUgXMBCoAz2LHeuAoKWRt", //Token contract address
symbol: "SRM"
}
baseCoin:{
walletAddress: "KNGtr4y3ZHBx1xqYvYfnBokNBJV2CD7GTeqM8xJos8C", //SOL or SPL wallet address
address: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", //Token contract address
symbol: "USDC"
}
}
}
window.coin98.trade(exampleOrder)

Settle account

window.coin98.settle({
selectedPair:{
address,
programId
}
})

Cancel order

const exampleCancelOrder ={
id: orderId,
side: "buy" or "sell",
selectedPair:{
address,
programId
}
}
window.coin98.cancelOrder(exampleCancelOrder)

Create a new wallet

const exampleCreateToken = {
token: token address,
image: token image,
symbol: token symbol
}
window.coin98.createTokenWallet(exampleCreateToken)

Send coins

const exampleSendObject = {
symbol: token symbol,
address: token address
}
window.coin98.send(exampleSendObject)

Handling events

List of events

Below is the list of events to detect and react when your account connected to Coin98 Extension.

  • CONNECT_CONFIRMED: Received when account connected to Coin98 Extension

  • WALLET_NOT_FOUND: Received when no wallet created

  • SEND_CONFIRMED: Received a hash when send coin completed

  • TRADE_CONFIRMED: Received a hash when trade completed

  • SETTLE_CONFIRMED: Received a hash when settle account completed

  • TOKEN_CREATE_CONFIRMED: Received a hash when token created

  • UPDATE_WALLET: Received when new wallet created or updatedCANCEL_ORDER_CONFIRMED: Received a hash when cancel order successfully

More ways to deal with events

// Listening any event you want
window.coin98.on('CONNECT_CONFIRMED', (event)=>{
console.log('Event message', event)
})
// Off any event you want
window.coin98.off('CONNECT_CONFIRMED')