Skip to main content

Quick Start

Get started with Sequence with just a few lines of code, follow along below.

Install

First, install the 0xsequence and ethers packages from NPM:

npm install 0xsequence ethers

or

npm install 0xsequence ethers

or

yarn add 0xsequence ethers

You can find the source of the 0xsequence package on Github.

Connect your wallet

Connecting to Ethereum Mainnet:

import { sequence } from '0xsequence'

const wallet = sequence.initWallet('mainnet')
const connectDetails = await wallet.connect()

console.log('=> connected?', connectDetails.connected)

Connecting to Polygon:

import { sequence } from '0xsequence'

const wallet = sequence.initWallet('polygon')
const connectDetails = await wallet.connect()

console.log('=> connected?', connectDetails.connected)

Get the wallet address

const wallet = sequence.getWallet()
const walletAddress = await wallet.getAddress()

console.log(walletAddress)
// # => '0xabcd....'

Open the wallet from your dapp

const wallet = sequence.getWallet()
wallet.openWallet()

Get the blockchain network ID

You can use a variety of methods to query the chain ID which the wallet is presently connected to.

const wallet = sequence.getWallet()

console.log('chainId:', await wallet.getChainId())

const provider = wallet.getProvider()
console.log('provider.getChainId()', await provider.getChainId())

const signer = wallet.getSigner()
console.log('signer.getChainId()', await signer.getChainId())