Skip to content

Latest commit

 

History

History
174 lines (152 loc) · 8.32 KB

File metadata and controls

174 lines (152 loc) · 8.32 KB
description
Interact with users' Starknet accounts in MetaMask.

Use Starknet

Starknet is a non-EVM Layer 2 network. You can interact with users' Starknet accounts in MetaMask by connecting to the Starknet Snap. You can use the get-starknet library or the wallet_invokeSnap JSON-RPC method from your dapp to connect to the Starknet Snap. Both options support similar functionalities, but offer different ways of interacting with users' Starknet accounts.

See Connect to Starknet to get started.

The following sections compare the two connection options.

get-starknet

:::warning Important

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

:::

The get-starknet library:

  • Provides a high-level API that abstracts complex operations.
  • Standardizes error handling.
  • Supports connecting to multiple Starknet wallets, not limited to MetaMask.
  • Manages wallet connections and Starknet interactions.
  • Provides results in more readable code.

get-starknet provides the same functionalities as wallet_invokeSnap and integrates a Starknet Window Object (SWO). The SWO simplifies account management and signing, and enhances the experience of handling account states and transactions. A dapp uses the Account object in the SWO to manage operations.

wallet_invokeSnap

The wallet_invokeSnap method:

  • Requires precise method names and parameter structures.
  • Handles both MetaMask-specific and Starknet-specific errors.
  • Is designed for operating within the MetaMask framework.
  • Manages lower-level Starknet interactions directly.
  • Provides results in more detailed, lower-level code.

wallet_invokeSnap manages direct interactions between the dapp and the Starknet Snap. It facilitates network communication for account creation, transaction signing, fee estimation, and other Starknet-related actions.

Supported functionalities

The following section lists the core functionalities and API methods that each connection option supports:

Functionality `get-starknet` `wallet_invokeSnap`
Account management Deploy an account `deployAccount` ↗ `starkNet_createAccount`
Recover an account address `getAddress` ↗ `starkNet_recoverAccounts`
Display a private key n/a `starkNet_displayPrivateKey`
Gas and fees Estimate the gas fee `estimateFeeBulk` ↗ `starkNet_estimateFee`
Estimate the account deploy fee `estimateAccountDeployFee` ↗ `starkNet_estimateAccountDeployFee`
Token management Add an ERC-20 token `watchAsset` ↗ `starkNet_addErc20Token`
Get the ERC-20 token balance `callContract` ↗ `starkNet_getErc20TokenBalance`
Signing and transactions Sign a message `signMessage` ↗ `starkNet_signMessage`
Sign a transaction `signTransaction` ↗ `starkNet_signTransaction`
Sign a declare transaction `signDeclareTransaction` ↗ `starkNet_signDeclareTransaction`
Verify a signed message n/a `starkNet_verifySignedMessage`
Execute a transaction `execute` ↗ `starkNet_executeTxn`
Declare a contract `declareContract` ↗ `starkNet_declareContract`
Get transactions `getTransaction` ↗ `starkNet_getTransaction`
Get the transaction status `getTransactionStatus` ↗ `starkNet_getTransactionStatus`
Network management Switch networks `switchNetwork` ↗ `starkNet_switchNetwork`
Get the current network `getChainId` ↗ `starkNet_getCurrentNetwork`

Resources

To get started, connect your dapp to Starknet in MetaMask.

The following external resources provide additional information for learning about and interacting with Starknet: