Giter Site home page Giter Site logo

lionweb3 / get-starknet Goto Github PK

View Code? Open in Web Editor NEW

This project forked from starknet-io/get-starknet

0.0 0.0 0.0 1.06 MB

StarkNet wallet <-> dApp bridge

License: MIT License

Shell 0.27% JavaScript 1.24% TypeScript 83.84% CSS 0.38% HTML 0.64% Svelte 13.62%

get-starknet's Introduction

get-starknet

npm

Goals

  • ❤️‍🩹 Allow Starknet dApps and wallets to seamlessly connect
  • 🪶 Lightweight and easy to use
  • 🏎 Fast integration, building and testing
  • ⚙️ Customizable and extensible
  • 🌍 Open source and controlled by the community

Installation

# using npm
npm install get-starknet starknet@next

# using yarn
yarn add get-starknet starknet@next

# using pnpm
pnpm add get-starknet starknet@next

Usage for dApp developers

You can use the built-in UI to connect to any Starknet wallet as fast as possible like this:

import { connect, disconnect } from "get-starknet"

return <button onClick={() => connect()}>Connect wallet</button>

Advanced usage

You can also choose to customize the UI by overwriting the CSS classes, or by implementing your very own UI. This is possible due to a split into a core and ui package. As a library author or dapp developer who wants to implement a custom UI, you can use the core package.

import {
  disconnect,
  enable,
  getAvailableWallets,
  getDiscoveryWallets,
  getLastConnectedWallet,
  getPreAuthorizedWallets,
} from "get-starknet-core"

interface GetStarknetResult {
  // Returns all wallets available in the window object
  getAvailableWallets: (
    options?: GetWalletOptions,
  ) => Promise<StarknetWindowObject[]>
  // Returns only preauthorized wallets available in the window object
  getPreAuthorizedWallets: (
    options?: GetWalletOptions,
  ) => Promise<StarknetWindowObject[]>
  // Returns all wallets in existence (from discovery file)
  getDiscoveryWallets: (options?: GetWalletOptions) => Promise<WalletProvider[]>
  // Returns the last wallet connected when it's still connected
  getLastConnectedWallet: () => Promise<StarknetWindowObject | null>
  // Connects to a wallet
  enable: (
    wallet: StarknetWindowObject,
    options?: {
      starknetVersion?: "v4" | "v5"
    },
  ) => Promise<ConnectedStarknetWindowObject>
  // Disconnects from a wallet
  disconnect: (options?: { clearLastWallet?: boolean }) => Promise<void>
}

Development

You need Node and pnpm installed. Make sure to clone this repo and run:

pnpm install
pnpm build

To start watching for changes, run:

pnpm dev

and open http://localhost:5173/

Running tests

For running tests:

pnpm test

get-starknet's People

Contributors

avimak avatar delaaxe avatar dependabot[bot] avatar dhruvkelawala avatar github-actions[bot] avatar gregoryguillou avatar janek26 avatar ltoussaint avatar mottyl avatar realcryptomer avatar robriks avatar rootulp avatar semantic-release-bot avatar wraitii avatar yoga-braavos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.