Skip to main content

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

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:

Functionalityget-starknetwallet_invokeSnap
Account managementDeploy an accountdeployAccountstarkNet_createAccount
Recover an account addressgetAddressstarkNet_recoverAccounts
Display a private keyn/astarkNet_displayPrivateKey
Gas and feesEstimate the gas feeestimateFeeBulkstarkNet_estimateFee
Estimate the account deploy feeestimateAccountDeployFeestarkNet_estimateAccountDeployFee
Token managementAdd an ERC-20 tokenwatchAssetstarkNet_addErc20Token
Get the ERC-20 token balancecallContractstarkNet_getErc20TokenBalance
Signing and transactionsSign a messagesignMessagestarkNet_signMessage
Sign a transactionsignTransactionstarkNet_signTransaction
Sign a declare transactionsignDeclareTransactionstarkNet_signDeclareTransaction
Verify a signed messagen/astarkNet_verifySignedMessage
Execute a transactionexecutestarkNet_executeTxn
Declare a contractdeclareContractstarkNet_declareContract
Get transactionsgetTransactionstarkNet_getTransaction
Get the transaction statusgetTransactionStatusstarkNet_getTransactionStatus
Network managementSwitch networksswitchNetworkstarkNet_switchNetwork
Get the current networkgetChainIdstarkNet_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: