You're Invited: Meet the Socket team at BSidesSF and RSAC - April 27 - May 1.RSVP
Socket
Sign inDemoInstall
Socket

starknetkit

Package Overview
Dependencies
Maintainers
0
Versions
132
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

starknetkit

<!-- logo -->

2.10.4
next
latest
Source
npm
Version published
Weekly downloads
5.6K
-24.7%
Maintainers
0
Weekly downloads
 
Created
Source

🕹️ 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 })

Handle webwallet logout

In your application, import handleWebwalletLogoutEvent and pass a callback to manage the state of your dapp

useEffect(() => {
  handleWebwalletLogoutEvent(() => {
    // clear state
  })
}, [])

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.

Keywords

starknet

FAQs

Package last updated on 21 Mar 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts