The Tomo Connect SDK Lite aims to define an easy-to-integrate and highly compatible Blockchain Provider API for dApps. This API allows dApps to easily connect to all kinds of wallets (including extension wallets, hardware wallets, and mobile wallets), retrieve account asset data, and sign messages and transactions (especially Babylon staking related transactions).
Integration
First, you need to add Tomo Connect SDK in to your project dependency:
Using the above code in your dApp, you can easily open Tomo BTC connect modal and interact with the supported BTC wallet.
Using the Provider API
Once you connect the wallet, you can use the following way to interact with the connect wallet:
import { useTomoProviders, useTomoModalControl, useTomoWalletConnect, useTomoWalletState} from'@tomo-inc/wallet-connect-sdk'// Open BTC connect modalconsttomoModal=useTomoModalControl();tomoModal.open("connect");// Check wallet connection statusconsttomowalletState=useTomoWalletState();constconnected=tomowalletState.isConnected;// Get providerconstproviders=useTomoProviders();constprovider=providers.bitcoinProvider;// DisconnectconsttomoWalletConnect=useTomoWalletConnect();tomoWalletConnect.disconnect();
All the provider APIs are as follows:
exporttypeFees= {// fee for inclusion in the next block fastestFee:number// fee for inclusion in a block in 30 mins halfHourFee:number// fee for inclusion in a block in 1 hour hourFee:number// economy fee: inclusion not guaranteed economyFee:number// minimum fee: the minimum fee of the network minimumFee:number}// UTXO is a structure defining attributes for a UTXOexportinterfaceUTXO {// hash of transaction that holds the UTXO txid:string// index of the output in the transaction vout:number// amount of satoshis the UTXO holds value:number// the script that the UTXO contains scriptPubKey:string}// supported networksexportenumNetwork { MAINNET ='mainnet', TESTNET ='testnet', SIGNET ='signet'}exportabstractclassWalletProvider {abstractconnectWallet():Promise<this>abstractgetWalletProviderName():Promise<string>abstractgetAddress():Promise<string>abstractgetPublicKeyHex():Promise<string>abstractsignPsbt(psbtHex:string):Promise<string>abstractsignPsbts(psbtsHexes:string[]):Promise<string[]>abstractgetNetwork():Promise<Network>abstractsignMessageBIP322(message:string):Promise<string>abstracton(eventName:string,callBack: () =>void):voidabstractoff(eventName:string,callBack: () =>void):voidabstractswitchNetwork(network:Network):Promise<void>abstractsendBitcoin(to:string, satAmount:number):Promise<string>abstractgetNetworkFees():Promise<Fees>abstractpushTx(txHex:string):Promise<string>abstractgetUtxos(address:string, amount?:number):Promise<UTXO[]>abstractgetBTCTipHeight():Promise<number>abstractgetBalance():Promise<number>}
Wallet Customization
Currently Tomo Connect SDK supports the following BTC wallet:
OKX Bitcoin
Unisat
Tomo Bitcoin
OneKey Bitcoin
Bitget Bitcoin
Keystone Bitcoin
If you want to support your own Bitcoin wallet into the wallet list, there are two ways: