Skip to content

magic: 2.0.0

Compare
Choose a tag to compare
@Adamj1232 Adamj1232 released this 16 Mar 02:40
b191bf9

The Magic module provides email login support for the Magic Wallet through web3-onboard.

Install

npm i @web3-onboard/magic

Head over to https://magic.link/ and signup to get an API key for your DApp

Login options

  • Email - The Magic module comes with a built in email login modal that is customizable
    in the same fashion that all other web3-onboard UI components are
  • note: The Magic Module currently only supports email login but we are open to expand to sms or socials*

Initialization Options

type magicOptions = {
  apiKey: string
}

Usage

import Onboard from '@web3-onboard/core'
import magicModule from '@web3-onboard/magic'

const magic = magicModule({ apiKey: 'API_KEY' })

const onboard = Onboard({
  // ... other Onboard options
  wallets: [
    magic
    //... other wallets
  ]
})

const connectedWallets = await onboard.connectWallet()
console.log(connectedWallets)

Accessing the Magic Wallet Internals

When a Magic wallet is connect the Magic instance is exposed.
This can be used to get information such as user Metadata, update a user's email address or handle the user's token.

const [magicWallet] = await onboard.connectWallet()

try {
  const { email, publicAddress } = await magicWallet.instance.user.getMetadata();
} catch {
  // Handle errors if required!
}

For full documentation and examples please visit Magic's official docs

Changelog:

  • web3-onboard/magic:v2.0.0: [feature] - Magic wallet module addition #879