Skip to content

argentlabs/starknetkit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

4f1f5a8 ยท Oct 31, 2024
Jul 3, 2024
Oct 6, 2023
Oct 31, 2024
Oct 6, 2023
Oct 10, 2024
Oct 6, 2023
Oct 10, 2024
Oct 6, 2023
Mar 19, 2024
Oct 6, 2023
Aug 23, 2024
Oct 6, 2023
Oct 31, 2024
Oct 23, 2024
Oct 10, 2024
Jul 1, 2024
Oct 6, 2023
Oct 29, 2024
Feb 8, 2024
Oct 30, 2024

Repository files navigation

๐Ÿ•น๏ธ StarknetKit

Install starknetkit with npm or yarn

# latest official release (main branch)
$ npm install starknetkit

# or with yarn:
$ yarn add starknetkit

Imports

After installation, we get access to different methods, such as connect, disconnect, etc which we should import for use in our application:

import { connect, disconnect } from "starknetkit"

Establishing a connection

To establish a wallet connection, we need to call the connect method which was imported earlier like this:

const wallet = await connect()

By default, the list of connectors is:

  • Argent X
  • Braavos
  • Argent mobile
  • Argent webwallet

Connect with specific connectors

const webwallet = await connect([new WebWalletConnector()])

const argentMobileWallet = await connect([
  new ArgentMobileConnector()
])

const wallet = await connect([
  new InjectedConnector({ options: { id: "argentX" } }),
  new InjectedConnector({ options: { id: "braavos" } })
])

Reconnect to a previously connected wallet on load:

const wallet = await connect({ modalMode: "neverAsk" })

Disconnect a wallet

await disconnect({ clearLastWallet: true })

Listen to account change

const selectedConnectorWallet = getSelectedConnectorWallet()
selectedConnectorWallet.on("accountsChanged", () => {
  setWallet(prevState => {
    const updatedWallet = { ...prevState }
    updatedWallet.account = selectedConnectorWallet.account
    return updatedWallet
  })
})

๐Ÿ“• Guides

Guides can be found here

โœ๏ธ Contributing

If you consider to contribute to this project please read CONTRIBUTING.md first.

๐Ÿ“œ License

Copyright (c) 2023

Licensed under the MIT license.