@huskyfinance/l2-letsgo
v1.0.5
Published
lets go L2
Downloads
5
Readme
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()