### Install @lens-chain/storage-client Source: https://lens.xyz/docs/storage/usage/getting-started Install the latest version of the @lens-chain/storage-client package using npm. This is the first step to interacting with Grove's API. ```bash npm install @lens-chain/storage-client@latest ``` -------------------------------- ### Instantiate Grove Storage Client Source: https://lens.xyz/docs/storage/usage/getting-started Instantiate the StorageClient to begin interacting with Grove. This requires importing the StorageClient from the @lens-chain/storage-client library. ```typescript import { StorageClient } from "@lens-chain/storage-client"; const storageClient = StorageClient.create(); ``` -------------------------------- ### Setup Environment Variables Source: https://lens.xyz/docs/chain/smart-contracts/hardhat This bash command copies the example environment file (`.env.example`) to `.env`, which should then be populated with project-specific configurations, such as the `PRIVATE_KEY` for interacting with the Lens Chain. ```bash cp .env.example .env ``` -------------------------------- ### Install rindexer Source: https://lens.xyz/docs/chain/tools/data-indexers/rindexer Installs the rindexer tool by downloading and executing an installation script from the provided URL. ```shell curl -L https://rindexer.xyz/install.sh | bash ``` -------------------------------- ### Install Lens Chain SDK Source: https://lens.xyz/docs/chain/integrations/viem Installs the official @lens-chain/sdk package, enabling interaction with the Lens Chain. ```bash npm install @lens-chain/sdk@latest ``` -------------------------------- ### Install Viem SDK Source: https://lens.xyz/docs/chain/integrations/viem Installs the Viem package, a TypeScript interface for Ethereum, which is a dependency for interacting with the Lens Chain. ```bash npm install viem@2 ``` -------------------------------- ### Install Covalent JavaScript SDK Source: https://lens.xyz/docs/chain/tools/data-indexers/covalent This command installs the Covalent client SDK for JavaScript using npm, which is a dependency for interacting with the GoldRush API programmatically. ```bash npm install @covalenthq/client-sdk" ``` -------------------------------- ### Install Across SDK Source: https://lens.xyz/docs/chain/tools/bridging/across Installs the necessary packages for the Across SDK, Lens Chain SDK, and Viem for use in JavaScript applications. ```bash npm install @across-protocol/app-sdk @lens-chain/sdk@latest viem ``` -------------------------------- ### Install Safe and Lens SDK Dependencies Source: https://lens.xyz/docs/chain/tools/account-abstraction/safe Installs the necessary Safe Protocol Kit and Lens SDK packages using npm. ```bash npm install @safe-global/protocol-kit @lens-chain/sdk@latest ``` -------------------------------- ### Install ConnectKit and Lens Chain SDK Source: https://lens.xyz/docs/chain/integrations/connect-wallet Installs ConnectKit, its dependencies, and the Lens Chain SDK using npm. Requires wagmi, viem, and @tanstack/react-query. ```bash npm install connectkit wagmi viem@2.x @tanstack/react-query @lens-chain/sdk@latest ``` -------------------------------- ### Install and Instantiate New Storage Client Package Source: https://lens.xyz/docs/storage/resources/changelog Provides instructions for uninstalling the old storage client package and installing the new `@lens-chain/storage-client` package. It also shows how to instantiate the new client. ```bash npm uninstall @lens-protocol/storage-node-client@next npm install @lens-chain/storage-client@next ``` -------------------------------- ### Example Lens URI Source: https://lens.xyz/docs/storage/resources/glossary Provides a concrete example of a Lens URI, illustrating how a storage key is incorporated into the identifier for a Grove resource. ```Text lens://af5225b6262e03be6bfacf31aa416ea5e00ebb05e802d0573222a92f8d0677f5 ``` -------------------------------- ### Install Lens Chain SDK Source: https://lens.xyz/docs/chain/integrations/ethers Installs the latest version of the Lens Chain SDK package. ```bash npm install @lens-chain/sdk@latest ``` -------------------------------- ### Install ZKsync-ethers and Ethers.js Source: https://lens.xyz/docs/chain/integrations/ethers Installs the necessary packages for interacting with Lens Chain using ethers.js. Ensure ethers.js v6 is installed as a peer dependency. ```bash npm install zksync-ethers ethers@6 ``` -------------------------------- ### Install Foundry ZKsync Source: https://lens.xyz/docs/chain/smart-contracts/foundry This snippet shows how to clone the Foundry ZKsync repository and install the ZKsync-compatible version of Foundry. It includes commands for cloning, installation, and verification of the installed forge and cast versions. ```Shell git clone git@github.com:matter-labs/foundry-zksync.git cd foundry-zksync ./install-foundry-zksync ``` ```Shell $ forge -V 0.0.2 (6e1c282 2024-07-03T00:22:11.972797000Z) ``` -------------------------------- ### Install The Graph CLI Source: https://lens.xyz/docs/chain/tools/data-indexers/the-graph Installs the latest version of The Graph CLI globally using npm. This tool is essential for initializing, building, and deploying subgraphs. ```bash npm install -g @graphprotocol/graph-cli@latest ``` -------------------------------- ### Verify rindexer Installation Source: https://lens.xyz/docs/chain/tools/data-indexers/rindexer Checks the installed version of the rindexer tool to confirm successful installation. ```shell rindexer --version ``` -------------------------------- ### Start Postgres Container Source: https://lens.xyz/docs/chain/running-an-archive-node Starts the PostgreSQL container using Docker Compose. This container will host the Lens chain database. ```Bash docker compose --file mainnet-external-node.yml up -d postgres ``` -------------------------------- ### Install Project Dependencies Source: https://lens.xyz/docs/chain/smart-contracts/hardhat This bash command installs all the necessary project dependencies using Yarn, as defined in the project's `package.json` file. ```bash yarn install ``` -------------------------------- ### Run rindexer Indexer Source: https://lens.xyz/docs/chain/tools/data-indexers/rindexer Starts the rindexer service to begin indexing blockchain data based on the configured rindexer.yaml file. ```shell rindexer start ``` -------------------------------- ### Clone Repository and Install Dependencies Source: https://lens.xyz/docs/chain/tools/defi/uniswap This snippet shows how to clone the echofi-deploy repository and install its JavaScript dependencies using yarn. ```bash git clone https://github.com/defispartan/echofi-deploy.git cd echofi-deploy yarn install ``` -------------------------------- ### Setup AcrossClient Source: https://lens.xyz/docs/chain/tools/bridging/across Initializes the AcrossClient with specified chain configurations and an integrator ID. It supports multiple chains, including testnets. ```typescript import { chains } from "@lens-chain/sdk/viem"; import { createAcrossClient } from "@across-protocol/app-sdk"; import { sepolia } from "viem/chains"; const client = createAcrossClient({ integratorId: "0xdead", // 2-byte hex string chains: [chains.testnet, sepolia], useTestnet: true, }); ``` -------------------------------- ### Troubleshoot Library Not Loaded Error Source: https://lens.xyz/docs/chain/smart-contracts/foundry Provides the command to install `libusb` using Homebrew to resolve 'Library not loaded' errors encountered during Foundry installation or execution. ```bash brew install libusb ``` -------------------------------- ### Start External Node Source: https://lens.xyz/docs/chain/running-an-archive-node Starts the Lens external node service using Docker Compose. This command assumes the database has been successfully restored. ```Bash docker compose --file mainnet-external-node.yml up -d external-node ``` -------------------------------- ### Configure rindexer.yaml for No-Code Indexing Source: https://lens.xyz/docs/chain/tools/data-indexers/rindexer An example YAML configuration file for rindexer, specifying project details, network settings, contract addresses, ABIs, and events to index. ```yaml name: PingIndexer description: Indexer for the Ping contract on Lens Testnet repository: https://github.com/yourusername/ping-indexer project_type: no-code networks: - name: lensTestnet chain_id: 37111 rpc: https://rpc.testnet.lens.xyz storage: postgres: enabled: true contracts: - name: Ping details: - network: lensTestnet address: 0xb7462EaCd5487514b6b789CF1Fca3081020F4e21 abi: ./abis/ping.abi.json include_events: - Pong ``` -------------------------------- ### Foundry Configuration for ZKSync Source: https://lens.xyz/docs/chain/smart-contracts/foundry Example `foundry.toml` configuration specifying contract source directories, Solidity version, and ZKSync-specific settings for Foundry. ```toml [profile.default] src = 'src' out = 'out' libs = ['lib'] [profile.zksync] src = 'contracts' solc-version = "0.8.24" fallback_oz = true is_system = false mode = "3" test = 'test' script = 'script' cache_path = 'cache_forge' libs = ['node_modules', 'lib'] ``` -------------------------------- ### Fetch Wallet Balances via Covalent API (Lens Network) Source: https://lens.xyz/docs/chain/tools/data-indexers/covalent This example demonstrates how to fetch token balances for a given wallet address across specified Lens network chains using the Covalent GoldRush API. It requires an API key and the wallet address as input. ```bash curl --request GET \ --url "https://api.covalenthq.com/v1/allchains/address/INSERT_ADDRESS_HERE/balances/?chains=lens-sepolia-testnet,lens-mainnet&key=INSERT_API_KEY_HERE" \ --header 'accept: application/json' ``` -------------------------------- ### Query Lens Chain Transactions with Node.js Source: https://lens.xyz/docs/chain/tools/bigquery/examples This Node.js example shows how to use the @google-cloud/bigquery package to retrieve the latest 10 transactions from the Lens Chain public dataset. ```JavaScript const {BigQuery} = require('@google-cloud/bigquery'); async function queryLens() { const bigquery = new BigQuery(); const query = ` SELECT * FROM `lens-chain-mainnet.public.transactions` ORDER BY createdAt DESC LIMIT 10 `; const [rows] = await bigquery.query(query); console.log('Latest 10 transactions:', rows);} ``` -------------------------------- ### Fetch Transactions via Covalent API (Lens Network) Source: https://lens.xyz/docs/chain/tools/data-indexers/covalent This example demonstrates how to fetch transactions for a given wallet address across specified Lens network chains using the Covalent GoldRush API. It requires an API key and the wallet address as input. ```bash curl --request GET \ --url "https://api.covalenthq.com/v1/allchains/transactions/?chains=lens-mainnet,lens-sepolia-testnet&addresses=INSERT_ADDRESS_HERE&key=INSERT_API_KEY_HERE" \ --header 'accept: application/json' ``` -------------------------------- ### Start Lens Node with Docker Compose Source: https://lens.xyz/docs/chain/running-a-node Starts a Lens node instance using Docker Compose. Supports both testnet and mainnet configurations. The mainnet configuration can disable snapshot recovery by setting an environment variable. ```Bash docker-compose --file testnet-external-node.yml up -d ``` ```Bash docker-compose --file mainnet-external-node.yml up -d ``` -------------------------------- ### Start External Node in Treeless Mode (Optional) Source: https://lens.xyz/docs/chain/running-an-archive-node Starts the Lens external node without rebuilding the Merkle tree, suitable for environments with limited resources or when the zks_getProof method is not needed. This involves specifying components in the command. ```YAML command: ["--components=core,api,da_fetcher,tree_fetcher"] ``` ```Bash docker compose --file mainnet-external-node.yml up -d external-node ``` -------------------------------- ### Integrate Foundry with Hardhat Project Source: https://lens.xyz/docs/chain/smart-contracts/foundry Steps to integrate Foundry testing into an existing Hardhat project, including installing the plugin, importing it, initializing Foundry, and configuring `foundry.toml`. ```bash npm install --save-dev @nomicfoundation/hardhat-foundry ``` ```typescript import "@nomicfoundation/hardhat-foundry"; ``` ```bash npx hardhat init-foundry ``` -------------------------------- ### Install Hardhat ZKsync Dependencies Source: https://lens.xyz/docs/chain/smart-contracts/hardhat Installs the necessary npm packages for integrating Hardhat with ZKsync Era, including the Hardhat ZKsync plugin and ZKsync ethers.js library. ```bash npm install -D @matterlabs/hardhat-zksync zksync-ethers ``` -------------------------------- ### Make First API Request to Lens Node Source: https://lens.xyz/docs/chain/running-a-node Demonstrates how to make a POST request to the Lens node's HTTP API to get the main contract address. It includes the request payload in JSON format. ```Shell curl --request POST \ --url http://localhost:3060/ \ --header 'Content-Type: application/json' \ --data '{ "jsonrpc": "2.0", "id": 1, "method": "zks_getMainContract", "params": [] }' ``` -------------------------------- ### Example Storage Key Source: https://lens.xyz/docs/storage/resources/glossary Illustrates the format of a Storage Key used in the Grove system. This is a globally unique hexadecimal identifier for files or folders. ```Text af5225b6262e03be6bfacf31aa416ea5e00ebb05e802d0573222a92f8d0677f5 ``` -------------------------------- ### Deploy Contracts to Lens Chain Sepolia Testnet Source: https://lens.xyz/docs/chain/smart-contracts/foundry This example shows how to deploy a smart contract named 'Lock' to the Lens Chain Sepolia Testnet using Foundry. It specifies constructor arguments, the keystore to use, RPC URL, chain ID, and the `--zksync` flag for deployment. ```Shell FOUNDRY_PROFILE=zksync forge create src/Lock.sol:Lock \ --constructor-args "42" \ --account myKeystore \ --from \ --rpc-url https://rpc.testnet.lens.xyz \ --chain 37111 \ --zksync ``` -------------------------------- ### Query Lens Chain Addresses with Python Source: https://lens.xyz/docs/chain/tools/bigquery/examples This Python snippet demonstrates how to use the Google Cloud client library to query recent publications from the Lens Chain public dataset in BigQuery. ```Python from google.cloud import bigquery # Initialize the clientclient = bigquery.Client() # Query recent publicationsquery = """SELECT address,FROM `lens-chain-mainnet.public.addresses` addressesWHERE LIMIT 5""" # Execute the queryquery_job = client.query(query) # Process resultsfor row in query_job: print(f"Handle: {row.handle}, Posted at: {row.block_timestamp}") ``` -------------------------------- ### Verify Contract with Hardhat Source: https://lens.xyz/docs/chain/smart-contracts/hardhat This bash command verifies a deployed contract on the Lens Chain. It requires the contract address and any constructor arguments. The example verifies a contract deployed with the initial value '42'. ```bash # npm hardhat verify [] --network lensTestnet npm hardhat verify 0xda2BFD327d880A42Ec72E3392E10e43bb32B874F "42" --network lensTestnet ``` -------------------------------- ### Use Generic ACL Syntax with Storage Client Source: https://lens.xyz/docs/storage/resources/changelog Illustrates the updated generic ACL syntax which requires a `chain_id` and uses a builder pattern. This example shows how to specify the chain ID, function, and parameters for the ACL. ```javascript import { RECOVERED_ADDRESS_PARAM_MARKER } from "@lens-chain/storage-client"; // … const acl = genericAcl("0x1234…") .withFunction("someFunction(address user) returns (bool)") .withChainId(1) .withParams([RECOVERED_ADDRESS_PARAM_MARKER]) .build(); ``` -------------------------------- ### Edit File Example (TypeScript) Source: https://lens.xyz/docs/storage/usage/edit Demonstrates how to edit a file using the `editFile` method of the storage client. It takes the file's lens URI, the new file content, a signer instance, and the ACL configuration. ```TypeScript async function onSubmit(event: SubmitEvent) { event.preventDefault(); const input = event.currentTarget.elements["image"]; const file = input.files[0]; const response = await storageClient.editFile( "lens://323c0e1cceb…", file, walletClient, { acl } ); // response.uri: 'lens://323c0e1cceb…' } ``` -------------------------------- ### SQL Example: Get Latest Transactions Source: https://lens.xyz/docs/chain/tools/bigquery/examples A common SQL query to retrieve the latest 10 transactions from the Lens Chain testnet transactions table. ```SQL SELECT * FROM lens-chain-testnet.public.transactions order by "createdAt" desc limit 10; ``` -------------------------------- ### Clone Lens Node Repository Source: https://lens.xyz/docs/chain/running-a-node Clones the Lens Chain Node repository from GitHub and navigates into the cloned directory. This is the first step in setting up a Lens node. ```Bash git clone https://github.com/lens-protocol/lens-chain-node && cd lens-chain-node ``` -------------------------------- ### Initialize Subgraph Indexing Source: https://lens.xyz/docs/chain/tools/data-indexers/the-graph Initializes a new subgraph project using the Graph CLI. It prompts the user for configuration details like the protocol, network, contract address, and ABI. ```bash graph init --studio ``` -------------------------------- ### Initialize Protocol Kit for Safe Deployment Source: https://lens.xyz/docs/chain/tools/account-abstraction/safe Initializes the Protocol Kit with provider details, signer, and Safe account configuration, including owners and threshold. ```typescript const safeAccountConfig = { owners: [ "0x81EdcF8e0a72c3300087891Bb3E992FAf285b2FC", "0x482c27532517af746358D8E35AfCb3b2ca90A72B", "0x28f875a08F320Cb5Fb6317c6C948fCA8663aC7e9", ], // replace with owner addresses threshold: 2, // replace with multi-signature threshold }; const predictedSafe = { safeAccountConfig, }; const protocolKit = await Safe.init({ provider: chains.testnet.rpcUrls.default, signer: process.env.PRIVATE_KEY, // replace with deployer private key predictedSafe, }); ``` -------------------------------- ### Instantiate New Storage Client Source: https://lens.xyz/docs/storage/resources/changelog Demonstrates how to instantiate the new `@lens-chain/storage-client` client. The `create` method is used without any arguments for the default instantiation. ```javascript import { StorageClient } from "@lens-chain/storage-client"; const storageClient = StorageClient.create(); ``` -------------------------------- ### Clone Lens Node Repository Source: https://lens.xyz/docs/chain/running-an-archive-node Clones the Lens chain node repository from GitHub and navigates into the cloned directory. This is the first step in setting up the node. ```Bash git clone https://github.com/lens-protocol/lens-chain-node && cd lens-chain-node ``` -------------------------------- ### Create New Rust rindexer Project Source: https://lens.xyz/docs/chain/tools/data-indexers/rindexer Scaffolds a new rindexer project specifically for building custom indexing solutions using Rust. ```shell rindexer new rust ``` -------------------------------- ### Import Deployment Keystore with Cast Source: https://lens.xyz/docs/chain/smart-contracts/foundry This command demonstrates how to import a private key into a Foundry keystore for deploying contracts on Lens Chain. It prompts the user for the private key and a password, then confirms the successful creation of the keystore. ```Shell FOUNDRY_PROFILE=zksync cast wallet import myKeystore --interactive ``` -------------------------------- ### Install Halliday Payments SDK Source: https://lens.xyz/docs/chain/tools/on-ramp/halliday Installs the Halliday Payments SDK for web projects using npm. This is the first step to integrating Halliday's payment functionalities. ```bash npm install @halliday-sdk/commerce ``` -------------------------------- ### Query BigQuery using REST API Source: https://lens.xyz/docs/chain/tools/bigquery/examples This example demonstrates how to use `curl` to interact with the BigQuery REST API to count total addresses in the Lens Chain public dataset. ```Bash curl -X POST \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -H "Content-Type: application/json" \ https://bigquery.googleapis.com/bigquery/v2/projects/lens-public-data/queries \ -d '{ "query": "SELECT COUNT(*) as total_addresses FROM `lens-chain-mainnet.public.addresses`" }' ``` -------------------------------- ### Deploy and Interact with Safe CLI Source: https://lens.xyz/docs/chain/resources/contracts Instructions on how to deploy and interact with Safe using the Safe CLI, emphasizing the use of custom networks. ```bash To deploy and interact with Safe, use the Safe CLI w/ custom network. ``` -------------------------------- ### Create a Wallet Instance for Lens Chain and Ethereum L1 Source: https://lens.xyz/docs/chain/integrations/ethers Creates a Wallet instance using a private key and connects it to both Lens Chain and Ethereum L1 providers. Assumes the private key is stored in environment variables. ```typescript import { Wallet } from "@lens-chain/sdk/ethers"; import { lensProvider, ethProvider } from "./providers"; export const wallet = new Wallet( process.env.PRIVATE_KEY as String, lensProvider, ethProvider ); ``` -------------------------------- ### Add Lens Chain to Wallet Source: https://lens.xyz/docs/chain/integrations/viem Adds the Lens Chain mainnet configuration to the user's wallet using Viem's `addChain`. Requires the chain object. ```TypeScript import { chains } from "@lens-chain/sdk/viem"; import { walletClient } from "./walletClient"; await walletClient.addChain({ chain: chains.mainnet }); ``` -------------------------------- ### Create and Connect an Unconnected Wallet Instance Source: https://lens.xyz/docs/chain/integrations/ethers Demonstrates creating a Wallet instance without immediate connection and then connecting it to specific L1 and L2 providers. ```typescript import { Wallet } from "@lens-chain/sdk/ethers"; import { lensProvider, ethProvider } from "./providers"; const unconnectedWallet = new Wallet(process.env.PRIVATE_KEY as String); const lensWallet = unconnectedWallet.connect(lensProvider); const ethWallet = unconnectedWallet.connectToL1(ethProvider); ``` -------------------------------- ### HTML Form for File Upload (HTML) Source: https://lens.xyz/docs/storage/usage/edit An example HTML form with a file input and a submit button, used for selecting and replacing file content. ```HTML
``` -------------------------------- ### Get Quote for Bridging Source: https://lens.xyz/docs/chain/tools/bridging/across Retrieves a price and fee estimate for a specific bridging route and input amount. Requires route details and the amount to bridge. ```typescript import { parseEther } from "viem"; // Bridge 1 WGRASS from Lens Testnet to ETH Sepolia const route = { originChainId: chains.testnet.id, destinationChainId: sepolia.id, inputToken: "0xeee5a340Cdc9c179Db25dea45AcfD5FE8d4d3eB8", // WGRASS Lens Testnet outputToken: "0x2Be68B15c693D3b5747F9F0D49D30A2E81BAA2Df", // WGRASS Ethereum Sepolia }; const quote = await client.getQuote({ route, inputAmount: parseEther("1"), }); ``` -------------------------------- ### Get Available Routes Source: https://lens.xyz/docs/chain/tools/bridging/across Fetches available bridging routes based on optional parameters like origin token, destination token, or chain IDs. ```typescript // available params: originToken, destinationToken, destinationChainId, originChainId, originTokenSymbol, destinationTokenSymbol const options = { originChainId: 37111 }; const routes = await client.getAvailableRoutes(options); ``` -------------------------------- ### Update Lens Chain SDK to Latest Version Source: https://lens.xyz/docs/chain/resources/changelog This command updates the Lens Chain SDK package to the latest stable 1.0 release. Ensure you have Node.js and npm installed. ```bash npm install @lens-chain/sdk@latest ``` -------------------------------- ### Deploy Subgraph Source: https://lens.xyz/docs/chain/tools/data-indexers/the-graph Deploys the subgraph to The Graph Studio. This command requires authentication with a deploy key and then proceeds to generate code, build the subgraph, and deploy it. ```bash graph auth --studio graph codegen && graph build graph deploy ``` -------------------------------- ### Configure Web3Provider with ConnectKit and Wagmi Source: https://lens.xyz/docs/chain/integrations/connect-wallet Sets up the Web3Provider component using Wagmi and ConnectKit for Ethereum wallet connections. It configures chains, transports, WalletConnect projectId, and application details. Requires 'use client' directive for Next.js App Router. ```typescript "use client"; import { WagmiProvider, createConfig, http } from "wagmi"; import { chains } from "@lens-chain/sdk/viem"; import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; import { ConnectKitProvider, getDefaultConfig } from "connectkit"; const config = createConfig( getDefaultConfig({ chains: [chains.mainnet, chains.testnet], transports: { [chains.mainnet.id]: http(chains.mainnet.rpcUrls.default.http[0]!), [chains.testnet.id]: http(chains.testnet.rpcUrls.default.http[0]!), }, walletConnectProjectId: process.env.NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID, appName: "Lens Testing App", appDescription: "A sample app integrating Lens Testing wallet connection.", appUrl: "https://yourapp.com", appIcon: "https://yourapp.com/icon.png", }) ); const queryClient = new QueryClient(); export const Web3Provider = ({ children }) => { return ( {children} ); }; ``` -------------------------------- ### Resolve Lens URI to URL (TypeScript) Source: https://lens.xyz/docs/storage/usage/download This TypeScript example demonstrates how to use the `storageClient.resolve` method to convert a Grove Lens URI into a downloadable gateway URL. This is useful for programmatically accessing content. ```typescript const url = storageClient.resolve("lens://af5225b…"); // url: https://api.grove.storage/af5225b… ``` -------------------------------- ### One-Step File Upload via API (Shell) Source: https://lens.xyz/docs/storage/usage/upload An example using curl to perform a one-step upload of a video file to the Grove storage API. It specifies the chain ID and content type in the request. ```Shell curl -s -X POST "https://api.grove.storage/?chain_id=37111" \ --data-binary @watch_this.mp4 \ -H 'Content-Type: video/mp4' ``` -------------------------------- ### Storage Smart Contract Example Source: https://lens.xyz/docs/chain/smart-contracts/hardhat A basic Solidity smart contract named 'Storage' that stores and retrieves a uint256 number. It includes an event for when the number is updated and a constructor for initialisation. ```solidity // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; contract Storage { // This variable will store the number uint256 private storedNumber; // This event will be emitted whenever the stored number is updated event NumberStored(uint256 newNumber); // Constructor to initialize the stored number constructor(uint256 initialNumber) { storedNumber = initialNumber; emit NumberStored(initialNumber); } // Function to store a new number function storeNumber(uint256 newNumber) public { storedNumber = newNumber; emit NumberStored(newNumber); } // Function to retrieve the stored number function retrieveNumber() public view returns (uint256) { return storedNumber; } } ``` -------------------------------- ### Create Ethers Providers for Lens Chain and Ethereum L1 Source: https://lens.xyz/docs/chain/integrations/ethers Sets up JsonRpcProvider instances for both Lens Chain (L2) and an Ethereum L1 network (e.g., Sepolia). Uses SDK's getDefaultProvider for Lens Chain and ethers.js's getDefaultProvider for L1. ```typescript import { getDefaultProvider, Network } from "@lens-chain/sdk/ethers"; import { ethers } from "ethers"; // Lens Chain (L2) export const lensProvider = getDefaultProvider(Network.Testnet); // Ethereum L1 export const ethProvider = ethers.getDefaultProvider("sepolia"); ``` -------------------------------- ### Clone Lens Network Hardhat Boilerplate Source: https://lens.xyz/docs/chain/smart-contracts/hardhat This bash command clones the official Lens Network Hardhat boilerplate repository into a new directory named 'my-project' and then navigates into that directory. ```bash git clone https://github.com/lens-protocol/lens-network-hardhat-boilerplate.git my-project cd my-project ``` -------------------------------- ### Upload File using Storage Client (TypeScript) Source: https://lens.xyz/docs/storage/usage/upload An example of an asynchronous function that handles form submission, retrieves a file, and uploads it using the storage client with a defined ACL configuration. It logs the response URI. ```TypeScript async function onSubmit(event: SubmitEvent) { event.preventDefault(); const input = event.currentTarget.elements["image"]; const file = input.files[0]; const response = await storageClient.uploadFile(file, { acl }); // response.uri: 'lens://323c0e1ccebcfa70dc130772…' } ``` -------------------------------- ### Direct Download Link Source: https://lens.xyz/docs/storage/usage/download This snippet shows how to create a direct download link for content hosted on Grove using an HTML anchor tag. The link points to the gateway URL of the content. ```html Download ``` -------------------------------- ### Run Foundry Tests with ZKSync Profile Source: https://lens.xyz/docs/chain/smart-contracts/foundry Executes Foundry tests specifically configured for the ZKSync environment using the `FOUNDRY_PROFILE` environment variable. ```bash FOUNDRY_PROFILE=zksync forge test --zksync ``` -------------------------------- ### Testing BigQuery Queries with LIMIT Source: https://lens.xyz/docs/chain/tools/bigquery/costs Illustrates the best practice of using the LIMIT clause when testing new BigQuery queries to reduce data processing and costs. ```SQL -- Always add LIMIT when testing new queries SELECT column1, column2 FROM `table_name` LIMIT 100 ``` -------------------------------- ### Relocate Lens Chain SDK and Update Imports Source: https://lens.xyz/docs/chain/resources/changelog This sequence of commands uninstalls the old Lens Chain SDK package and installs the new one from the @lens-chain organization. It also shows how to amend import statements to reflect the new package name. ```bash npm uninstall @lens-network/sdk npm install @lens-chain/sdk@canary ``` ```javascript - import { chains } from '@lens-network/sdk'; + import { chains } from '@lens-chain/sdk'; ```