@huskyfinance/l2-letsgo
TypeScript icon, indicating that this package has built-in type declarations

1.0.5 • Public • Published

LetsGo

The purpose of this package it to help Dapp developers handle L1 to L2 transition.

Installation

npm i @huskyfinance/l2-letsgo

Usage

import LetsGo, { xDai } from '@huskyfinance/l2-letsgo'

const letsgo = new LetsGo({targetNetwork: xDai})

// popup metamask switch network notification
await letsgo.setupNetwork()

React

Simple Example:

import LetsGo, { xDai } from 'l2-letsgo'

function App() {

  const [isReady, setIsReady] = useState(false)

  const userAddress = '0x000abcd'

  useEffect(() => {
    const letsgo = new LetsGo({ 
      targetNetwork: xDai,
      // optional
      address: userAddress,
      checkBalance: true
    })
    letsgo.setupNetwork().then(() => {
      setIsReady(true)
    })
  }, [userAddress])
}

Config

You can also pass in custom network config!

const ArbitrumTestnet = {
  name: 'Arbitrum (Kovan)',
  rpcUrls: ['https://kovan4.arbitrum.io/rpc'],
  blockExplorerUrl: 'https://explorer.arbitrum.io/#/',
  chainId: 212984383488152,
}

const letsgo = new LetsGo({targetNetwork: ArbitrumTestnet})

await letsgo.setupNetwork()

Readme

Keywords

none

Package Sidebar

Install

npm i @huskyfinance/l2-letsgo

Weekly Downloads

0

Version

1.0.5

License

ISC

Unpacked Size

13.2 kB

Total Files

8

Last publish

Collaborators

  • flyingnobita
  • antoncoding