Skip to content

Latest commit

 

History

History
93 lines (63 loc) · 1.8 KB

magic.md

File metadata and controls

93 lines (63 loc) · 1.8 KB

web3-react Documentation - Magic

Install

yarn add @web3-react/magic-connector

Arguments

apiKey: string
chainId: number
email: string

Example

import { MagicConnector } from '@web3-react/magic-connector'

const magic = new MagicConnector({ apiKey: '…', chainId: 4, email: '…' })

Note: Once the connector has been activated, the Magic SDK instance can be accessed under the .magic property.

Errors

UserRejectedRequestError

Happens when the user closes the connection window.

Example

import { UserRejectedRequestError } from '@web3-react/magic-connector'

function Component() {
  const { error } = useWeb3React()
  const isNoEthereumProviderError = error instanceof UserRejectedRequestError
  // ...
}

FailedVerificationError

Happens when the Magic link verification fails.

Example

import { FailedVerificationError } from '@web3-react/magic-connector'

function Component() {
  const { error } = useWeb3React()
  const isNoEthereumProviderError = error instanceof FailedVerificationError
  // ...
}

MagicLinkRateLimitError

Happens when the Magic rate limit has been reached.

Example

import { MagicLinkRateLimitError } from '@web3-react/magic-connector'

function Component() {
  const { error } = useWeb3React()
  const isNoEthereumProviderError = error instanceof MagicLinkRateLimitError
  // ...
}

MagicLinkExpiredError

Happens when the Magic link has expired.

Example

import { MagicLinkExpiredError } from '@web3-react/magic-connector'

function Component() {
  const { error } = useWeb3React()
  const isNoEthereumProviderError = error instanceof MagicLinkExpiredError
  // ...
}