iam-dev / starknet-snap

The MetaMask Snap for StarkNet

Home Page:https://snaps.consensys.net/starknet

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool


Starknet Snap · npm version

The Starknet snap allows developers to deploy Starknet accounts, make transactions on Starknet, and interact with Starknet smart contracts. It can be connected with any dapp to access Starknet and developers can experiment integrating their dapp with this snap today.

Starknet Snap

Starknet Dapp

Blog Post

Development

Prerequisites

  • MetaMask Flask
    • ⚠️ You cannot have other versions of MetaMask installed
  • Nodejs 16. We strongly recommend you install via NVM to avoid incompatibility issues between different node projects.
    • Once installed, you should also install Yarn with npm i -g yarn to make working with this repository easiest.

Installing

nvm use
yarn setup

Running

Snap

⚠️ When snap updates you will need to still reconnect from the dapp to see changes

# Running Snap via watch mode
yarn workspace @consensys/starknet-snap watch

Alternatively you can build and serve the snap manually. This can sometimes be more stable than watch mode but requires a manual rebuild and serve anytime there is a change on the snap.

# Building and serving snap manually
yarn workspace @consensys/starknet-snap build
yarn workspace @consensys/starknet-snap serve

UI

# Running Wallet UI
yarn workspace wallet-ui start
# Running Storybook
yarn workspace wallet-ui storybook

Dapp intergation Guide

How to install

From the dApp, issue the following RPC request to install the Snap, make sure it is using the latest version

provider.request({
  method: 'wallet_requestSnaps',
  params: {
    ["npm:@consensys/starknet-snap"]: { version: "2.2.0"}, //Snap's version
  },
})

Interact with Starknet Snap's Api

From the dApp, issue the following RPC request to interact with the Snap

e.g

provider.request({
  method: 'wallet_invokeSnap',
  params: {
    snapId: "npm:@consensys/starknet-snap",
    request: {
      method: 'starkNet_getStoredUserAccounts', //Snap method
      params: {
        chainId : "1", //Snap method's parameter
      },
    },
  },
}))

Starknet Snap's Api

The corresponding request payload and response for latest Starknet Snap's Api are documented in the openrpc spec

Licenses

This project is dual-licensed under Apache 2.0 and MIT terms:

Copyright (c) 2023 ConsenSys Software Inc.

About

The MetaMask Snap for StarkNet

https://snaps.consensys.net/starknet

License:Apache License 2.0


Languages

Language:TypeScript 89.5%Language:HTML 6.5%Language:HCL 2.3%Language:JavaScript 1.2%Language:Makefile 0.2%Language:Shell 0.2%Language:CSS 0.1%