useMetamask<>

NameTypeReturns
useMetamask<>(CallBack | undefined) function UseMatamaskAPI

CallBack<>(Metamask)

When calling useMetamask hook you can provide a function that expects the Metamask object as param.
You can for example add a listener to chainChanged event and then location.reload.

function HookCleaner
Metamask Metamask

HookCleaner

React like Cleaner function in where you can as an example destroy listeners attached to metamask.

function void | function

useTokenPrice<>

NameTypeReturns
useTokenPrice<>(string) function [number, ReFetchFn]

ReFetchFn<>

Hook resolves with an Array of 2 elements.
Index 1 of the Array is a function which trigger a fetch to the coinGecko API

function void

Parse

Parse is a nano-module that includes a set of small functions to format/manipulate Ether.

interface Parse {
toHex: (n: number) => string
hexToInt: (s: string) => number
toWei: (s: number | string) => string
toTxWei: (n: number | string) => string
weiToEth: (n: number | string) => number
txWeiToEth: (s: string) => number
}
NameTypeReturns

toHex<>(number)

Parses a number to a it's HEX base value.

function string

hexToInt<>(number)

Parses a HEX base number to it's decimal value.

function number

toWei<>(number | string)

Returns the wei value of a decimal string number.

function string

toTxWei<>(number | string)

Returns the HEX base value of a decimal number.

function string

weiToEth<>(number | string)

Returns the value in ETH for the provided wei value.

function number

txWeiToEth<>(string)

Returns the decimal value for a HEX base wei

function number

@Type Metamask

export interface Metamask extends OnEvent, OnRequest {
isConnected(): boolean
isUserUnlocked(): Promise<boolean>
isMetaMask: boolean
chainId: string
removeListener: (e: string, f: any) => void
selectedAddress: string | null
}

@Type UseMatamaskAPI

export interface UseMatamaskAPI {
connect: () => void
disconnect: (props?: { reload?: boolean }) => void
send: (props: Omit<SendMethodProps, "from">) => Promise<string>
resetError: () => void
account: string
accounts: string[]
balance: number
formattedBalance: string
chainId: string
chainIdDecimal: number
error?: ErrorState
metamask: Metamask
isConnected: boolean
}