TomoEVMKit provides an API interface for projects based on @web3-onboard to migrate with minimum efforts.
Update Initiate
To initiate the onboard in TomoEVMKit, you need to add the await keyword.
// Old
import Onboard from '@web3-onboard/core'
// New
import { Onboard } from "@tomo-inc/tomo-evm-kit";
// Old
onboard = Onboard({
wallets,
chains,
appMetadata,
…
});
// New
onboard = await Onboard({
wallets,
chains,
clientId: "..", // client id from tomo
projectId: "..", // project id for wallet connect
…
});
You can get clientId from the Tomo dashboard and projectId from the Walletconnect dashboard.
Done!
Different API logics
Due to the different logic of implementation of TomoEVMKit and Blocknative, we do not support all options in onboardnow, below are lists:
InitOptions
✅ Fully Support, ⚠️ Partial Support, ✖️ Not Support,
export interface InitOptions {
/**
* Wallet modules to be initialized and added to wallet selection modal
*/
wallets: WalletInit[]; // ✅
/**
* The chains that your app works with
*/
chains: (Chain | ChainWithDecimalId)[]; // ✅
/**
* Additional metadata about your app to be displayed in the Onboard UI
*/
appMetadata?: AppMetadata; // ✅
/**
* Define custom copy for the 'en' locale or add locales to i18n your app
*/
i18n?: i18nOptions; // ✖️
/**
* Customize the connect modal
*/
connect?: ConnectModalOptions; // ⚠️ only support `autoConnectLastWallet`
/**
* Customize the account center UI
*/
accountCenter?: AccountCenterOptions; // ✖️
/**
* @deprecated apiKey parameter has been deprecated and is no
* longer used within Web3-Onboard to provide notifications
*/
apiKey?: string; // ✖️
/**
* Transaction notification options
*/
notify?: Partial<NotifyOptions> | Partial<Notify>; // ✖️
/** Gas module */
gas?: typeof gas; // ✖️
/** Web3-Onboard module to add Wagmi support
* see https://www.npmjs.com/package/@web3-onboard/wagmi
*/
wagmi?: typeof wagmi; // ✖️
/**
* Object mapping for W3O components with the key being the DOM
* element to mount the component to, this defines the DOM container
* element for svelte to attach the component
*/
containerElements?: Partial<ContainerElements>; // ✖️
/**
* @deprecated Transaction Preview support has ended and Transaction Preview
* is no longer supported as part of Web3-Onboard.
* Please remove from your onboard config to avoid
* console errors and un-expected behavior
*/
transactionPreview?: unknown; // ✖️
/**
* Custom or predefined theme for Web3Onboard
* BuiltInThemes: ['default', 'dark', 'light', 'system']
* or customize with a ThemingMap object.
*/
theme?: Theme; // ✅
/**
* Defaults to False - use to reduce load time
* If set to true the Inter font will not be imported and
* instead the default 'sans-serif' font will be used
* To define the font used see `--w3o-font-family` prop within
* the Theme initialization object or set as css variable
*/
disableFontDownload?: boolean; // ✖️
/**
* Type of unstoppableResolution module
* A small module that can bee added to allow Unstoppable Domain
* address resolution similar to that of ens (Ethereum Name Service)
* ENS resolution will take president if available
*/
unstoppableResolution?: typeof unstoppableResolution; // ✖️
}
onboard = Onboard({
...
connect: {
autoConnectLastWallet: true // need explicitly set to true
}
})
onboard.state.select("wallets").subscribe((wallets) => { // you can subscribe the connection
if (wallets.length > 0) {
console.log("Wallet is connected");
console.log('provider',wallets[0].provider) // only one provider provided.
} else {
console.log("Wallet is disconnected");
}
});