Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Starknet Snap docs #1509

Open
wants to merge 40 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
e6bd15c
rough skeleton
joaniefromtheblock Aug 28, 2024
f8c3685
update menu sidebar
joaniefromtheblock Aug 28, 2024
1130adf
Add Starknet Snap API reference docs
alexandratran Aug 31, 2024
9401571
Merge branch 'main' into wip-starknet-snap
alexandratran Sep 5, 2024
a43f196
Clean up files and placeholders
alexandratran Sep 5, 2024
c27a96d
add changes for connect
joaniefromtheblock Sep 12, 2024
6bac10a
update branch
joaniefromtheblock Sep 12, 2024
473a71d
examples added
joaniefromtheblock Sep 12, 2024
25821bb
rewrite of connect section
joaniefromtheblock Sep 14, 2024
0251bcc
rough additions of troubleshoot section
joaniefromtheblock Sep 14, 2024
3d8ef91
updates with suggestions
joaniefromtheblock Sep 18, 2024
b915696
add additional suggestions
joaniefromtheblock Sep 18, 2024
5b6e1cf
apply suggestions
joaniefromtheblock Sep 19, 2024
f2074ef
more suggestions
joaniefromtheblock Sep 19, 2024
455aaec
updates
joaniefromtheblock Sep 19, 2024
d832af8
updates
joaniefromtheblock Sep 19, 2024
df73570
Merge branch 'main' into wip-starknet-snap
alexandratran Sep 20, 2024
0e4ef69
Edit non-EVM intro and Starknet intro
alexandratran Sep 20, 2024
8e75cb8
Edit Connect to Starknet
alexandratran Sep 20, 2024
8501a8b
Edit About get-starknet
alexandratran Sep 20, 2024
baa2b16
Edit Manage Starknet accounts
alexandratran Sep 20, 2024
f6f30a2
Edit Manage networks, API reference, etc
alexandratran Sep 20, 2024
81d3bb2
add docs
joaniefromtheblock Sep 20, 2024
c5f1762
fix table
joaniefromtheblock Sep 20, 2024
333cef5
Apply suggestions from code review
joaniefromtheblock Sep 24, 2024
5786849
Apply suggestions from code review
joaniefromtheblock Sep 24, 2024
8e467fa
update troubleshoot section
joaniefromtheblock Sep 25, 2024
151e759
update troubleshoot sections
joaniefromtheblock Sep 25, 2024
a1fe114
update text for tutorial
joaniefromtheblock Sep 25, 2024
ff7df58
add dual examples
joaniefromtheblock Sep 26, 2024
faba7f4
copy edits
joaniefromtheblock Sep 26, 2024
1617eab
copy edits
joaniefromtheblock Sep 26, 2024
4a64f9b
copy edits
joaniefromtheblock Sep 26, 2024
07ad89e
Edit content for style and formatting
alexandratran Sep 26, 2024
0cadd60
Merge and edit branch 'wip-starknet-snap' of github.com:MetaMask/meta…
alexandratran Sep 26, 2024
d432e98
add template text
joaniefromtheblock Sep 26, 2024
99839e7
add note
joaniefromtheblock Sep 26, 2024
b22b545
updates
joaniefromtheblock Oct 3, 2024
7219bc9
Merge branch 'main' into wip-starknet-snap
joaniefromtheblock Oct 3, 2024
052b326
remove old instances
joaniefromtheblock Oct 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions wallet-sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ const sidebar = {
type: "doc",
id: "reference/sdk-unity-api",
},
{
type: "category",
label: "Non-EVM APIs",
link: { type: "generated-index", slug: "/reference/non-evm-apis" },
items: [{ type: "autogenerated", dirName: "reference/non-evm-apis" }],
},
{
type: "doc",
id: "reference/provider-api",
Expand Down
4 changes: 4 additions & 0 deletions wallet/how-to/connect/access-accounts.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ When accessing a user's accounts:
- **Always** disable the connect button while the connection request is pending.
- **Never** initiate a connection request on page load.

:::note
You can also access users' accounts on some [non-EVM networks](/wallet/how-to/use-non-evm-networks).
:::

## Create a connect button

:::caution Important
Expand Down
8 changes: 4 additions & 4 deletions wallet/how-to/manage-networks/add-network.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ The confirmations look like the following:
</div>
</div>

:::note

To add a local development network such as [Hardhat](https://hardhat.org) to MetaMask, see [Run a development network](../run-devnet.md).

:::info Development and non-EVM networks
- To add a local development network such as [Hardhat](https://hardhat.org) to MetaMask, see [Run a development network](../run-devnet.md).
- To add a non-EVM network such as [Starknet](../use-non-evm-networks/starknet/index.md) to MetaMask,
see [Use non-EVM networks](/wallet/how-to/use-non-evm-networks).
:::

## Example
Expand Down
2 changes: 1 addition & 1 deletion wallet/how-to/run-devnet.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
description: Configure and connect to a Ganache development network.
sidebar_position: 9
sidebar_position: 10
---

# Run a development network
Expand Down
32 changes: 32 additions & 0 deletions wallet/how-to/use-non-evm-networks/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
description: Interact with users' accounts on non-EVM networks.
sidebar_position: 9
---

import CardList from "@site/src/components/CardList"

# Use non-EVM networks

You can interact with users' accounts on non-EVM networks by connecting to existing
[MetaMask Snaps](https://metamask.io/snaps/).

Non-EVM networks are blockchain networks that are not compatible with the Ethereum Virtual Machine (EVM).
Non-EVM dapps and MetaMask can't directly interact with each other.
By connecting to dedicated non-EVM Snaps, you can extend the functionality of MetaMask and integrate non-EVM networks into your existing MetaMask workflow.

joaniefromtheblock marked this conversation as resolved.
Show resolved Hide resolved
MetaMask provides Snaps for the following networks:

<CardList
items={[
{
href: "starknet",
title: "Starknet",
description:
"Layer 2 network for Ethereum using ZK rollups.",
},
]}
/>
joaniefromtheblock marked this conversation as resolved.
Show resolved Hide resolved

:::info
See the [full list of available non-EVM Snaps](https://snaps.metamask.io/interoperability).
:::
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
---
description: Learn about how `get-starknet` interacts with MetaMask.
sidebar_position: 8
---

# About `get-starknet`

[`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.

joaniefromtheblock marked this conversation as resolved.
Show resolved Hide resolved
When you integrate `get-starknet` into your dapp, it creates a [Starknet
Windows Object (SWO)](https://github.com/starknet-io/get-starknet/blob/get-starknet-core%403.3.0/packages/core/src/StarknetWindowObject.ts), 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.
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
joaniefromtheblock marked this conversation as resolved.
Show resolved Hide resolved
Windows Object (SWO), which represents the MetaMask wallet with Starknet functionality.

1. You can retrieve an [Account Object](https://starknetjs.com/docs/API/#account) from the Starknet Windows Object (SWO) when you access `swo.account`.
This Account Object enables you to manage Starknet interactions.
This instance manages the Starknet account within MetaMask.

```mermaid
sequenceDiagram
participant user as End User
participant dapp as Dapp
participant get as get-starknet
participant mm as MetaMask
participant Snap as Starknet Snap
participant network as Starknet network

dapp->>get: Initialize connection
get->>mm: Request connection
mm->>Snap: Activate
Snap-->>mm: Activated
get->>Snap: Request Starknet account address
Snap-->>mm: Recover account and return Starknet account address
mm-->>get: Return Starknet account address
get-->>dapp: Connection established with SWO return

dapp->>get: Read blockchain data
get->>network: Query data
network-->>get: Return data
get-->>dapp: Processed data

dapp->>get: Write transaction
joaniefromtheblock marked this conversation as resolved.
Show resolved Hide resolved
get->>mm: Request write transaction
mm->>Snap: write transaction
Snap-->>mm: Request confirmation to write transaction
mm-->>user: Request confirmation
user-->>mm: Confirm transaction
mm-->>Snap: Confirm transaction

alt If the Account has deployed
Snap-->>network: deploying account transaction
end
Snap-->>network: Submit transaction
network-->>Snap: Transaction result
Snap-->>mm: Return Transaction result
mm-->>get: Return Transaction result
get-->>dapp: Return Transaction result
```

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

- The `AccountInterface` 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 `AccountInterface`,
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.
Loading
Loading