### Quick Start: Emulator Fork Setup Source: https://github.com/onflow/docs/blob/main/docs/build/tools/flow-cli/fork-testing.md Steps to initialize a Flow project, install dependencies, start a forked emulator, and execute scripts against the forked network. ```bash flow init ``` ```bash flow dependencies install FlowToken FungibleToken ``` ```bash flow emulator --fork mainnet ``` ```bash flow scripts execute myScript.cdc --network mainnet-fork ``` -------------------------------- ### Set up RainbowKit environment Source: https://github.com/onflow/docs/blob/main/docs/blockchain-development-tutorials/evm/frameworks/rainbowkit.md Install the necessary RainbowKit dependencies and start the development server. This is the initial setup for a new RainbowKit project. ```bash $ npm init @rainbow-me/rainbowkit@latest $ cd my-rainbowkit-app $ npm run dev ``` -------------------------------- ### Complete Flow Project Setup Example in Go Source: https://github.com/onflow/docs/blob/main/docs/build/tools/clients/flow-go-sdk/flowkit.md A full example demonstrating Flowkit's capabilities, including loading project state, selecting a network, fetching deployment contracts, resolving imports in Cadence scripts, and retrieving account information for signing. This requires a 'flow.json' configuration file and appropriate network setup. ```go package main import ( "log" "github.com/onflow/flowkit/v2" "github.com/onflow/flowkit/v2/config" "github.com/onflow/flowkit/v2/project" "github.com/spf13/afero" ) func main() { // 1. Load project state state, err := flowkit.Load([]string{"flow.json"}, afero.Afero{Fs: afero.NewOsFs()}) if err != nil { log.Fatalf("Failed to load state: %v", err) } // 2. Choose target network network := config.TestnetNetwork log.Printf("Using network: %s\n", network.Name) // 3. Get deployment contracts for the network contracts, err := state.DeploymentContractsByNetwork(network) if err != nil { log.Fatalf("Failed to get contracts: %v", err) } log.Printf("Found %d contracts for deployment\n", len(contracts)) for _, contract := range contracts { log.Printf(" - %s -> %s\n", contract.Name, contract.AccountAddress) } // 4. Get network aliases aliases := state.AliasesForNetwork(network) log.Printf("Network has %d aliases\n", len(aliases)) // 5. Create import replacer importReplacer := project.NewImportReplacer(contracts, aliases) // 6. Resolve imports in a script scriptCode := []byte(` import "Kibble" import "FungibleToken" access(all) fun main(): String { return "Hello, Flow!" } `) program, err := project.NewProgram(scriptCode, nil, "script.cdc") if err != nil { log.Fatalf("Failed to parse program: %v", err) } resolvedProgram, err := importReplacer.Replace(program) if err != nil { log.Fatalf("Failed to resolve imports: %v", err) } log.Printf("Resolved script:\n%s\n", string(resolvedProgram.Code())) // 7. Get account for signing account, err := state.Accounts().ByName("testnet-account") if err != nil { log.Fatalf("Failed to get account: %v", err) } log.Printf("Using account: %s (%s)\n", account.Name, account.Address) log.Println("Setup complete! Ready to interact with Flow.") } ``` -------------------------------- ### Install Dependencies and Run Project Source: https://github.com/onflow/docs/blob/main/docs/blockchain-development-tutorials/cadence/account-management/account-linking-with-dapper.md Install project dependencies using Yarn and start the development server. Ensure you have Node.js and Yarn installed. ```zsh yarn install yarn run dev ``` -------------------------------- ### Machine Account Setup Output and Directory Structure Source: https://github.com/onflow/docs/blob/main/docs/protocol/node-ops/node-operation/node-bootstrap.md This example shows the output after running the machine account setup command and the resulting directory structure, including the generated `node-machine-account-info.priv.json` file. ```shell $ ./boot-tools/bootstrap machine-account --address 0x1de23de44985c7e7 -o ./bootstrap INF read machine account private key json DBG encoded public machine account key machineAccountPubKey=2743786d1ff1bf7d7026d693a774210eaa54728343859baab62e2df7f71a370651f4c7fd239d07af170e484eedd4f3c2df47103f6c39baf2eb2a50f67bbcba6a INF wrote file bootstrap/private-root-information/private-node-info_6f6e98c983dbd9aa69320452949b81abeab2ac591a247f55f19f4dbf0b477d26/node-machine-account-info.priv.json $tree ./bootstrap/ ./bootstrap ├── private-root-information │ └── private-node-info_d60bd55ee616c5c297cae1d5cfb7f65e7e04014d9c4abe595af2fd83f3cfe160 │ ├── node-info.priv.json │ ├── node-machine-account-info.priv.json │ ├── node-machine-account-key.priv.json │ └── secretsdb-key └── public-root-information ├── node-id └── node-info.pub.d60bd55ee616c5c297cae1d5cfb7f65e7e04014d9c4abe595af2fd83f3cfe160.json 3 directories, 5 files ``` -------------------------------- ### Usage Example Source: https://github.com/onflow/docs/blob/main/docs/build/tools/clients/fcl-js/cross-vm/rainbowkit-adapter.mdx A typical usage example demonstrating the setup of a RainbowKit configuration for the Flow testnet using the FCL adapter. ```APIDOC ## Usage Below is a typical usage example that shows how to set up a **RainbowKit** config for the Flow testnet, using this adapter. (From your provided sample.) ```ts import * as fcl from '@onflow/fcl' import { createFclConnector, flowWallet, useIsCadenceWalletConnected } from '@onflow/fcl-rainbowkit-adapter' import { connectorsForWallets } from '@rainbow-me/rainbowkit' import { flowTestnet } from 'wagmi/chains' import { createConfig, http } from 'wagmi' // Configure FCL (Flow testnet in this example) fcl.config({ "accessNode.api": "https://rest-testnet.onflow.org", "discovery.wallet": "https://fcl-discovery.onflow.org/testnet/authn", "walletconnect.projectId": "9b70cfa398b2355a5eb9b1cf99f4a981", // example WC projectId }) // Create a list of connectors from your wallets const connectors = connectorsForWallets([ { groupName: "Recommended", wallets: [ flowWallet(), ], }, ], { appName: 'RainbowKit demo', projectId: '9b70cfa398b2355a5eb9b1cf99f4a981', }) // Wagmi config export const config = createConfig({ chains: [flowTestnet], connectors, ssr: true, transports: { [flowTestnet.id]: http(), } }); // In your React component function MyApp() { const isCadenceConnected = useIsCadenceWalletConnected(config) return (
{isCadenceConnected ? (

Cadence wallet is connected!

) : (

Please connect your Cadence wallet

)}
) } ``` ``` -------------------------------- ### Start Claude CLI Source: https://github.com/onflow/docs/blob/main/docs/blockchain-development-tutorials/use-AI-to-build-on-flow/llms/claude-code.md Navigate to your project directory and start the Claude CLI. This action automatically installs the necessary extensions for IDE integration. ```bash cd your-awesome-project claude ``` -------------------------------- ### Verbose Logging Example Source: https://github.com/onflow/docs/blob/main/docs/build/tools/emulator/index.md Starts the Flow Emulator with verbose logging enabled for more detailed output. ```bash flow emulator --verbose ``` -------------------------------- ### Example: Get Collection with Host Source: https://github.com/onflow/docs/blob/main/docs/build/tools/flow-cli/get-flow-data/get-collections.md An example of fetching a collection from the mainnet. This command specifies the collection ID and the host to connect to. Ensure the collection ID is valid and the host is accessible. ```shell flow collections get 3e694588e789a72489667a36dd73104dea4579bcd400959d47aedccd7f930eeb \ --host access.mainnet.nodes.onflow.org:9000 ``` -------------------------------- ### Install Dependencies Source: https://github.com/onflow/docs/blob/main/README.md Run this command to install all necessary project dependencies. ```bash yarn ``` -------------------------------- ### Install Dependencies Source: https://github.com/onflow/docs/blob/main/docs/blockchain-development-tutorials/evm/frameworks/wagmi.md Navigate to the created project directory and install the necessary npm packages. ```bash cd flow-evm-wagmi npm install ``` -------------------------------- ### Install Foundry Source: https://github.com/onflow/docs/blob/main/docs/blockchain-development-tutorials/evm/development-tools/foundry.md Install Foundry using the `foundryup` CLI tool. ```shell curl -L https://foundry.paradigm.xyz | bash ``` ```shell foundryup ``` -------------------------------- ### Install Dependencies with bun Source: https://github.com/onflow/docs/blob/main/docs/blockchain-development-tutorials/integrations/gelato-sw.md Install the necessary Gelato Smart Wallet and viem packages using bun. ```bash bun add @gelatonetwork/smartwallet viem ``` -------------------------------- ### Install Dependencies with Bun Source: https://github.com/onflow/docs/blob/main/docs/blockchain-development-tutorials/use-AI-to-build-on-flow/mcp/contribute-to-mcp.md Install all project dependencies using Bun. ```bash bun install ``` -------------------------------- ### Install Web3.js Source: https://github.com/onflow/docs/blob/main/docs/blockchain-development-tutorials/evm/frameworks/web3-js.md Install the web3 library using npm. This is a prerequisite for using Web3.js in your project. ```sh npm install web3 ``` -------------------------------- ### Install Dependencies with npm Source: https://github.com/onflow/docs/blob/main/docs/blockchain-development-tutorials/integrations/gelato-sw.md Install the necessary Gelato Smart Wallet and viem packages using npm. ```bash npm install @gelatonetwork/smartwallet viem ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/onflow/docs/blob/main/docs/blockchain-development-tutorials/use-AI-to-build-on-flow/agents/agentkit-flow-guide.md Navigate to your project directory and install necessary npm packages. ```bash cd onchain-agent npm install ``` -------------------------------- ### Installation Source: https://github.com/onflow/docs/blob/main/docs/build/tools/clients/fcl-js/cross-vm/rainbowkit-adapter.mdx Install the FCL Rainbowkit Adapter package using npm. ```APIDOC ## Installation ```bash npm install @onflow/fcl-rainbowkit-adapter ``` ``` -------------------------------- ### Install Dependencies with pnpm Source: https://github.com/onflow/docs/blob/main/docs/blockchain-development-tutorials/integrations/gelato-sw.md Install the necessary Gelato Smart Wallet and viem packages using pnpm. ```bash pnpm add @gelatonetwork/smartwallet viem ``` -------------------------------- ### Install Dependencies with yarn Source: https://github.com/onflow/docs/blob/main/docs/blockchain-development-tutorials/integrations/gelato-sw.md Install the necessary Gelato Smart Wallet and viem packages using yarn. ```bash yarn add @gelatonetwork/smartwallet viem ``` -------------------------------- ### Get ETH/USD Price Example Source: https://github.com/onflow/docs/blob/main/docs/defi/band-oracle.md Example of how to get the ETH price in USD. Ensure `flowPayment` is defined and contains the necessary payment. ```cadence // Get ETH price in USD let priceData = BandOracle.getReferenceData( baseSymbol: "ETH", quoteSymbol: "USD", payment: <- flowPayment ) // priceData.fixedPointRate contains ETH price in USD ``` -------------------------------- ### Install Flow CLI Source: https://github.com/onflow/docs/blob/main/docs/blockchain-development-tutorials/cadence/getting-started/cadence-environment-setup.md Installs the Flow Command Line Interface using Homebrew. For other operating systems, consult the installation guide. ```zsh brew install flow-cli ``` -------------------------------- ### Bootstrap Immediately with Most Recent Root Snapshot Source: https://github.com/onflow/docs/blob/main/docs/protocol/node-ops/node-operation/protocol-state-bootstrap.md This example shows how to use Dynamic Startup to bootstrap your node immediately with the most recent Root Snapshot. This involves specifying a past epoch counter and ensuring the database is not already bootstrapped. ```sh ... \ --dynamic-startup-access-address=secure.mainnet.nodes.onflow.org:9001 \ --dynamic-startup-access-publickey=28a0d9edd0de3f15866dfe4aea1560c4504fe313fc6ca3f63a63e4f98d0e295144692a58ebe7f7894349198613f65b2d960abf99ec2625e247b1c78ba5bf2eae \ --dynamic-startup-epoch=1 ``` -------------------------------- ### Start Flow Emulator and Deploy Dependencies Source: https://github.com/onflow/docs/blob/main/docs/blockchain-development-tutorials/forte/flow-actions/flow-actions-transaction.md Initiates the Flow emulator, deploys necessary dependencies, creates test tokens, and sets up the initial liquidity and staking pools. ```bash make start ``` -------------------------------- ### Install Specific Flow CLI Version Source: https://github.com/onflow/docs/blob/main/docs/build/tools/flow-cli/install.md Installs a specific version of the Flow CLI by appending the version tag to the installation command. This example shows how to install version v2.0.0. ```sh sudo sh -ci "$(curl -fsSL https://raw.githubusercontent.com/onflow/flow-cli/master/install.sh)" -- v2.0.0 ``` -------------------------------- ### Quickstart Deployment Command Source: https://github.com/onflow/docs/blob/main/docs/build/evm/quickstart.md Use this command to quickly deploy the Button Clicker Contract if you have forked the repository and set up your .env file. ```bash npx hardhat ignition deploy ./ignition/modules/ClickToken.ts --network flowTestnet ``` -------------------------------- ### Start Development Server Source: https://github.com/onflow/docs/blob/main/docs/blockchain-development-tutorials/cadence/getting-started/building-a-frontend-app.md Run this command in your project's root directory to start the development server. ```bash npm run dev ``` -------------------------------- ### Cross-Currency Conversion Example Source: https://github.com/onflow/docs/blob/main/docs/defi/band-oracle.md Example demonstrating how to get the EUR price in JPY. Ensure `flowPayment` is defined and contains the necessary payment. ```cadence // Get EUR price in JPY let priceData = BandOracle.getReferenceData( baseSymbol: "EUR", quoteSymbol: "JPY", payment: <- flowPayment ) // priceData.fixedPointRate contains EUR/JPY exchange rate ``` -------------------------------- ### Create .env File Source: https://github.com/onflow/docs/blob/main/docs/blockchain-development-tutorials/use-AI-to-build-on-flow/agents/eliza/index.md Copy the example environment file to `.env` and populate it with your specific configuration values. This file is crucial for protecting sensitive information like API keys. ```bash cp .env.example .env ``` -------------------------------- ### Installation and Importing Source: https://github.com/onflow/docs/blob/main/docs/build/tools/clients/flow-go-sdk/index.md Instructions on how to install the Flow Go SDK using Go modules and how to import the library into your Go project. ```APIDOC ## Installation The recommended way to install Go Flow SDK is by using Go modules. ```sh go get github.com/onflow/flow-go-sdk ``` ## Importing the Library After the library has been installed you can import it. ```go import "github.com/onflow/flow-go-sdk" ``` ``` -------------------------------- ### Example: Get Specific System Transaction by ID Source: https://github.com/onflow/docs/blob/main/docs/build/tools/flow-cli/transactions/get-system-transactions.md This example shows how to retrieve a specific system transaction from the latest block on mainnet by providing its transaction ID. ```shell > flow transactions get-system latest 07a8...b433 --network mainnet ``` -------------------------------- ### Importing the get function from @onflow/sdk Source: https://github.com/onflow/docs/blob/main/docs/build/tools/clients/fcl-js/packages-docs/sdk/get.md Demonstrates two ways to import the get function: importing the entire SDK or importing the function directly. Ensure the SDK is installed. ```typescript import * as sdk from "@onflow/sdk" sdk.get(ix, key, fallback) ``` ```typescript import { get } from "@onflow/sdk" get(ix, key, fallback) ``` -------------------------------- ### Example Account Retrieval Source: https://github.com/onflow/docs/blob/main/docs/build/tools/flow-cli/accounts/get-accounts.md This is an example of how to use the `flow accounts get` command with a specific account address. The output includes details like balance, keys, and deployed contracts. ```shell flow accounts get 0xf8d6e0586b0a20c7 ``` -------------------------------- ### Bootstrap Immediately with Dynamic Startup Source: https://github.com/onflow/docs/blob/main/docs/protocol/node-ops/node-operation/protocol-state-bootstrap.md To bootstrap immediately using the first available Root Snapshot, specify a past epoch counter. The `--dynamic-startup-epoch-phase` flag can be omitted in this case. ```shell ... \ --dynamic-startup-epoch-phase=1 ``` -------------------------------- ### Using the get function with interaction objects Source: https://github.com/onflow/docs/blob/main/docs/build/tools/clients/fcl-js/packages-docs/sdk/get.md Shows how to initialize an interaction, set values using put, and then retrieve them using get. Includes examples for direct and fallback retrieval, as well as nested properties. Requires importing get, put, and initInteraction. ```typescript import { get, put, initInteraction } from "@onflow/sdk" const interaction = initInteraction(); // Set a value first put("user.name", "Alice")(interaction); // Get the value const userName = get(interaction, "user.name"); // "Alice" const userAge = get(interaction, "user.age", 25); // 25 (fallback) // Get nested values put("config.network.url", "https://access.mainnet.onflow.org")(interaction); const networkUrl = get(interaction, "config.network.url"); ``` -------------------------------- ### Install ExampleNFT Contract Dependency Source: https://github.com/onflow/docs/blob/main/docs/blockchain-development-tutorials/cadence/cadence-advantages/compose-with-cadence-transactions.md Use this command to add the ExampleNFT contract as a dependency for your project. Ensure no conflicting core contract dependencies are present in your flow.json. ```bash flow dependencies install testnet://012e4d204a60ac6f.ExampleNFT ``` -------------------------------- ### Initialize gRPC Emulator Client (Previous Versions) Source: https://github.com/onflow/docs/blob/main/docs/build/tools/clients/flow-go-sdk/migration-v0.25.0.md Example of initializing a gRPC emulator client in versions prior to 0.25.0. ```go flowClient, err := client.New("127.0.0.1:3569", grpc.WithInsecure()) ``` -------------------------------- ### Initialize a Flow Project Source: https://github.com/onflow/docs/blob/main/docs/build/tools/flow-cli/commands.md Starts a new Flow project. Creates configuration files, directory structures, and sets up emulator accounts. Use `--config-only` for configuration only, `--global` for global configuration, or `--service-private-key` for a custom service account. ```bash flow init my-project ``` ```bash flow init --config-only ``` ```bash flow init --global ``` ```bash flow init --service-private-key ``` -------------------------------- ### Example: Get Latest System Transaction on Mainnet Source: https://github.com/onflow/docs/blob/main/docs/build/tools/flow-cli/transactions/get-system-transactions.md This example demonstrates fetching the latest system transaction from the mainnet. The output includes transaction status, ID, events, and hidden code/payload sections. ```shell > flow transactions get-system latest --network mainnet Status ✅ SEALED ID 40bc4b100c1930c61381c22e0f4c10a7f5827975ee25715527c1061b8d71e5aa Payer — Authorizers [] Proposal Key: — No Payload Signatures No Envelope Signatures Events: Index 0 Type A.1654653399040a61.FlowToken.TokensDeposited Tx ID 40bc4b100c1930c61381c22e0f4c10a7f5827975ee25715527c1061b8d71e5aa Values - amount (UFix64): 0.00100000 - to ({}?): 5068e27f275c546c Code (hidden, use --include code) Payload (hidden, use --include payload) ``` -------------------------------- ### Flow Emulator Default Output Source: https://github.com/onflow/docs/blob/main/docs/build/tools/emulator/index.md Example output when starting the Flow Emulator, showing service account, gRPC, and HTTP server details. ```text INFO[0000] ⚙️ Using service account 0xf8d6e0586b0a20c7 serviceAddress=f8d6e0586b0a20c7 ... INFO[0000] 🌱 Starting Flow Emulator INFO[0000] 🛠 GRPC server started on 127.0.0.1:3569 INFO[0000] 📡 HTTP server started on 127.0.0.1:8080 ``` -------------------------------- ### Use gRPC Client with Options (Previous Versions) Source: https://github.com/onflow/docs/blob/main/docs/build/tools/clients/flow-go-sdk/migration-v0.25.0.md Shows how to initialize a gRPC emulator client and call GetLatestBlock with additional options in previous versions. ```go // initialize a gRPC emulator client flowClient, err := client.New("127.0.0.1:3569", grpc.WithInsecure()) latestBlock, err := flowClient.GetLatestBlock(ctx, true, MaxCallSendMsgSize(100)) ``` -------------------------------- ### Start Local Development Server Source: https://github.com/onflow/docs/blob/main/README.md Starts a local server for live development. Changes are reflected without a server restart. ```bash yarn start ``` -------------------------------- ### Flow CLI Configuration Help Command Source: https://github.com/onflow/docs/blob/main/docs/blockchain-development-tutorials/use-AI-to-build-on-flow/cursor/cadence-rules.md Example of how to use the Flow CLI to get help configuring flow.json for a specific network deployment. ```bash @flow-project-config help me configure my flow.json for testnet deployment ``` -------------------------------- ### Example Subscribe Request Source: https://github.com/onflow/docs/blob/main/docs/protocol/access-onchain-data/websockets-stream-api/subscribe-message.md Use this JSON structure to initiate a subscription to a topic. Include a topic and optional arguments like start block height. ```json { "subscription_id": "some-id-1", "action": "subscribe", "topic": "block_digests", "arguments": { "block_status": "finalized", "start_block_height": "99416580" } } ``` -------------------------------- ### Create Dummy Key File Source: https://github.com/onflow/docs/blob/main/docs/blockchain-development-tutorials/cadence/emulator-fork-testing/index.md Create a placeholder key file for the service account when using a forked emulator. This is a P-256 placeholder. ```bash echo "0x0000000000000000000000000000000000000000000000000000000000000001" > blank-key.pkey ``` -------------------------------- ### Example flow.json Dependency Entry Source: https://github.com/onflow/docs/blob/main/docs/build/tools/flow-cli/dependency-manager.md Illustrates how a dependency is represented in the `flow.json` configuration file after being installed. It includes the source and optional aliases for different environments. ```json { "dependencies": { "FlowToken": { "source": "testnet://7e60df042a9c0868.FlowToken", "aliases": { "emulator": "0ae53cb6e3f42a79" } } } } ``` -------------------------------- ### Define DeFi Contract Logic Source: https://github.com/onflow/docs/blob/main/docs/blockchain-development-tutorials/cadence/emulator-fork-testing/index.md Define your contract's access and functions. This example imports FlowToken and defines a function to get the total supply. ```cadence import "FlowToken" access(all) contract MyDeFiProtocol { // Your DeFi logic that reads real mainnet FlowToken data access(all) fun getTotalSupply(): UFix64 { return FlowToken.totalSupply } } ``` -------------------------------- ### High Precision Calculation Example Source: https://github.com/onflow/docs/blob/main/docs/blockchain-development-tutorials/forte/fixed-point-128-bit-math.md Demonstrates the recommended approach for accurate calculations by converting to high precision at the start, performing operations, and converting back at the end. ```cadence // Convert once at the start let amountHP = DeFiActionsMathUtils.toUInt128(amount) let feeRate = DeFiActionsMathUtils.toUInt128(0.003) let priceHP = DeFiActionsMathUtils.toUInt128(price) // Perform all calculations at high precision let afterFeeHP = DeFiActionsMathUtils.mul(amountHP, DeFiActionsMathUtils.toUInt128(1.0) - feeRate) let outputHP = DeFiActionsMathUtils.mul(afterFeeHP, priceHP) // Convert once at the end with smart rounding let output = DeFiActionsMathUtils.toUFix64RoundDown(outputHP) ``` -------------------------------- ### Get Node Version Information Source: https://github.com/onflow/docs/blob/main/docs/build/tools/clients/fcl-js/packages-docs/fcl/getNodeVersionInfo.md Retrieve node version information using the getNodeVersionInfo builder. This example decodes the response and logs the semver, protocol_version, and spork_id. ```typescript import * as fcl from "@onflow/fcl"; // Get node version information using builder const versionInfo = await fcl.send([ fcl.getNodeVersionInfo() ]).then(fcl.decode); console.log("Node version:", versionInfo.semver); console.log("Protocol version:", versionInfo.protocol_version); console.log("Spork ID:", versionInfo.spork_id); ``` -------------------------------- ### Initialize HTTP and gRPC Clients (Version 0.25.0) Source: https://github.com/onflow/docs/blob/main/docs/build/tools/clients/flow-go-sdk/migration-v0.25.0.md Demonstrates initializing both HTTP and gRPC emulator clients using the new access package in version 0.25.0. Requires common client interface declaration. ```go // common client interface var flowClient access.Client // initialize an http emulator client flowClient, err := http.NewClient(http.EmulatorHost) // initialize a gPRC emulator client flowClient, err = grpc.NewClient(grpc.EmulatorHost) ``` -------------------------------- ### Get Flow Configuration with useFlowConfig Source: https://github.com/onflow/docs/blob/main/docs/build/tools/react-sdk/hooks.md Use this hook to access the current Flow network and access node URL. No setup is required beyond importing the hook. ```tsx import { useFlowConfig } from "@onflow/react-sdk" ``` ```tsx function MyComponent() { const config = useFlowConfig() return (

Current network: {config.flowNetwork}

Current access node: {config.accessNodeUrl}

) } ``` -------------------------------- ### Establish WebSocket Connection in JavaScript Source: https://github.com/onflow/docs/blob/main/docs/protocol/access-onchain-data/websockets-stream-api/index.md Use any WebSocket client library to connect to the Flow Stream API endpoint. This example demonstrates basic connection setup in JavaScript. ```javascript const ws = new WebSocket('wss://rest-mainnet.onflow.org/ws'); ws.onopen = () => { console.log('Connected to WebSocket server'); }; ws.onclose = () => { console.log('Disconnected from WebSocket server'); }; ws.onerror = (error) => { console.error('WebSocket error:', error); }; ``` -------------------------------- ### Authentication Challenge Request - Redirect Flow Source: https://github.com/onflow/docs/blob/main/docs/build/tools/wallet-provider-spec/custodial.md Example of a GET request initiated by FCL to a Wallet Provider's authentication endpoint for the Redirect Flow. Includes required and optional query parameters. ```http GET https://provider.com/flow/authenticate ?l6n=https%3A%2F%2Fdapp.com &nonce=asdfasdfasdf &scope=email+shippingAddress &redirect=https%3A%2F%2Fdapp.com%2Fflow%2Fcallback ``` -------------------------------- ### Creating and Using an SDK Client Source: https://github.com/onflow/docs/blob/main/docs/build/tools/clients/fcl-js/packages-docs/sdk/createSdkClient.md Illustrates the creation of an SDK client with specified options and how to send a transaction or script, then decode the response. Includes basic error handling. ```typescript const client = createSdkClient({ accessNodeUrl: "https://rest-mainnet.onflow.org", transport: myTransport, computeLimit: 1000, }) client.send([myScript, myTransaction]) .then(client.decode) .catch(error => console.error("Error sending request:", error)) ``` -------------------------------- ### Manual Reference for Cadence NFT Standards Rule Source: https://github.com/onflow/docs/blob/main/docs/blockchain-development-tutorials/use-AI-to-build-on-flow/cursor/cadence-rules.md Manually invoke the Cadence NFT standards rule by referencing it in a chat prompt, for example, to get help implementing a new NFT contract. ```markdown @cadence-nft-standards help me implement a new NFT contract ``` -------------------------------- ### Navigate to Project Directory Source: https://github.com/onflow/docs/blob/main/docs/blockchain-development-tutorials/tokens/fungible-token-cadence.md After initializing the project, change your current directory to the newly created project folder. ```bash cd FooToken ``` -------------------------------- ### Flow CLI Commands for Project Management Source: https://context7.com/onflow/docs/llms.txt Commands for initializing a Flow project, generating contracts, starting the emulator, deploying, executing scripts, and sending transactions. Ensure Flow CLI is installed and configured. ```bash # Initialize a new Flow project flow init my-project # Generate a new contract flow generate contract Counter # Start the local emulator flow emulator start # Deploy contracts to emulator flow project deploy # Execute a script to read data flow scripts execute cadence/scripts/GetCounter.cdc # Send a transaction to modify state flow transactions send cadence/transactions/IncrementCounter.cdc --signer emulator-account ``` -------------------------------- ### Hooks Request to Wallet Provider Source: https://github.com/onflow/docs/blob/main/docs/build/tools/wallet-provider-spec/custodial.md Example of a GET request from FCL to the Wallet Provider's hooks endpoint to retrieve private identity information and verify the authentication code. The code is passed as a query parameter. ```http GET https://povider.com/hooks ?code=afseasdfsadf ``` -------------------------------- ### Finalize Environment Configuration Source: https://github.com/onflow/docs/blob/main/docs/blockchain-development-tutorials/use-AI-to-build-on-flow/agents/agentkit-flow-guide.md After setting up API keys and private keys, rename .env.local to .env and start the development server. ```bash mv .env.local .env npm run dev ``` -------------------------------- ### Authentication Challenge Response - Redirect Flow Source: https://github.com/onflow/docs/blob/main/docs/build/tools/wallet-provider-spec/custodial.md Example of a GET request from the Wallet Provider back to the dApp's callback URL to complete the authentication challenge in the Redirect Flow. Includes user and provider-specific data. ```http GET https://dapp.com/flow/callback ?l6n=https%3A%2F%2Fdapp.com &nonce=asdfasdfasdf &addr=0xab4U9KMf &padder=0xhMgqTff86 &code=afseasdfsadf &exp=1650400809517 &hks==https%3A%2F%2Fprovider.com%2Fhooks ``` -------------------------------- ### Example Usage with Response Source: https://github.com/onflow/docs/blob/main/docs/build/tools/flow-cli/_template.md Demonstrates a typical command usage scenario and its expected output. This is useful for understanding command behavior and response formats. ```shell {usage example with response} ``` -------------------------------- ### Configure FCL for Local Wallet Discovery Source: https://github.com/onflow/docs/blob/main/docs/blockchain-development-tutorials/cadence/mobile/react-native-quickstart.md When running a local Wallet Discovery service, update the `discovery.wallet` and `discovery.authn.endpoint` to point to your local IP address and port. This example demonstrates using a local setup for Wallet Discovery and Dev Wallet. ```javascript import { config } from "@onflow/fcl"; config({ ... "discovery.wallet": "http://10.0.0.1:3002/local/authn", "discovery.authn.endpoint": "http://10.0.0.1:3002/api/local/authn", ... }) ```