### Install StarknetKit SDK Source: https://www.starknetkit.com/docs/latest/getting-started/without-starknet-react Installs the StarknetKit package and its peer dependencies using npm, yarn, or pnpm. This is the first step to integrate StarknetKit into your dApp. ```bash npm install starknetkit ``` -------------------------------- ### Install @starknet-io/get-starknet-core Source: https://www.starknetkit.com/docs/latest/connectors/metamask-snap Install the necessary package for using starknet-react with StarknetKit. This command installs the core Starknet functionalities required for wallet connections. ```bash npm i @starknet-io/get-starknet-core ``` -------------------------------- ### Create StarknetKit App Boilerplate Source: https://www.starknetkit.com/docs/latest/getting-started/usage Use this command to quickly set up a new project with StarknetKit, Starknet-React, and Next.js. Follow the prompts to name your project and complete the setup. The template includes a basic example of StarknetKit usage with Starknet-react. ```bash npx create-demo-starknetkit-app ``` -------------------------------- ### Establish Wallet Connection with Default Connectors Source: https://www.starknetkit.com/docs/latest/getting-started/without-starknet-react Establishes a wallet connection by calling the `connect` method. It uses the default connector order: Ready Wallet (Argent X) and Braavos. ```javascript const { wallet, connector, connectorData } = await connect({}) ``` -------------------------------- ### Connect Wallet and Set State Source: https://www.starknetkit.com/docs/v2.3.2/getting-started/usage An example function that connects to a wallet and updates the application's state with connection and address information if the connection is successful. ```javascript const connectWallet = async () => { const { wallet, connectorData } = await connect() if (wallet && connectorData) { setConnection(wallet) setAddress(connectorData.account) } } ``` -------------------------------- ### Establish Custom Wallet Connection Order Source: https://www.starknetkit.com/docs/v2.3.2/getting-started/usage Establishes a wallet connection with a custom order of connectors by passing the `connectors` argument to the `connect` method. This example prioritizes the Web Wallet and Argent X. ```javascript import { connect } from "starknetkit" import { WebWalletConnector } from "starknetkit/webwallet" import { InjectedConnector } from "starknetkit/injected" const { wallet, connectorData } = await connect({ connectors: [ new WebWalletConnector(), new InjectedConnector({ options: { id: "argentX" } }), ], }) ``` -------------------------------- ### Install Starknetkit and Starknet-react Packages Source: https://www.starknetkit.com/docs/v1.1.9/starknetkit-with-starknet-react Installs the necessary Starknetkit and Starknet-react packages using npm, yarn, or pnpm. Ensure compatibility with starknet-react v2 connectors. ```bash npm install starknetkit @starknet-react/core @starknet-react/chains ``` -------------------------------- ### Configure and Establish Wallet Connection Source: https://www.starknetkit.com/docs/latest/getting-started/without-starknet-react Establishes a wallet connection with custom configurations, including modal appearance and a specific order of connectors (InjectedConnector for Argent X and Braavos). It then sets the connection and address states if a wallet is found. ```javascript import { connect } from "starknetkit" import { WebWalletConnector } from "starknetkit/webwallet" import { InjectedConnector } from "starknetkit/injected" const handleConnect = async () => { const { wallet, connectorData } = await connect({ modalMode: 'alwaysAsk', modalTheme: 'system', connectors: [ new InjectedConnector({ options: { id: "argentX", name: "Ready Wallet (formerly Argent)" }, }), new InjectedConnector({ options: { id: "braavos", name: "Braavos" }, }) ], }); if (wallet && connectorData) { setConnection(wallet); setAddress(connectorData.account || ''); } }; ``` -------------------------------- ### Use StarknetKit Connect Function for Metamask Source: https://www.starknetkit.com/docs/latest/connectors/metamask-snap Implement a handler function to connect to Starknet using StarknetKit's `connect` function, specifically targeting the Metamask connector. This example shows how to initiate the connection and set wallet state upon successful connection. ```javascript const handleConnect = async () => { const { wallet, connectorData } = await connect({ connectors: [ new InjectedConnector({ options: { id: 'metamask', name: 'MetaMask' }, }), ], }); if (wallet && connectorData) { setConnection(wallet); setAddress(connectorData.account || ''); } }; ``` -------------------------------- ### Request Wallet Accounts with StarknetKit Source: https://www.starknetkit.com/docs/v2.3.2/getting-started/usage Demonstrates how to request account access from a Starknet wallet using the `.request` method with the `wallet_requestAccounts` type. This replaces the older `.enable()` method and is essential for interacting with the Starknet network. ```javascript await wallet.request({ type: "wallet_requestAccounts" }) // replaces .enable() ``` -------------------------------- ### Install StarknetKit Package Source: https://www.starknetkit.com/docs/v1.1.9/getting-started Installs the StarknetKit package and its peer dependencies using npm. This is the first step to integrating the SDK into your dApp. ```bash npm install starknetkit ``` -------------------------------- ### Run Starknet dApp Development Server Source: https://www.starknetkit.com/docs/v1.1.9/starknetkit-template After creating a new Starknet dApp project, navigate into the project directory and run this command to start the development server. This command is typically used with npm. ```bash cd my-app npm run dev ``` -------------------------------- ### Connect Wallet with Specific Options Source: https://www.starknetkit.com/docs/v2.3.2/getting-started/usage Connects to a wallet using `connect` with specific options, including `modalMode`, `modalTheme`, `webWalletUrl`, and detailed `argentMobileOptions` for Argent Mobile wallet integration. ```javascript const { wallet, connectorData } = await connect({ modalMode: "alwaysAsk", modalTheme: "light", webWalletUrl: "https://web.argent.xyz", argentMobileOptions: { dappName: "Dapp name", projectId: "YOUR_PROJECT_ID", // wallet connect project id chainId: "SN_MAIN", url: window.location.hostname, icons: ["https://your-icon-url.com"], rpcUrl: "YOUR_RPC_URL", }, }) ``` -------------------------------- ### Handle Wallet Disconnection Source: https://www.starknetkit.com/docs/latest/getting-started/without-starknet-react Provides an example function `disconnectWallet` that calls the `disconnect` method and then resets the application's connection and address states to their default values (undefined and empty string, respectively). ```javascript const disconnectWallet = async () => { await disconnect() setConnection(undefined) setAddress("") } ``` -------------------------------- ### Initialize ReadyConnector with Default Options Source: https://www.starknetkit.com/docs/latest/connectors/ready Initializes the ReadyConnector with basic options, including dApp name, URL, and chain ID. This setup is used when connecting via StarknetKit's built-in modal. ```typescript const { wallet, connectorData } = await connect({ connectors: [ ReadyConnector.init({ options: { dappName: "Dapp name", url: window.location.hostname, chainId: CHAIN_ID, icons: [], }, }) as StarknetKitConnector, ], }) ``` -------------------------------- ### Import StarknetKit Connection Functions Source: https://www.starknetkit.com/docs/latest/getting-started/without-starknet-react Imports the `connect` and `disconnect` functions from the starknetkit library. These functions are essential for managing wallet connections in your application. ```javascript import { connect, disconnect } from "starknetkit" ``` -------------------------------- ### Initialize Connection on Component Mount Source: https://www.starknetkit.com/docs/latest/getting-started/without-starknet-react Uses a `useEffect` hook to automatically attempt reconnection to a previously connected wallet when the component mounts. If a connection is found, it updates the application's state with the wallet and selected address. ```javascript useEffect(() => { const connectToStarknet = async () => { const { wallet, connectorData } = await connect({ modalMode: "neverAsk" }) if (wallet && connectorData != null) { setConnection(wallet) setAddress(wallet.selectedAddress) } } connectToStarknet() }, []) ``` -------------------------------- ### Connect to Web Wallet with specific URL Source: https://www.starknetkit.com/docs/v2.3.2/connectors/web-wallet This example shows how to establish a connection to the web wallet by directly passing the `webWalletUrl` to the `connect` function. This method is used to connect to a specific instance of the web wallet. ```typescript const { wallet, connectorData } = await connect({ webWalletUrl: "https://web.argent.xyz", }) setWallet(wallet) setConnectorData(connectorData) ``` -------------------------------- ### Establish Default Wallet Connection Source: https://www.starknetkit.com/docs/v2.3.2/getting-started/usage Establishes a wallet connection by calling the `connect` method. It returns wallet, connector, and connector data. The default connector order is Argent X, Braavos, Argent Mobile, and Argent Web Wallet. ```javascript const { wallet, connector, connectorData } = await connect() ``` -------------------------------- ### Import getStarknet from @starknet-io/get-starknet-core Source: https://www.starknetkit.com/docs/latest/connectors/metamask-snap Import the `getStarknet` function from the StarknetKit core package. This function is essential for initializing Starknet functionalities within your application when using starknet-react. ```javascript import { getStarknet } from "@starknet-io/get-starknet-core" ``` -------------------------------- ### Connect to Web Wallet using StarknetKit's connect function Source: https://www.starknetkit.com/docs/latest/connectors/web-wallet This example shows how to connect to the Web Wallet using StarknetKit's standalone `connect` function. It requires passing an array containing an instance of `WebWalletConnector` to the `connectors` argument. ```typescript const { wallet, connectorData } = await connect({ connectors: [ new WebWalletConnector(), ], }) ``` -------------------------------- ### Sign Typed Data with Starknet Wallet Source: https://www.starknetkit.com/docs/v2.3.2/getting-started/usage Illustrates how to sign typed data using the Starknet wallet via the `.request` method and the `wallet_signTypedData` type. This is essential for various dApp functionalities that require secure off-chain data signing. ```javascript await wallet.request({ type: "wallet_signTypedData", params: typedData, }) ``` -------------------------------- ### Wallet Request Methods in JavaScript Source: https://www.starknetkit.com/docs/latest/available-methods Demonstrates how to use the `.request` method of the StarknetKit wallet object to interact with various wallet functionalities. These examples cover requesting accounts, chain IDs, adding invoke transactions, and signing typed data. ```javascript await wallet.request({ type: "wallet_requestAccounts" }) // replaces .enable() await wallet.request({ type: "wallet_requestChainId" }) await wallet.request({ type: "wallet_addInvokeTransaction", params: { calls: [call], }, }) await wallet.request({ type: "wallet_signTypedData", params: typedData, }) ``` -------------------------------- ### Implement Starknet Wallet Connector with Starknet-react Source: https://www.starknetkit.com/docs/latest/connectors/metamask-snap A React component demonstrating how to connect and disconnect from Starknet wallets using starknet-react and StarknetKit. It fetches available connectors, displays connection status, and provides buttons for connecting and disconnecting. ```javascript 'use client'; import { useAccount, useConnect, useDisconnect } from '@starknet-react/core'; import { useMemo } from 'react'; import { getStarknet } from '@starknet-io/get-starknet-core'; export function WalletConnector() { const { disconnect } = useDisconnect(); const { connect, connectors } = useConnect(); const availableConnectors = useMemo( () => connectors.filter((connector) => connector.available), [connectors] ); getStarknet(); // Call this const { address } = useAccount(); if (!address) { return (
{availableConnectors.map((connector) => ( ))}
); } return (
Connected: {address?.slice(0, 6)}...{address?.slice(-4)}
); } ``` -------------------------------- ### Detect and Set Web Wallet Connection State Source: https://www.starknetkit.com/docs/v1.1.9/connectors/web-wallet This example shows how to attempt a connection using `connect` with `webWalletUrl` and then conditionally update the application state based on whether the wallet is connected. It sets the provider and address if a connection is established. ```javascript const connectWallet = async () => { const { wallet } = await connect({ webWalletUrl: "https://web.argent.xyz" }) if (wallet && wallet.isConnected) { setConnection(wallet) setProvider(wallet.account) setAddress(wallet.selectedAddress) } } ``` -------------------------------- ### Configure InjectedConnector with Options Source: https://www.starknetkit.com/docs/latest/connectors/injected This snippet illustrates how to configure the `InjectedConnector` with different options. It shows examples of creating a connector with just the `id`, and another with `id`, `name`, and `icon` for richer integration. The `id` is mandatory, while `name` and `icon` are optional for customizing the wallet's appearance in the connection interface. ```javascript // with id only new InjectedConnector({ options: { id: "argentX" }, }) new InjectedConnector({ options: { id: "braavos" }, }) // with id, name and icon new InjectedConnector({ options: { id: "argentX", name: "Ready Wallet (formerly Argent)", icon: "data:image/svg+xml;base64,PHN2ZyB3aWR0a....", }, }) new InjectedConnector({ options: { id: "braavos", name: "Braavos", icon: "data:image/svg+xml;base64,PHN2ZyB3aWR0a....", }, }) ``` -------------------------------- ### Add Metamask InjectedConnector to Starknet Providers Source: https://www.starknetkit.com/docs/latest/connectors/metamask-snap Configure StarknetKit providers to include the new Metamask InjectedConnector. This involves updating the `starknet-providers.tsx` file with the connector configurations for different wallets including MetaMask. ```typescript const connectors = [ new InjectedConnector({ options: { id: 'braavos', name: 'Braavos' } }), new InjectedConnector({ options: { id: 'argentX', name: 'Ready Wallet (formerly Argent)' } }), new InjectedConnector({ options: { id: 'metamask', name: 'MetaMask' } }), ]; ``` -------------------------------- ### Configure ArgentMobileConnector Initialization Parameters (JavaScript) Source: https://www.starknetkit.com/docs/v2.3.2/connectors/argent-mobile This snippet outlines the full set of parameters available for initializing the `ArgentMobileConnector`. It includes `dappName`, `projectId`, `chainId`, `url`, `icons`, `rpcUrl`, and optional `inAppBrowserOptions` for a comprehensive connection setup. ```javascript ArgentMobileConnector.init({ options: { dappName: "Dapp name", projectId: "YOUR_PROJECT_ID", // wallet connect project id chainId: "SN_MAIN", url: window.location.hostname, icons: ["https://your-icon-url.com"], rpcUrl: "YOUR_RPC_URL", }, inAppBrowserOptions: { // Optional - Used for Argent's in mobile app browser id: "wallet id", name: "wallet name", } }); ``` -------------------------------- ### Add Invoke Transaction to Starknet Wallet Source: https://www.starknetkit.com/docs/v2.3.2/getting-started/usage Provides an example of how to add an invoke transaction to the Starknet wallet using the `.request` method with the `wallet_addInvokeTransaction` type. This requires specifying the `calls` parameter, which defines the actions to be performed on the Starknet network. ```javascript await wallet.request({ type: "wallet_addInvokeTransaction", params: { calls: [call], }, }) ``` -------------------------------- ### ReadyConnector Initialization Parameters Source: https://www.starknetkit.com/docs/latest/connectors/ready Demonstrates the full set of parameters for initializing the ReadyConnector, including options for WalletConnect, chain ID, icons, and RPC URL. Also shows optional in-app browser settings. ```typescript ReadyConnector.init({ options: { dappName: "Dapp name", projectId: "YOUR_PROJECT_ID", // wallet connect project id chainId: "SN_MAIN", url: window.location.hostname, icons: ["https://your-icon-url.com"], rpcUrl: "YOUR_RPC_URL", }, inAppBrowserOptions: { // Optional - Used for Ready's in-app browser id: "wallet id", name: "wallet name", } }); ``` -------------------------------- ### Create a Starknet App with StarknetKit and Starknet-react Source: https://www.starknetkit.com/docs/v1.1.9/starknetkit-template This command bootstraps a Starknet dApp project using StarknetKit and includes starknet-react by default, facilitating easier contract interactions. The `[app-name]` parameter specifies the project's name. ```bash npx create-starknetkit-app [app-name] starknet-react ``` -------------------------------- ### Create a Basic Starknet App using StarknetKit Source: https://www.starknetkit.com/docs/v1.1.9/starknetkit-template This command initializes a new Starknet dApp project using the StarknetKit template with default connection settings. It leverages Next.js for building the application. ```bash npx create-starknetkit-app [app-name] ``` -------------------------------- ### Disconnect Wallet Source: https://www.starknetkit.com/docs/latest/getting-started/without-starknet-react Disconnects the currently connected wallet by calling the `disconnect` method. This action should typically be followed by resetting any state variables related to the wallet connection. ```javascript await disconnect() ``` -------------------------------- ### Initialize WebWalletConnector with URL Source: https://www.starknetkit.com/docs/v1.1.9/connectors/web-wallet Demonstrates how to instantiate the `WebWalletConnector` by providing the URL for the Web Wallet service. This is a core part of configuring the connector. ```javascript new WebWalletConnector({ url: "https://web.argent.xyz", }) ``` -------------------------------- ### Disconnect Wallet with Clear Last Wallet Option Source: https://www.starknetkit.com/docs/latest/getting-started/without-starknet-react Demonstrates how to call the `disconnect` method with the `clearLastWallet: true` option. This may clear stored wallet information, preventing automatic reconnection on next load. ```javascript await disconnect({ clearLastWallet: true }) ``` -------------------------------- ### Signer Instantiation Source: https://www.starknetkit.com/docs/v1.1.9/starknetjs-101/signer Demonstrates how to instantiate a Signer object using a keypair. ```APIDOC ## Signer Instantiation ### Description To instantiate a signer, you need a keypair. ### Method `new starknet.Signer(keyPair)` ### Endpoint N/A (Constructor) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **keyPair** (object) - Required - The keypair object to initialize the signer. ``` -------------------------------- ### Request Starknet Chain ID with StarknetKit Source: https://www.starknetkit.com/docs/v2.3.2/getting-started/usage Shows how to retrieve the current Starknet chain ID connected to the wallet using the `.request` method with the `wallet_requestChainId` type. This is crucial for ensuring your application interacts with the correct network. ```javascript await wallet.request({ type: "wallet_requestChainId" }) ``` -------------------------------- ### Contract Instantiation Source: https://www.starknetkit.com/docs/v1.1.9/starknetjs-101/contract Learn how to create and manage contract instances using Starknet.js. This includes initializing a contract with its ABI and address, attaching it to a different address, or connecting it to a new provider or account. ```APIDOC ## Contract Instantiation ### Description Instantiate a contract by providing its ABI, address, and a provider or account. ### Method `new starknet.Contract(abi, address, providerOrAccount)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **abi** (Abi) - The contract's ABI. * **address** (string) - The contract's address. * **providerOrAccount** (ProviderInterface | AccountInterface) - The provider or account to interact with the network. ### Request Example ```javascript const contract = new starknet.Contract(abi, address, providerOrAccount); ``` ### Response #### Success Response (200) * **Contract** - A new Contract instance. ### Response Example ```json { "contractInstance": "[Contract Object]" } ``` --- ## Contract Methods for Instance Management ### Description Methods to manage the contract instance's address and connection to a provider or account. ### Method `contract.attach(address)` ### Endpoint N/A (Method on Contract instance) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **address** (string) - The new address of the contract. ### Request Example ```javascript contract.attach("0x123..."); ``` ### Response #### Success Response (200) * **void** - No return value, modifies the contract instance in place. --- ### Method `contract.connect(providerOrAccount)` ### Endpoint N/A (Method on Contract instance) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **providerOrAccount** (ProviderInterface | AccountInterface) - The new provider or account to connect with. ### Request Example ```javascript contract.connect(newAccount); ``` ### Response #### Success Response (200) * **void** - No return value, modifies the contract instance in place. ``` -------------------------------- ### Reconnect to Previously Connected Wallet on Load Source: https://www.starknetkit.com/docs/latest/getting-started/without-starknet-react Attempts to reconnect to a previously connected wallet when the application loads, using the `connect` method with `modalMode: "neverAsk"` to avoid prompting the user if a wallet is already established. ```javascript const { wallet, connectorData } = await connect({ modalMode: "neverAsk" }) ``` -------------------------------- ### Import ReadyConnector and StarknetKitConnector Source: https://www.starknetkit.com/docs/latest/connectors/ready Imports necessary components from StarknetKit to enable the Ready connector. This is the first step before initializing the connector. ```typescript import { connect, disconnect } from "starknetkit" import { ReadyConnector, StarknetKitConnector } from "starknetkit/ready" ``` -------------------------------- ### Connect Wallet on Load with Never Ask Mode Source: https://www.starknetkit.com/docs/v2.3.2/getting-started/usage A useEffect hook that attempts to connect to a Starknet wallet on component mount using `modalMode: "neverAsk"`. If a connection is found and the wallet is connected, it updates the connection and address states. ```javascript useEffect(() => { const connectToStarknet = async () => { const { wallet, connectorData } = await connect({ modalMode: "neverAsk" }) if (wallet && wallet.isConnected) { setConnection(wallet) setAddress(wallet.selectedAddress) } } connectToStarknet() }, []) ``` -------------------------------- ### Instantiate Starknet.js Account Source: https://www.starknetkit.com/docs/v1.1.9/starknetjs-101/account Demonstrates how to instantiate an Account in Starknet.js. This requires a pre-deployed account contract, a provider instance, and the keypair for the account. The address property returns the account contract's address. ```javascript const account = new starknet.Account(Provider, address, starkKeyPair); console.log(account.address); ``` -------------------------------- ### Instantiate Starknet.js Contract Source: https://www.starknetkit.com/docs/v1.1.9/starknetjs-101/contract Demonstrates how to create a new contract instance using the Starknet.js library. This requires the contract's ABI, its address on the StarkNet network, and either a provider or an account object for interaction. ```javascript new starknet.Contract(abi, address, providerOrAccount) ``` -------------------------------- ### Import StarknetConfig and publicProvider Source: https://www.starknetkit.com/docs/latest/getting-started/usage Import the necessary components, `StarknetConfig` and `publicProvider`, from the StarknetKit library. These are essential for configuring the Starknet provider in your dApp. ```javascript import { StarknetConfig, publicProvider } from "@starknet-react/core" import { InjectedConnector } from "starknetkit/injected" ``` -------------------------------- ### Get Starknet Block Hash and Number with provider.getBlockHashAndNumber Source: https://www.starknetkit.com/docs/v1.1.9/starknetjs-101/provider Fetches the hash and number of the latest Starknet block. This is a quick way to get the current state of the blockchain. The response includes `block_hash` and `block_number`. ```typescript provider.getBlockHashAndNumber() => Promise ``` -------------------------------- ### Import Starknet Configuration Components Source: https://www.starknetkit.com/docs/v1.1.9/starknetkit-with-starknet-react Imports essential components for configuring StarknetKit with Starknet-react, including various wallet connectors, chains, and the StarknetConfig provider. ```javascript import { InjectedConnector } from "starknetkit/injected"; import { ArgentMobileConnector } from "starknetkit/argentMobile"; import { WebWalletConnector } from "starknetkit/webwallet"; import { mainnet, sepolia } from "@starknet-react/chains"; import { StarknetConfig, publicProvider } from "@starknet-react/core"; ``` -------------------------------- ### Starknet.js Provider Methods: Get Nonce Source: https://www.starknetkit.com/docs/v1.1.9/starknetjs-101/provider Retrieves the nonce for a given 'contractAddress' at a specific optional 'blockIdentifier'. The nonce is a BigNumberish value. ```javascript provider.getNonce(contractAddress, blockIdentifier) ``` -------------------------------- ### Starknet.js Provider Methods: Get Class at Contract Source: https://www.starknetkit.com/docs/v1.1.9/starknetjs-101/provider Fetches the contract class of a deployed contract at a specific 'contractAddress' and optional 'blockIdentifier'. ```javascript provider.getClassAt(contractAddress, blockIdentifier) ``` -------------------------------- ### Import WebWalletConnector and Connect in StarknetKit Source: https://www.starknetkit.com/docs/v1.1.9/connectors/web-wallet This snippet shows how to import the necessary functions and the WebWalletConnector from StarknetKit and then use the `connect` method to establish a connection. It requires the `starknetkit` library. ```javascript import { connect, disconnect } from "starknetkit" import { WebWalletConnector } from "starknetkit/webwallet" const { wallet } = await connect({ connectors: [ new WebWalletConnector({ url: "https://web.argent.xyz", }), ], }) ``` -------------------------------- ### account.getSuggestedMaxFee Source: https://www.starknetkit.com/docs/v1.1.9/starknetjs-101/account Gets the suggested maximum fee based on the transaction type. The `details` object may include `blockIdentifier` and `nonce`. ```APIDOC ## account.getSuggestedMaxFee ### Description Gets Suggested Max Fee based on the transaction type. ### Method POST ### Endpoint /account/getSuggestedMaxFee ### Parameters #### Request Body - **estimateFeeAction** (object) - Required - The action for which to estimate the fee. - **type** (string) - The type of transaction (e.g., 'DEPLOY', 'INVOKE'). - **details** (object) - Optional - Additional details for fee estimation. - **blockIdentifier** (object) - Optional - Specifies the block for estimation. - **nonce** (string) - Optional - The nonce for the transaction. ### Response #### Success Response (200) - **maxFee** (BigNumberish) - The suggested maximum fee. #### Response Example { "maxFee": "100000000000000" } ``` -------------------------------- ### Starknet.js Provider Methods: Get Transaction Source: https://www.starknetkit.com/docs/v1.1.9/starknetjs-101/provider Fetches detailed information about a transaction using its 'txHash'. This includes fields like 'transaction_hash', 'version', and 'signature'. ```javascript provider.getTransaction(txHash) ``` -------------------------------- ### Initialize ReadyConnector with Project ID Source: https://www.starknetkit.com/docs/latest/connectors/ready Initializes the ReadyConnector, including a WalletConnect projectId for dApp-specific identification. This enhances security and personalization when connecting. ```typescript const { wallet, connectorData } = await connect({ connectors: [ ReadyConnector.init({ options: { dappName: 'Dapp name', url: window.location.hostname, projectId: "d7615***" } }) as StarknetkitConnector, ], }) ``` -------------------------------- ### Get Starknet Contract Class Definition with provider.getClass Source: https://www.starknetkit.com/docs/v1.1.9/starknetjs-101/provider Retrieves the definition of a Starknet contract class using its hash. Requires `classHash` and returns a Promise for `ContractClass`. ```typescript provider.getClass(classHash) => Promise ``` -------------------------------- ### Get Starknet Nonce with provider.getNonce Source: https://www.starknetkit.com/docs/v1.1.9/starknetjs-101/provider Retrieves the nonce for a given Starknet contract address at a specific block. Requires `contractAddress` and `blockIdentifier`, returning a Promise for `BigNumberish`. ```typescript provider.getNonce(contractAddress, blockIdentifier) => Promise ``` -------------------------------- ### Get Starknet Contract Class Hash at Block with provider.getClassHashAt Source: https://www.starknetkit.com/docs/v1.1.9/starknetjs-101/provider Fetches the class hash of a contract at a specific block. It requires a `blockIdentifier` and returns a Promise for `ContractAddress`. ```typescript provider.getClassHashAt(blockIdentifier) => Promise ``` -------------------------------- ### Standalone ReadyConnector Initialization Source: https://www.starknetkit.com/docs/latest/connectors/ready Initializes the ReadyConnector for standalone use, determining whether to use the connector for the in-app browser or a list of other connectors for external use. Includes imports for `isInReadyAppBrowser`. ```typescript import { isInReadyAppBrowser, ReadyConnector, } from "starknetkit/ready" const Ready = ReadyConnector.init({ options: { dappName: "Dapp name", icons: ["https://your-icon-url.com"], projectId: "YOUR_WALLETCONNECT_PROJECT_ID", }, inAppBrowserOptions: {}, // Optional - Used for Ready's in-app browser }) export const connectors = isInReadyAppBrowser() ? Ready : [ new InjectedConnector({ options: { id: "argentX", name: "Ready Wallet (formerly Argent)" } }), new InjectedConnector({ options: { id: "braavos" } }), Ready, ] ``` -------------------------------- ### Instantiate Starknet.js Provider with Options Source: https://www.starknetkit.com/docs/v1.1.9/starknetjs-101/provider Instantiates a Starknet.js Provider, allowing for custom configurations through an options object. The 'rpc' option can be used for RPC provider configurations. ```javascript new starknet.Provider(optionsOrProvider) ``` -------------------------------- ### Starknet.js Provider Methods: Get Transaction Receipt Source: https://www.starknetkit.com/docs/v1.1.9/starknetjs-101/provider Retrieves the status and details of a transaction using its 'txHash'. The response includes 'transaction_hash', 'status', and optional 'actual_fee'. ```javascript provider.getTransactionReceipt(txHash) ``` -------------------------------- ### Contract Deployment and Interaction Source: https://www.starknetkit.com/docs/v1.1.9/starknetjs-101/provider Methods for deploying contracts, calling contract functions, and retrieving contract class information. ```APIDOC ## POST /declare ### Description Declares a contract class to the StarkNet network. ### Method POST ### Endpoint /declare ### Parameters #### Request Body - **DeclareContractTransaction** (object) - Required - Details of the contract declaration. - **details** (object) - Optional - Additional details for the declaration. ### Response #### Success Response (200) - **transaction_hash** (string) - The hash of the declaration transaction. - **class_hash** (string) - The hash of the declared contract class. ### Response Example ```json { "transaction_hash": "0x123...", "class_hash": "0xabc..." } ``` ``` ```APIDOC ## POST /deploy ### Description Deploys a contract to the StarkNet network. ### Method POST ### Endpoint /deploy ### Parameters #### Request Body - **contract** (object) - Required - Contract definition. - **constructorCalldata** (array) - Optional - Calldata for the constructor. - **addressSalt** (string) - Optional - Salt for the contract address. ### Response #### Success Response (200) - **contract_address** (string) - The deployed contract address. - **transaction_hash** (string) - The hash of the deployment transaction. ### Response Example ```json { "contract_address": "0x456...", "transaction_hash": "0x789..." } ``` ``` ```APIDOC ## POST /call ### Description Calls a contract function without executing a transaction (view call). ### Method POST ### Endpoint /call ### Parameters #### Request Body - **call** (object) - Required - Details of the contract call. - **blockIdentifier** (object) - Optional - Identifier for the block. Defaults to 'latest'. ### Response #### Success Response (200) - **result** (CallContractResponse) - The result of the contract call. ### Response Example ```json { "result": [ "0x1", "0x2" ] } ``` ``` ```APIDOC ## GET /class ### Description Retrieves the contract class definition by its hash. ### Method GET ### Endpoint /class ### Parameters #### Query Parameters - **classHash** (string) - Required - The hash of the contract class. ### Response #### Success Response (200) - **contractClass** (ContractClass) - The definition of the contract class. ### Response Example ```json { "contractClass": { "program": "...", "entry_points_by_type": {} } } ``` ``` -------------------------------- ### Starknet.js Provider Methods: Get Block Source: https://www.starknetkit.com/docs/v1.1.9/starknetjs-101/provider Retrieves block information for a given 'blockIdentifier'. The response contains details such as 'accepted_time', 'block_hash', 'block_number', and transaction information. ```javascript provider.getBlock(blockIdentifier) ``` -------------------------------- ### Starknet.js Provider Methods: Get Chain ID Source: https://www.starknetkit.com/docs/v1.1.9/starknetjs-101/provider Retrieves the current chain ID for the network the Provider is connected to. This method returns a Promise that resolves to a StarknetChainId. ```javascript provider.getChainId() ``` -------------------------------- ### Import WebWalletConnector from StarknetKit Source: https://www.starknetkit.com/docs/latest/connectors/web-wallet To use the Web Wallet connector, you must first import the `WebWalletConnector` class from the 'starknetkit/webwallet' module. This is the initial step before configuring and using the connector. ```typescript import { WebWalletConnector } from "starknetkit/webwallet" ``` -------------------------------- ### Define StarknetKit Connectors Source: https://www.starknetkit.com/docs/latest/getting-started/usage Define an array of StarknetKit connectors, replacing Starknet-React's default connectors. This example shows how to configure connectors for ArgentX and Braavos wallets. ```javascript const connectors = [ new InjectedConnector({ options: { id: "argentX", name: "Ready Wallet (formerly Argent)" }, }), new InjectedConnector({ options: { id: "braavos", name: "Braavos" }, }) ] ``` -------------------------------- ### Import StarknetKit and InjectedConnector Source: https://www.starknetkit.com/docs/latest/connectors/injected This code snippet demonstrates how to import the necessary functions and the `InjectedConnector` class from the StarknetKit library. These are essential for establishing a connection with a wallet. ```javascript import { connect, disconnect } from "starknetkit" import { InjectedConnector } from "starknetkit/injected" ``` -------------------------------- ### Get Starknet Transaction Count with provider.getTransactionCount Source: https://www.starknetkit.com/docs/v1.1.9/starknetjs-101/provider Retrieves the total number of transactions within a specific Starknet block. Takes a `blockIdentifier` and returns a Promise resolving to a number. ```typescript provider.getTransactionCount(blockIdentifier) => Promise ``` -------------------------------- ### Get Starknet Chain ID with provider.getChainId Source: https://www.starknetkit.com/docs/v1.1.9/starknetjs-101/provider Retrieves the current Starknet chain ID. This method returns a Promise that resolves with the chain ID, typically a number or string. ```typescript provider.getChainId() => Promise ``` -------------------------------- ### Import StarknetKit and WebWalletConnector Source: https://www.starknetkit.com/docs/v2.3.2/connectors/web-wallet This snippet shows how to import the necessary functions from starknetkit and the specific connector for the Web Wallet. These are the foundational imports required to initiate a connection. ```typescript import { connect, disconnect } from "starknetkit" import { WebWalletConnector } from "starknetkit/webwallet" ``` -------------------------------- ### Get Starknet Syncing Status with provider.getSyncingStats Source: https://www.starknetkit.com/docs/v1.1.9/starknetjs-101/provider Checks the synchronization status of the Starknet node. Returns a Promise that resolves to a boolean (if not syncing) or a `GetSyncingStatsResponse` object detailing the syncing progress. ```typescript provider.getSyncingStats() => Promise ``` -------------------------------- ### Get Starknet Transaction by Block ID and Index with provider.getTransactionByBlockIdAndIndex Source: https://www.starknetkit.com/docs/v1.1.9/starknetjs-101/provider Retrieves a specific Starknet transaction from a block based on its index. Requires `blockIdentifier` and `index`, returning a Promise for `GetTransactionByBlockIdAndIndex`. ```typescript provider.getTransactionByBlockIdAndIndex(blockIdentifier, index) => Promise ``` -------------------------------- ### Instantiate WebWalletConnector with URL parameter Source: https://www.starknetkit.com/docs/latest/connectors/web-wallet The `WebWalletConnector` accepts an optional `url` parameter to specify the Web Wallet's base URL. This allows you to point to different instances, such as the testnet URL provided. ```typescript new WebWalletConnector({ url: "https://web.ready.co", }) ``` -------------------------------- ### Get Starknet Storage Value with provider.getStorageAt Source: https://www.starknetkit.com/docs/v1.1.9/starknetjs-101/provider Retrieves the value of a storage slot for a Starknet contract at a specific block. Requires `contractAddress`, `key`, and `blockIdentifier`, returning a Promise for `BigNumberish`. ```typescript provider.getStorageAt(contractAddress, key, blockIdentifier) => Promise ``` -------------------------------- ### Connect to Web Wallet using starknet-react Source: https://www.starknetkit.com/docs/latest/connectors/web-wallet This snippet demonstrates how to connect to the Web Wallet using the `useConnect` hook from starknet-react. It involves creating an instance of `WebWalletConnector` with a specified URL and passing it to the `connect` function. ```typescript const { connect } = useConnect(); const handleConnect = async () => { connect({ connector: new WebWalletConnector({ url: 'https://web.ready.co', }), }); }; ```