@raydeck/usemetamask
v1.2.0
Published
<a name="readmemd"></a>
Downloads
4
Readme
@raydeck/usemetamask
React Components and hooks for interacting with metamask. Built with metamask-ts
@raydeck/usemetamask - v1.2.0
@raydeck/usemetamask - v1.2.0
Table of contents
Hooks Functions
Other Functions
- MetamaskConnected
- MetamaskDisconnected
- MetamaskInstalled
- MetamaskNotInstalled
- MetamaskProvider
- MetamaskWrongChain
Hooks Functions
useAccount
▸ useAccount(): string
Returns the current account
Example
import { useAccount } from "@raydeck/usemetamask";
const account = useAccount();
Export
Returns
string
string
useAccounts
▸ useAccounts(): string
[]
Returns the current accounts
Example
import { useAccounts } from "@raydeck/usemetamask";
const accounts = useAccounts();
Export
Returns
string
[]
string[]
useChainId
▸ useChainId(): string
Example
import { useChainId } from "@raydeck/usemetamask";
const chainId = useChainId();
Export
Returns
string
The current chain ID.
useConnected
▸ useConnected(): boolean
Returns whether the wallet is connected to this site.
Example
import { useConnected } from "@raydeck/usemetamask";
const connected = useConnected();
Export
Returns
boolean
boolean.
useMessage
▸ useMessage(): ProviderMessage
Returns the current message
Example
import { useMessage } from "@raydeck/usemetamask";
const message = useMessage();
Export
Returns
ProviderMessage
ProviderMessage
useReloadOnChainChange
▸ useReloadOnChainChange(): void
Trigger a window reload when the chain changes. (best practice)
Export
Example
import { useChainChanged } from "@raydeck/usemetamask";
useChainChanged();
Returns
void
Other Functions
MetamaskConnected
▸ MetamaskConnected(props
, context?
): null
| ReactElement
<any
, any
>
Parameters
| Name | Type |
| :------ | :------ |
| props
| Object
|
| props.chainIds?
| string
[] |
| props.children
| ReactNode
|
| props.unconnected?
| ReactNode
|
| context?
| any
|
Returns
null
| ReactElement
<any
, any
>
MetamaskDisconnected
▸ MetamaskDisconnected(props
, context?
): null
| ReactElement
<any
, any
>
Parameters
| Name | Type |
| :------ | :------ |
| props
| Object
|
| props.chainId?
| string
|
| props.children
| ReactNode
|
| props.connected?
| ReactNode
|
| context?
| any
|
Returns
null
| ReactElement
<any
, any
>
MetamaskInstalled
▸ MetamaskInstalled(props
, context?
): null
| ReactElement
<any
, any
>
Parameters
| Name | Type |
| :------ | :------ |
| props
| Object
|
| props.children
| ReactNode
|
| context?
| any
|
Returns
null
| ReactElement
<any
, any
>
MetamaskNotInstalled
▸ MetamaskNotInstalled(props
, context?
): null
| ReactElement
<any
, any
>
Parameters
| Name | Type |
| :------ | :------ |
| props
| Object
|
| props.children
| ReactNode
|
| context?
| any
|
Returns
null
| ReactElement
<any
, any
>
MetamaskProvider
▸ MetamaskProvider(props
, context?
): null
| ReactElement
<any
, any
>
Parameters
| Name | Type |
| :------ | :------ |
| props
| Object
|
| props.children
| ReactNode
|
| context?
| any
|
Returns
null
| ReactElement
<any
, any
>
MetamaskWrongChain
▸ MetamaskWrongChain(props
, context?
): null
| ReactElement
<any
, any
>
Parameters
| Name | Type |
| :------ | :------ |
| props
| Object
|
| props.chainIds?
| string
[] |
| props.children
| ReactNode
|
| props.unconnected?
| ReactNode
|
| context?
| any
|
Returns
null
| ReactElement
<any
, any
>