Browser

You can actually see MultipleChain as mentioned under "structure". In addition, there are classes where you can connect to wallets and send transactions. You can see how to manage this process and connect to wallets in the examples.

We will give examples on the EVM and you will see "EIP6963" here. However, this will not be valid for other networks.

Adapter

Adapter means "the class with which we interact with the wallet". For example, this is "window.ethereum" for MetaMask and "window.phantom" for Phantom. However, some networks like Solana and Tron have their own adapter packages. Therefore, for Ethereum, we prepared the adapters directly with window['wallet name'], while for others we implemented existing adapters.

import { browser } from '@multiplechain/evm-chains'

declare global {
    interface Window {
        ethereum: any;
    }
}

const metamask = browser.adapters.MetaMask

const wallet = new browser.Wallet(metamask)

const ourAdapter = browser.fromEIP6963ProviderDetail({
    info: {
        uuid: '123',
        name: 'MetaMask',
        icon: 'https://metamask.io/icon.png'
    },
    provider: window.ethereum
})

const eip6963Adapter = browser.toEIP6963ProviderDetail(ourAdapter)

const switcher = browser.switcher(ourAdapter.provider ?? window.ethereum)

Wallet

Wallet takes an adapter parameter and manages the connection process between the adapter and the wallet. Adapters provide information about the connection and the wallet. Wallet is the class that manages the actual actions.

import { browser, assets } from '@multiplechain/evm-chains'

const metamask = browser.adapters.MetaMask

const wallet = new browser.Wallet(metamask)

const walletId = wallet.getId()

const walletName = wallet.getName()

const walletIcon = wallet.getIcon()

const walletPlatforms = wallet.getPlatforms()

const walletDownloadLink = wallet.getDownloadLink()

const walletDeepLink = wallet.createDeepLink('https://example.com')

const connectedAddress = await wallet.connect()

const isDetected = await wallet.isDetected()

const isConnected = await wallet.isConnected()

const signedMessage = await wallet.signMessage('Hello, World!')

const coinTransfer = await (new assets.Coin()).transfer('0x', '0x', 0.1)

const transactionId = await wallet.sendTransaction(coinTransfer)

wallet.on('event name', (event) => {
    console.log(event)
})

Last updated