About get-starknet
get-starknet is a library that simplifies Starknet
network interactions.
It works with the Starknet Snap to
enable dapps to interact with users' Starknet accounts in MetaMask.
When you integrate get-starknet into your dapp, it creates a Starknet
Window Object (SWO), 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:
-
The dapp uses
get-starknetto request the user connect to MetaMask. MetaMask automatically requests the user to add the Starknet Snap, if it's not already present. -
After the dapp is connected to MetaMask and the Starknet Snap,
get-starknetreceives a Starknet Window Object (SWO), which represents the MetaMask wallet with Starknet functionality. -
The dapp uses
swo.accountto retrieve an Account object from the SWO. This Account object enables the dapp to manage Starknet interactions within MetaMask.
The get-starknet library offers several features that improve how dapps interact with the Starknet
network through MetaMask:
- The
Accountobject uses a specified provider to access data from the Starknet network. - For transactions,
get-starknetprepares the data and sends it to MetaMask for signing through the Starknet Snap. get-starknetenables the dapp to create contract instances connected to theAccountInterface, allowing smart contract functions to be invoked, with MetaMask handling the signatures.get-starknetsets up listeners for account and network changes in MetaMask, so the dapp can subscribe and update its state accordingly.get-starknetcan request network changes through MetaMask, allowing users to switch between Starknet networks, such as Mainnet and Sepolia testnet.get-starknetcan also request MetaMask to display specific tokens, improving the user experience.