2.3.0 • Published 8 days ago

@0xsequence/kit v2.3.0

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
8 days ago

Sequence Kit 🧰

Sequence Kit 🧰 is a library enabling developers to easily integrate web3 wallets in their app. It is based on wagmi and supports all wagmi features.

  • Connect via social logins eg: facebook, google, discord, etc...! 🔐🪪
  • Connect to popular web3 wallets eg: walletConnect, metamask ! 🦊 ⛓️
  • Full-fledged embedded wallet for coins and collectibles 👛 🖼️ 🪙
  • Fiat onramp 💵 💶 💴 💷

View the demo! 👀

Quick Start

Installing the Library

@0xsequence/kit is the core package. Any extra modules require this package to be installed first. To install this package:

npm install @0xsequence/kit @0xsequence/kit-connectors wagmi ethers@5.7.2 viem 0xsequence @tanstack/react-query
# or
pnpm install @0xsequence/kit @0xsequence/kit-connectors wagmi ethers@5.7.2 viem 0xsequence @tanstack/react-query
# or
yarn add @0xsequence/kit @0xsequence/kit-connectors wagmi ethers@5.7.2 viem 0xsequence @tanstack/react-query

Setting up the Library

React apps must be wrapped by a Wagmi client and the KitWalletProvider components. It is important that the Wagmi wrapper comes before the Sequence Kit wrapper.

import MyPage from './components/MyPage'
import { KitProvider } from '@0xsequence/kit'
import { getDefaultConnectors } from '@0xsequence/kit-connectors'
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import { createConfig, http, WagmiProvider } from 'wagmi'
import { mainnet, polygon, Chain } from 'wagmi/chains'

const queryClient = new QueryClient() 

function App() {
  const chains = [mainnet, polygon] as [Chain, ...Chain[]]
  
  const projectAccessKey = 'xyz'

  const connectors = getDefaultConnectors({
    walletConnectProjectId: 'wallet-connect-id',
    defaultChainId: 137,
    appName: 'demo app',
    projectAccessKey
  })

  const transports = {}

  chains.forEach(chain => {
    transports[chain.id] = http()
  })
  
  const config = createConfig({
    transports,
    connectors,
    chains
  })

  return (
    <WagmiConfig config={config}>
      <QueryClientProvider client={queryClient}> 
        <KitProvider>
          <MyPage />
        </KitProvider>
      </QueryClientProvider>
    </WagmiConfig>
  );
}

Opening the Sign in Modal

Wallet selection is done through a modal which can be called programmatically.

import { useOpenConnectModal } from '@0xsequence/kit'
import { useDisconnect, useAccount } from 'wagmi'

const MyReactComponent = () => {
  const { setOpenConnectModal } = useOpenConnectModal()

  const { isConnected } = useAccount()

  const onClick = () => {
    setOpenConnectModal(true)
  }

  return (
    <>
      {!isConnected && (
        <button onClick={onClick}>
          Sign in
        </button>
      )}
    </>
  )
}

Hooks

useOpenConnectModal

Use the useOpenConnectModal to change to open or close the connection modal.

import { useOpenConnectModal } from '@0xsequence/kit'
// ...
  const { setOpenConnectModal } = useOpenConnectModal()
  setOpenConnectModal(true)

useTheme

Use the useTheme hook to get information about the current theme, such as light or dark, or set it to something else.

import { useTheme } from '@0xsequence/kit'
  const { theme, setTheme } = useTheme()

  setTheme('light')

Customization

The KitProvider wrapper can accept an optional config object.

The settings are described in more detailed in the Sequence Kit documentation.

  const kitConfig =  {
    defaultTheme: 'light',
    position: 'top-left',
    signIn: {
      logoUrl: 'https://logo-dark-mode.svg',
      projectName: 'my app',
      showEmailInput: true,
      socialAuthOptions: ['google', 'facebook', 'twitch', 'apple'],
      walletAuthOptions: ['sequence', 'metamask', 'wallet-connect', 'coinbase-wallet'],
    },
    // limits the digital assets displayed on the assets summary screen
    displayedAssets: [
      {
        contractAddress: ethers.constants.AddressZero,
        chainId: 137,
      },
      {
        contractAddress: '0x631998e91476da5b870d741192fc5cbc55f5a52e',
        chainId: 137
      }
    ],
  }

  <KitProvider config={kitConfig}>
    <App />
  <KitProvider>

Packages

PackageDescriptionDocs
@0xsequence/kitCore package for Sequence KitRead more
@0xsequence/kit-connectorsConnectors for sequence kit including popular web3 wallets and social loginsRead more
@0xsequence/kit-walletEmbedded wallets for viewing and sending coins and collectiblesRead more
@0xsequence/kit-checkoutCheckout modal with fiat onrampRead more
@0xsequence/kit-example-reactExample application showing sign in, wallet and checkoutRead more

Local Development

The React example can be used to test the library locally.

  1. pnpm install
  2. From the root folder, run pnpm watch to build the package in watch mode in one console.
  3. From the root folder, run pnpm start:react to run the react example in another console.

What to do next?

Now that the core package is installed, you can install the embedded wallet or take a look at the checkout.

LICENSE

Apache-2.0

Copyright (c) 2017-present Horizon Blockchain Games Inc. / https://horizon.io

2.3.0

8 days ago

2.2.2

9 days ago

2.2.1

10 days ago

2.2.0

14 days ago

2.1.1

15 days ago

2.1.1-beta

17 days ago

2.1.1-beta.1

17 days ago

2.0.8-beta.2

20 days ago

2.1.0

20 days ago

2.0.8-beta

21 days ago

2.0.8-beta.1

21 days ago

2.0.8

1 month ago

2.0.7

1 month ago

2.0.6

1 month ago

2.0.5-beta.12

1 month ago

2.0.5-beta.14

1 month ago

2.0.5-beta.13

1 month ago

2.0.5-beta.11

2 months ago

2.0.5-beta.10

2 months ago

2.0.5-beta.9

2 months ago

2.0.5

2 months ago

2.0.5-beta.8

2 months ago

2.0.5-beta.5

2 months ago

2.0.5-beta.4

2 months ago

2.0.5-beta.7

2 months ago

2.0.5-beta.6

2 months ago

2.0.5-beta.3

2 months ago

2.0.4

2 months ago

2.0.5-beta.1

2 months ago

2.0.5-beta.2

2 months ago

2.0.4-beta.1

3 months ago

2.0.3

3 months ago

2.0.2

3 months ago

2.0.1

3 months ago

2.0.0-beta.2

3 months ago

2.0.0-beta.1

3 months ago

2.0.0

3 months ago

1.0.14

3 months ago

1.0.13

3 months ago

1.0.11

3 months ago

1.0.12

3 months ago

1.0.9

5 months ago

1.0.8

5 months ago

1.0.7

5 months ago

1.0.6

5 months ago

1.0.10

5 months ago

1.0.2

6 months ago

1.0.5

6 months ago

1.0.4

6 months ago

1.0.3

6 months ago

1.0.1

6 months ago

1.0.0

7 months ago

0.0.9

7 months ago

0.0.8

7 months ago

0.0.7

7 months ago

0.0.6

8 months ago

0.0.5

8 months ago

0.0.4

8 months ago

0.0.3

8 months ago

0.0.2

8 months ago

0.0.1

8 months ago