Skip to content

Commit

Permalink
Edit About get-starknet
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandratran committed Sep 20, 2024
1 parent 8e75cb8 commit 8501a8b
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -1,30 +1,37 @@
---
description: How `get-starknet` interacts with MetaMask.
sidebar_position: 2
description: Learn about how `get-starknet` interacts with MetaMask.
sidebar_position: 8
---

# About `get-starknet`

`get-starknet` is a library that simplifies Starknet network interactions.
It works with the Starknet Snap to extend the functionality of MetaMask and enable dapps to interact with users' Starknet accounts in MetaMask.
[`get-starknet`](https://github.com/starknet-io/get-starknet) is a library that simplifies Starknet
network interactions.
It works with the [Starknet Snap](https://snaps.metamask.io/snap/npm/consensys/starknet-snap/) to
enable dapps to interact with users' Starknet accounts in MetaMask.

When you integrate `get-starknet` into your dapp, it creates a `WalletAccount` object. `WalletAccount` acts as a connection between dapps and MetaMask and provides a way to manage Starknet interactions.

This allows users to send Starknet transactions, sign Starknet messages, and manage Starknet accounts within MetaMask, and this functionality can be extended to multiple wallets.
When you integrate `get-starknet` into your dapp, it creates a `WalletAccount` object, which acts as
the connection between the dapp and MetaMask, and manages Starknet interactions.
This allows users to send Starknet transactions, sign Starknet messages, and manage Starknet
accounts within MetaMask, and this functionality can be extended to multiple wallets in the Starknet
ecosystem.

## How `get-starknet` and MetaMask interact

A dapp with `get-starknet` installed interacts with MetaMask as follows:

1. The dapp uses `get-starknet` to request the user connect to MetaMask. If the user doesn't have the Starknet Snap installed, MetaMask automatically prompts the user to connect and approve the addition.
1. The dapp uses `get-starknet` to request the user connect to MetaMask.
MetaMask automatically requests the user to add the Starknet Snap, if it's not already present.

1. After the dapp is connected to MetaMask and the Starknet Snap, `get-starknet` receives a Starknet Windows Object (SWO), which represents the MetaMask wallet with Starknet functionality.
1. After the dapp is connected to MetaMask and the Starknet Snap, `get-starknet` receives a Starknet
Windows Object (SWO), which represents the MetaMask wallet with Starknet functionality.

1. `get-starknet` creates a [`WalletAccount`](http://starknetjs.com/docs/guides/walletAccount/) instance. This instance manages the Starknet account within MetaMask.
1. `get-starknet` creates a [`WalletAccount`](http://starknetjs.com/docs/guides/walletAccount/) instance.
This instance manages the Starknet account within MetaMask.

```mermaid
sequenceDiagram
participant dapp as dapp
participant dapp as Dapp
participant get as get-starknet
participant mm as MetaMask
participant Snap as Starknet Snap
Expand Down Expand Up @@ -56,11 +63,16 @@ sequenceDiagram
get->>dapp: Notify change
```

The `get-starknet` library offers several key features that improve how dapps interact with the Starknet network through MetaMask:
The `get-starknet` library offers several features that improve how dapps interact with the Starknet
network through MetaMask:

- The `WalletAccount` uses a specified provider to access data from the Starknet network.
- For transactions, `get-starknet` prepares the data and sends it to MetaMask for signing through the Starknet Snap.
- `get-starknet` enables the dapp to create contract instances connected to the `WalletAccount`, allowing smart contract functions to be invoked, with MetaMask handling the signatures.
- `get-starknet` sets up listeners for account and network changes in MetaMask, so the dapp can subscribe and update its state accordingly.
- `get-starknet` can request network changes through MetaMask, allowing users to switch between Starknet networks, such as Mainnet or Sepolia testnet.
- `get-starknet` can also request MetaMask to display specific tokens, improving the user experience.
- For transactions, `get-starknet` prepares the data and sends it to MetaMask for signing through
the Starknet Snap.
- `get-starknet` enables the dapp to create contract instances connected to the `WalletAccount`,
allowing smart contract functions to be invoked, with MetaMask handling the signatures.
- `get-starknet` sets up listeners for account and network changes in MetaMask, so the dapp can
subscribe and update its state accordingly.
- `get-starknet` can request network changes through MetaMask, allowing users to switch between
Starknet networks, such as Mainnet and Sepolia testnet.
- `get-starknet` can also request MetaMask to display specific tokens, improving the user experience.
4 changes: 2 additions & 2 deletions wallet/how-to/use-non-evm-networks/starknet/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ The [`wallet_invokeSnap`](/snaps/reference/wallet-api-for-snaps/#wallet_invokesn
:::warning Important

We recommend using the `get-starknet` library for most use cases due to its ease of configuration
and multi-wallet support.
and multi-wallet support.
Learn more [about how `get-starknet` interacts with MetaMask](about-get-starknet.md).

:::


## Supported methods

Once connected to the Starknet Snap, your dapp can call
Expand Down

0 comments on commit 8501a8b

Please sign in to comment.