QtumSnap connector is used to install snap and exposes methods for calling snap on dApps and other applications.
npm install @lukachi/qtum-wallet-snap-connector
yarn add @lukachi/qtum-wallet-snap-connector
import { QtumWallet } from '@lukachi/qtum-wallet-snap-connector'
export const qtumSnap = new QtumWallet()
import { qtumSnap } from '@/path/to/qtumSnap'
const init = async () => {
await qtumSnap.enable()
}
import { isMetamaskInstalled } from '@lukachi/qtum-wallet-snap-connector'
import { qtumSnap } from '@/path/to/qtumSnap'
const checkSnapStatus = async () => {
return {
isMetamaskInstalled: await isMetamaskInstalled(),
isSnapInstalled: await qtumSnap.isInstalled(),
}
}
import { ethers } from 'ethers';
const provider = new ethers.providers.Web3Provider(connector);
import { providers } from 'ethers'
import { useMemo } from 'react'
import { qtumSnap } from '@/path/to/qtumSnap'
export const useProvider = () => {
const provider = useMemo(() => {
try {
return new providers.Web3Provider(qtumSnap as providers.ExternalProvider)
} catch (error) {
return undefined
}
}, [])
const signer = useMemo(() => {
return provider?.getSigner()
}, [provider])
return {
provider,
signer,
}
}