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

Add Starknet API docs #1516

Open
Tracked by #1511
joaniefromtheblock opened this issue Aug 30, 2024 · 5 comments · May be fixed by #1509
Open
Tracked by #1511

Add Starknet API docs #1516

joaniefromtheblock opened this issue Aug 30, 2024 · 5 comments · May be fixed by #1509
Assignees
Labels
tech-writing Requires updates to documentation content. wallet Related to wallet content.

Comments

@joaniefromtheblock
Copy link
Contributor

joaniefromtheblock commented Aug 30, 2024

To add Starknet methods mentioned in this notion doc:

https://www.notion.so/consensys/Starknet-Snap-User-Guide-9d95a3863b4145c8a3bad6455e35e0e4

FYI, the methods that are rolled up in get-starknet include:

starkNet_extractPublicKey
starkNet_signTransaction
starkNet_signDeployAccountTransaction
starkNet_signDeclareTransaction
starkNet_executeTxn
starkNet_signMessage
starkNet_declareContract
starkNet_getStoredNetworks
starkNet_recoverAccounts
starkNet_switchNetwork
starkNet_addNetwork
starkNet_addErc20Token
starkNet_getCurrentNetwork
@alexandratran
Copy link
Contributor

alexandratran commented Aug 30, 2024

Questions:

  1. Is there anywhere that I can find more info about the following Starknet endpoints that are referenced in the spec return values?
    • gateway/add_transaction
    • feeder_gateway/estimate_fee
    • feeder_gateway/call_contract
    • gateway/call_contract
  2. What is the best way to describe the difference between the Starknet Snap JSON-RPC API, and the Starknet JSON-RPC API? Maybe:
    • Starknet Snap API: With the Starknet Snap installed, you can use the Starknet Snap API to interact with users' Starknet accounts.
    • Starknet API: You can use the Starknet API to interact with the Starknet network.
  3. The list above of "methods rolled up in get-starknet" includes methods from both sets of APIs. Need to understand better how devs/users access these functionalities using get-starknet (are they wrapped up in the UI?).

@khanti42
Copy link
Contributor

khanti42 commented Sep 4, 2024

I think this document explains it https://starknetjs.com/docs/guides/walletAccount

In a nutshell :

A dev will instantiate a wallet with get-starknet like this :

import { connect } from 'get-starknet'; // v4.0.0 min
import { WalletAccount } from 'starknet'; // v6.10.0 min
const myFrontendProviderUrl = 'https://free-rpc.nethermind.io/sepolia-juno/v0_7';
// standard UI to select a wallet :
const selectedWalletSWO = await connect({ modalMode: 'alwaysAsk', modalTheme: 'light' });
const myWalletAccount = new WalletAccount({ nodeUrl: myFrontendProviderUrl }, selectedWalletSWO);

Once they get their myWalletAccount they can interact with the starknet network.

  • All reading activities will be done by the WalletAccount directly (not through the metamask wallet). That's why at the initialization of a WalletAccount, you need to put in the parameters a Provider instance. It will be used for all reading activities.
  • To write to Starknet, the WalletAccount will ask the browser Wallet to sign and send the transaction, using the Starknet Wallet API to communicate.

So generally speaking any action that writes to the blockchain has to be implemented on our side. Then user can use the myWalletAccount as an object.

For example if they need to sign a transaction they can simply do something like

myWalletAccount.signTransaction 

Behind the scene this will trigger the snap to show up by calling the starkNet_signTransaction method.

Other methods are related to the management of the wallet itself, like adding a new account, adding a new network, adding a new token, ...

@khanti42
Copy link
Contributor

khanti42 commented Sep 4, 2024

Regarding this specific questions :

What is the best way to describe the difference between the Starknet Snap JSON-RPC API, and the Starknet JSON-RPC API?

Generally I agree, but specifically

  • Starknet Snap API: With the Starknet Snap installed, you can use the Starknet Snap API to interact with users' Starknet accounts (i.e. write to the blockchain, e.g. submit transaction)
  • Starknet API: You can use the Starknet API to interact read information from the Starknet network (this does not require a wallet).

@alexandratran alexandratran added tech-writing Requires updates to documentation content. wallet Related to wallet content. labels Sep 5, 2024
@alexandratran alexandratran linked a pull request Sep 5, 2024 that will close this issue
2 tasks
@alexandratran
Copy link
Contributor

@khanti42

Thanks for the info. Do you have any information on my first question?

Is there anywhere that I can find more info about the following Starknet endpoints that are referenced in the spec return values?

  • gateway/add_transaction
  • feeder_gateway/estimate_fee
  • feeder_gateway/call_contract
  • gateway/call_contract

Also, regarding this:

Starknet API: You can use the Starknet API to interact read information from the Starknet network (this does not require a wallet).

The first few methods of the Starknet API allow you to submit Starknet transactions (e.g. starknet_addDeclareTransaction) – this isn't just reading from the network?

@khanti42
Copy link
Contributor

@alexandratran, the feeder_gateway/gateway has been deprecated and replaced by RPC endpoints. For some calls made by the StarkNet Snap, the response is simply the value returned by the RPC call to the StarkNet network (without any modifications). In those cases, the return value will follow the specifications of the corresponding RPC endpoint.

I will clarify this in a new review of PR #1509 by adding links to the appropriate sections of the StarkNet.js API documentation for those cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tech-writing Requires updates to documentation content. wallet Related to wallet content.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants