### Start Local Development Server Source: https://github.com/consensys/doc.linea/blob/main/README.mdx Run this command to preview the documentation locally. This command can be used every time after the initial setup. ```bash npm run start ``` -------------------------------- ### Install Web3 Package Source: https://github.com/consensys/doc.linea/blob/main/docs/network/overview/transaction-finality.mdx Install the necessary web3 package for interacting with Ethereum nodes. This is a prerequisite for running the JavaScript example. ```bash npm init -y && npm install web3 ``` -------------------------------- ### Install Dependencies and Copy Environment File Source: https://github.com/consensys/doc.linea/blob/main/docs/network/how-to/deploy-subdomain.mdx Clone the Linea Names repository, navigate to the contracts package, install dependencies, and copy the example environment file. ```bash cd ./packages/linea-ens-contracts yarn cp .env.org .env ``` -------------------------------- ### Start Nethermind Node (Linea Sepolia) Source: https://github.com/consensys/doc.linea/blob/main/docs/network/how-to/run-a-node/nethermind.mdx Use this command to start a Nethermind node for the Linea Sepolia testnet. Ensure Nethermind is installed and configured. ```bash nethermind \ --datadir ./nethermind-data \ --config linea-sepolia \ --JsonRpc.Enabled=true \ --JsonRpc.Host=0.0.0.0 \ --JsonRpc.Port=8545 \ --Metrics.Enabled=true \ --Metrics.ExposePort=8008 ``` -------------------------------- ### Install Dynamic SDK and Ethereum Connectors Source: https://github.com/consensys/doc.linea/blob/main/docs/network/how-to/connect-wallet.mdx Install the necessary packages for the Dynamic SDK and its Ethereum wallet connectors. ```bash npm install @dynamic-labs/sdk-react-core @dynamic-labs/ethereum ``` -------------------------------- ### Start Nethermind Node (Mainnet) Source: https://github.com/consensys/doc.linea/blob/main/docs/network/how-to/run-a-node/nethermind.mdx Use this command to start a Nethermind node for the Linea Mainnet. Ensure Nethermind is installed and configured. ```bash nethermind \ --datadir ./nethermind-data \ --config linea-mainnet \ --JsonRpc.Enabled=true \ --JsonRpc.Host=0.0.0.0 \ --JsonRpc.Port=8545 \ --Metrics.Enabled=true \ --Metrics.ExposePort=8008 ``` -------------------------------- ### Goldsky Instant Subgraph Configuration File Example Source: https://github.com/consensys/doc.linea/blob/main/docs/network/build/tools/data-indexers/goldsky/goldsky-index.mdx An example of a JSON configuration file for deploying an instant subgraph. It defines the subgraph name, ABIs, chains, and contract instances with their respective addresses and start blocks. ```json { "version": "1", "name": "TokenDeployed", "abis": { "TokenRegistry": { "path": "./abis/token-registry.json" } }, "chains": ["mainnet"], "instances": [ { "abi": "TokenRegistry", "address": "0x0A6f564C5c9BeBD66F1595f1B51D1F3de6Ef3b79", "startBlock": 13983724, "chain": "mainnet" } ] } ``` -------------------------------- ### Start Development Server Source: https://github.com/consensys/doc.linea/blob/main/docs/network/tutorials/ecosystem-tutorials/usdc.mdx Command to start the development server for the application. After running, access the app via `http://localhost:5173`. ```bash npm run dev ``` -------------------------------- ### Interactive Subgraph Initialization Example Source: https://github.com/consensys/doc.linea/blob/main/docs/network/build/tools/data-indexers/thegraph.mdx This example demonstrates the interactive prompts and output during the `graph init` process, including network selection, contract details, and event indexing. ```bash user@my-MacBook-Pro GRT-Subgraph % graph init › Warning: In next major version, this flag will be removed. By default we will deploy to the Graph Studio. › Learn more about Sunrise of Decentralized Data › https://thegraph.com/blog/unveiling-updated-sunrise-decentralized-data/ › Warning: In next major version, this flag will be removed. By default we will stop initializing a Git repository. ✔ Protocol · ethereum ✔ Product for which to initialize · subgraph-studio ✔ Subgraph slug · GRT ✔ Directory to create the subgraph in · GRT ? Ethereum network … ? Ethereum network … ? Ethereum network … ✔ Ethereum network · arbitrum-one ✔ Contract address · 0x9623063377AD1B27544C965cCd7342f7EA7e88C7 ✔ Fetching ABI from Etherscan ✖ Failed to fetch Start Block: Failed to fetch contract creation transaction hash ✔ Do you want to retry? (Y/n) · false ✖ Failed to fetch Contract Name: Failed to fetch contract source code ✔ Do you want to retry? (Y/n) · false ✔ Start Block · 42449274 ✔ Contract Name · GRT ✔ Index contract events as entities (Y/n) · true Generate subgraph Write subgraph to directory ✔ Create subgraph scaffold ✔ Initialize networks config ✔ Initialize subgraph repository ✔ Install dependencies with yarn ✔ Generate ABI and schema types with yarn codegen Add another contract? (y/n): ``` -------------------------------- ### Install Wagmi and Viem Source: https://github.com/consensys/doc.linea/blob/main/docs/network/how-to/fallback.mdx Install the necessary packages for Wagmi and Viem. The `@wagmi/connectors` package is often needed for app functionality. ```bash npm install @wagmi/core @wagmi/connectors viem ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/consensys/doc.linea/blob/main/README.mdx Run this command once in the project's root folder after installing Node.js to install all necessary project dependencies. ```bash npm install ``` -------------------------------- ### Install pcl CLI Source: https://github.com/consensys/doc.linea/blob/main/docs/network/how-to/write-and-deploy-assertions.mdx Install the pcl CLI using Homebrew. Verify the installation by checking the version. ```bash brew tap phylaxsystems/pcl brew install phylax ``` ```bash pcl --version ``` -------------------------------- ### Build and Start AI Agent Source: https://github.com/consensys/doc.linea/blob/main/docs/network/tutorials/aiagent-quickstart.mdx Commands to build the AI agent project and start the agent and its client interface. Ensure your character configuration file is specified when starting the agent. ```bash pnpm build pnpm start --character-"characters/yourcharactername.character.json" pnpm start:client ``` -------------------------------- ### Install Privy React SDK Source: https://github.com/consensys/doc.linea/blob/main/docs/network/how-to/connect-wallet.mdx Install the Privy SDK for React using npm. ```bash npm install @privy-io/react-auth@latest ``` -------------------------------- ### Install Foundry Source: https://github.com/consensys/doc.linea/blob/main/docs/network/build/launch-an-app/deploy.mdx Installs the Foundry build toolchain. Ensure you have curl installed. ```bash curl -L https://foundry.paradigm.xyz | bash ``` -------------------------------- ### Start Geth Node on Linea Mainnet Source: https://github.com/consensys/doc.linea/blob/main/docs/network/how-to/run-a-node/geth.mdx Use this command to start a Geth node connected to the Linea Mainnet. Ensure you have the necessary bootnodes configured for network connectivity. ```bash geth \ --datadir $HOME/geth-linea-data \ --networkid 59144 \ --rpc.allow-unprotected-txs \ --txpool.accountqueue 50000 \ --txpool.globalqueue 50000 \ --txpool.globalslots 50000 \ --txpool.pricelimit 1000000 \ --txpool.pricebump 1 \ --txpool.nolocals \ --http --http.addr '127.0.0.1' --http.port 8545 --http.corsdomain '*' --http.api 'web3,eth,txpool,net' --http.vhosts='*' \ --ws --ws.addr '127.0.0.1' --ws.port 8546 --ws.origins '*' --ws.api 'web3,eth,txpool,net' \ --bootnodes "enode://069800db9e6e0ec9cadca670994ef1aea2cfd3d88133e63ecadbc1cdbd1a5847b09838ee08d8b5f02a9c32ee13abeb4d4104bb5514e5322c9d7ee19f41ff3e51@3.132.73.210:31002,enode://a8e03a71eab12ec4b47bb6e19169d8e4dc7a58373a2476969bbe463f2dded6003037fa4dd5f71e15027f7fc8d7340956fbbefed67ddd116ac19a7f74da034b61@3.132.73.210:31003,enode://97706526cf79df9d930003644f9156805f6c8bd964fc79e083444f7014ce10c9bdd2c5049e63b58040dca1d4c82ebef970822198cf0714de830cff4111534ff1@18.223.198.165:31004,enode://24e1c654a801975a96b7f54ebd7452ab15777fc635c1db25bdbd4425fdb04e7f4768e9e838a87ab724320a765e41631d5d37758c933ad0e8668693558125c8aa@18.223.198.165:31000,enode://27010891d960f73d272a553f72b6336c6698db3ade98d631f09c764e57674a797be5ebc6829ddbb65ab564f439ebc75215d20aa98b6f351d12ea623e7d139ac3@3.132.73.210:31001,enode://228e1b8a4931e46f383e30721dac21fb8fb4e5e1b32c870e13b25478c82db3dc1cd9e7ceb93d302a766466b55638cc9c5cbfc43aa48fa41ced19baf365951f76@3.1.142.64:31002,enode://c22eb0d40fc3ad5ea710aeddea906567778166bfe18c157955e8c39b23a46c45db18a0fa2ba07f2b64c81178a8c796aec2a29151533920ead06fcdfc6d8d03c6@47.128.192.57:31004,enode://8ce733abe39fd7ae0a278b9893f85c1193c611a3886168690dd843435460f22cc4d61f9e8d0ace7f5905836a665319a31cccdaacdada2acc69972c382ecce7db@3.1.142.64:31003,enode://b7c1b2bed65a855f7a2104aac9a14674dfdf018fdac763415b373b29ce18cdb81d36328ba4e5c9f12629f3a50c3e8f9ee048f22dbdbe93a82813da89c6b81334@51.20.235.126:31004,enode://95270e0550848a72fb141cf27f1c4ea10714edde365b411dc0fa06c81c0f282ce155eb9fa472b6b8bb9ee98395eeaf4c5a7b02a01fe58b37ea98ba152eda4c37@13.50.94.193:31000,enode://72013391755f24f08567b932feeeec4c893c06e0b1fb480890c83bf87fd277ad86a5ab9cb586db9ae9970371a2f8cb0c96f6c9f69045abca0fb801db7f047138@51.20.235.126:31001' \ --syncmode full \ --metrics \ --verbosity 3 ``` -------------------------------- ### Install Dependencies Source: https://github.com/consensys/doc.linea/blob/main/docs/network/build/launch-an-app/app.mdx Install necessary packages including the MetaMask Embedded Wallets SDK, Wagmi, Viem, and React Query for web3 integration. ```bash npm install @web3auth/modal wagmi viem@2.x @tanstack/react-query ``` -------------------------------- ### Install Privy React SDK Source: https://github.com/consensys/doc.linea/blob/main/docs/network/build/tools/social-login/privy.mdx Install the Privy SDK for React applications using npm. ```bash npm install @privy-io/react-auth ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/consensys/doc.linea/blob/main/docs/network/tutorials/voting-dapp.mdx Install all necessary dependencies for both the frontend and backend components of the monorepo. ```bash pnpm install ``` -------------------------------- ### Start Besu Node on Linea Sepolia Source: https://github.com/consensys/doc.linea/blob/main/docs/network/how-to/run-a-node/besu.mdx Use this command to start a Besu node connected to the Linea Sepolia testnet, specifying the configuration file path. ```bash besu --config-file=/Users/myuser/sepolia/linea-besu.config.toml ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/consensys/doc.linea/blob/main/docs/network/tutorials/ecosystem-tutorials/usdc.mdx Installs necessary libraries for the React application, including React, Vite, and viem. ```bash npm install react@latest react-dom@latest @types/react@latest @types/react-dom@latest @vitejs/plugin-react@latest typescript@latest vite@latest viem@latest ``` -------------------------------- ### Install The Graph CLI Source: https://github.com/consensys/doc.linea/blob/main/docs/network/build/tools/data-indexers/thegraph.mdx Install the Graph CLI globally on your local machine to manage subgraphs. ```bash npm install -g @graphprotocol/graph-cli ``` -------------------------------- ### Install Wagmi Packages Source: https://github.com/consensys/doc.linea/blob/main/docs/network/how-to/connect-wallet.mdx Install the necessary Wagmi, Viem, and TanStack Query packages for your React dapp. ```bash npm install wagmi viem@2.x @tanstack/react-query ``` -------------------------------- ### Start Geth Node using Docker Compose Source: https://github.com/consensys/doc.linea/blob/main/docs/network/how-to/run-a-node/geth.mdx Run this command in the directory containing your docker-compose.yml and geth-genesis.json files to start the Geth node. ```bash docker compose up geth-node ``` -------------------------------- ### Start Geth Node on Linea Sepolia Testnet Source: https://github.com/consensys/doc.linea/blob/main/docs/network/how-to/run-a-node/geth.mdx Use this command to start a Geth node connected to the Linea Sepolia testnet. This configuration is suitable for development and testing purposes. ```bash geth \ --datadir $HOME/geth-sepolia-data \ --networkid 59141 \ --rpc.allow-unprotected-txs \ --txpool.accountqueue 50000 \ --txpool.globalqueue 50000 \ --txpool.globalslots 50000 \ --txpool.pricelimit 1000000 \ --txpool.pricebump 1 \ --txpool.nolocals \ --http --http.addr '0.0.0.0' --http.port 8545 --http.corsdomain '*' --http.api 'web3,eth,txpool,net' --http.vhosts='*' \ --ws --ws.addr '0.0.0.0' --ws.port 8546 --ws.origins '*' --ws.api 'web3,eth,txpool,net' \ --bootnodes "enode://6f20afbe4397e51b717a7c1ad3095e79aee48c835eebd9237a3e8a16951ade1fe0e66e981e30ea269849fcb6ba03d838da37f524fabd2a557474194a2e2604fa@18.221.100.27:31002,enode://ce1e0d8e0500cb5c0ac56bdcdafb2d6320c3a2c5125b5ccf12f5dfc9b47ee74acbcafc32559017613136c9c36a0ce74ba4f83b7fb8244f099f3b15708d9d3129@3.23.75.47:31000,enode://1b026a5eb0ae74300f58987d235ef0e3a550df963345cb3574be3b0b54378bd11f14dfd515a8976f2c2d2826090e9507b8ccc24f896a9ffffffcabcfd996a733@3.129.120.128:31001" \ --syncmode full \ --metrics \ --verbosity 3 ``` -------------------------------- ### Install Linea SDK Source: https://github.com/consensys/doc.linea/blob/main/docs/network/build/send-receive-messages.mdx Install the Linea SDK using npm. This package simplifies cross-layer message execution. ```bash npm install @consensys/linea-sdk ``` -------------------------------- ### Start Besu Node on Linea Mainnet Source: https://github.com/consensys/doc.linea/blob/main/docs/network/how-to/run-a-node/besu.mdx Use this command to start a Besu node connected to the Linea Mainnet, specifying the configuration file path. ```bash besu --config-file=/Users/myuser/mainnet/linea-besu.config.toml ``` -------------------------------- ### Install Viem Source: https://github.com/consensys/doc.linea/blob/main/docs/api/reference/index.mdx Install the viem package using npm or yarn. This library provides utilities for interacting with Ethereum-like blockchains. ```bash npm i viem ``` ```bash yarn add viem ``` -------------------------------- ### eRPC Configuration Example Source: https://github.com/consensys/doc.linea/blob/main/docs/network/build/tools/node-providers/erpc.mdx Define your eRPC configuration in a YAML file. This example shows basic settings including log level and upstream project configurations. ```yaml filename="erpc.yaml" logLevel: debug projects: - id: main upstreams: # You don't need to define architecture (e.g. evm) or chain id (e.g. 59144) # as they will be detected automatically by eRPC. - endpoint: https://rpc.linea.build - endpoint: evm+alchemy://xxxx-my-alchemy-api-key-xxxx ``` -------------------------------- ### Start Linea Besu Node with Docker Compose (Linea Sepolia) Source: https://github.com/consensys/doc.linea/blob/main/docs/network/how-to/run-a-node/linea-besu.mdx Use this command to start a Linea Besu node on Linea Sepolia using Docker Compose. Navigate to the directory containing your downloaded `.yaml` file first. ```bash docker compose -f ./your-file-path/docker-compose-advanced-sepolia.yaml up ``` -------------------------------- ### Start Linea Besu Node with Docker Compose (Mainnet) Source: https://github.com/consensys/doc.linea/blob/main/docs/network/how-to/run-a-node/linea-besu.mdx Use this command to start a Linea Besu node on Mainnet using Docker Compose. Ensure you are in the directory containing your downloaded `.yaml` file. ```bash docker compose -f ./your-file-path/docker-compose-advanced-mainnet.yaml up ``` -------------------------------- ### Create Project Directory and Initialize npm Source: https://github.com/consensys/doc.linea/blob/main/docs/network/tutorials/ecosystem-tutorials/usdc.mdx Sets up a new project directory and initializes it with npm. Ensure Node.js (16+) is installed. ```bash mkdir usdc-transfer-app cd usdc-transfer-app npm init -y ``` -------------------------------- ### Example Verification Output Source: https://github.com/consensys/doc.linea/blob/main/docs/network/how-to/verify-smart-contract/foundry.mdx This is an example of the output you can expect when verifying a contract. It shows the submission status, GUID, and final verification result. ```bash Start verifying contract 0x8de6e9b6c774c8b7aba587ed84e5ad0a45837b16 deployed on mainnet Submitting verification for [src/Counter.sol:Counter] "0x8dE6e9b6c774c8B7AbA587ED84E5AD0A45837b16". Submitted contract for verification: Response: OK GUID: `ynnfyvwcqev9i5xr1urdqt9kdwx4zkurvpu7rgh2ywmyp22dpy` URL: https://etherscan.io/address/0x8de6e9b6c774c8b7aba587ed84e5ad0a45837b16 Contract verification status: Response: `NOTOK` Details: `Pending in queue` Contract verification status: Response: `OK` Details: `Pass - Verified` Contract successfully verified ``` -------------------------------- ### Initialize Project with Create Web3 Template CLI Source: https://github.com/consensys/doc.linea/blob/main/docs/network/tutorials/voting-dapp.mdx Use this command to start a new Web3 project. It scaffolds a monorepo with frontend and backend components, including Linea support and MetaMask SDK integration. ```bash pnpm create @consensys/create-web3-template ``` -------------------------------- ### Select Frontend Framework Source: https://github.com/consensys/doc.linea/blob/main/docs/network/tutorials/voting-dapp.mdx Choose your preferred frontend framework. Next.js is recommended for this tutorial. ```bash ? Please select the framework you want to use: HardHat Vanilla React ❯ Next.js ``` -------------------------------- ### Initialize Geth Node (Linea Sepolia) Source: https://github.com/consensys/doc.linea/blob/main/docs/network/how-to/run-a-node/geth.mdx Bootstrap the Linea Sepolia node by initializing it with the genesis file. Ensure you are in the directory containing the genesis file. ```bash geth --datadir ./geth-sepolia-data init ./geth-genesis.json ``` -------------------------------- ### Install EVM Plugin for ElizaOS Source: https://github.com/consensys/doc.linea/blob/main/docs/network/tutorials/aiagent-quickstart.mdx Install the EVM Plugin using pnpm to enable interaction with the Linea blockchain. This is necessary if the plugin is not already included in your setup. ```bash pnpm add @elizaos/plugin-evm ``` -------------------------------- ### Initialize Geth Node (Mainnet) Source: https://github.com/consensys/doc.linea/blob/main/docs/network/how-to/run-a-node/geth.mdx Bootstrap the Linea Mainnet node by initializing it with the genesis file. Ensure you are in the directory containing the genesis file. ```bash geth --datadir ./geth-linea-data init ./geth-genesis.json ``` -------------------------------- ### Select Smart Contract Development Environment Source: https://github.com/consensys/doc.linea/blob/main/docs/network/tutorials/voting-dapp.mdx Choose your smart contract development environment. HardHat is selected for this tutorial. ```bash ? Would you like to use HardHat or Foundry? ❯ HardHat Foundry ``` -------------------------------- ### Get Block Transaction Count by Number Response Source: https://github.com/consensys/doc.linea/blob/main/docs/api/reference/eth-getblocktransactioncountbynumber.mdx This is an example of a successful response from the `eth_getBlockTransactionCountByNumber` method, indicating the transaction count for the requested block. ```json { "jsonrpc": "2.0", "id": 1, "result": "0x1" } ``` -------------------------------- ### debug_traceTransaction with callTracer Source: https://github.com/consensys/doc.linea/blob/main/docs/api/reference/debug-tracetransaction.mdx This example demonstrates how to use `debug_traceTransaction` with the `callTracer` to get a nested call tree of the transaction's execution. It shows the request payload and an abbreviated success response. ```APIDOC ## debug_traceTransaction with callTracer ### Description Replays a transaction using the `callTracer` to return the call tree, including nested `CALL`, `DELEGATECALL`, and `STATICCALL` frames, along with details like `from`, `to`, `gas`, `gasUsed`, `input`, `output`, and any nested calls. ### Method POST ### Endpoint `https://rpc.linea.build` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **jsonrpc** (string) - Required - Specifies the JSON-RPC protocol version. - **method** (string) - Required - The method name, which is `debug_traceTransaction`. - **params** (array) - Required - An array containing the transaction hash and options. - **transactionHash** (string) - Required - The 32-byte hash of the transaction to trace. - **options** (object) - Required - An object specifying the tracer. - **tracer** (string) - Required - Must be set to `"callTracer"`. - **id** (number) - Required - The ID of the request. ### Request Example ```bash curl https://rpc.linea.build \ -X POST \ -H "Content-Type: application/json" \ -d '{ \ "jsonrpc": "2.0", \ "method": "debug_traceTransaction", \ "params": [ \ "0x972fd73b83ee0d567143ebc67509d4fc98fa1b1941c2c145a342d3d10715c259", \ {"tracer": "callTracer"} \ ], \ "id": 1 \ }' ``` ### Response #### Success Response (200) - **jsonrpc** (string) - The JSON-RPC protocol version. - **id** (number) - The ID of the request. - **result** (object) - The execution trace details. - **from** (string) - The sender address of the transaction. - **to** (string) - The recipient address of the transaction. - **gas** (string) - The total gas limit for the transaction. - **gasUsed** (string) - The amount of gas used during the transaction. - **input** (string) - The input data of the transaction. - **output** (string) - The output data of the transaction. - **calls** (array) - An array of nested calls made during the transaction. - **type** (string) - The type of call (e.g., `CALL`). #### Response Example ```json { "jsonrpc": "2.0", "id": 1, "result": { "from": "0xd26c8000ec8778de5257305c9acdd79f16f87867", "to": "0x6d7ac5d23266c9fea16463b877005bff6de531a7", "gas": "0x2635a", "gasUsed": "0x1458e", "input": "0x455ee4aa...", "output": "0x", "calls": [ { "from": "0x6d7ac5d23266c9fea16463b877005bff6de531a7", "to": "0xc76cabfb0d247b4dc0b38b00b2ca92f8e8c9d32b", "gas": "0x1ee7d", "gasUsed": "0x12364", "type": "DELEGATECALL" } ], "type": "CALL" } } ``` ``` -------------------------------- ### Install Openfort SDK Source: https://github.com/consensys/doc.linea/blob/main/docs/network/build/tools/social-login/openfort.mdx Use this command to create a new Openfort project. You will be prompted to enter your Openfort API keys and select a framework. ```bash npm create openfort ``` -------------------------------- ### Query Linea Rollup Contract for Finalized L2 Block Number Source: https://github.com/consensys/doc.linea/blob/main/docs/network/overview/transaction-finality.mdx This JavaScript code snippet demonstrates how to query the Linea L1 rollup contract to get the current finalized L2 block number. Replace the Infura endpoint with your preferred Ethereum L1 RPC provider. Ensure you have Node.js installed and the web3 package is installed. ```javascript const { Web3 } = require("web3") const web3 = new Web3(new Web3.providers.HttpProvider(`https://mainnet.infura.io/v3/`)) const lineaRollupAbi = [{"constant":true,"inputs":[],"name":"currentL2BlockNumber","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"}]; const lineaRollupAddress = '0xd19d4b5d358258f05d7b411e21a1460d11b0876f'; const lineaRollupContract = new web3.eth.Contract(lineaRollupAbi, lineaRollupAddress); async function getFinalizedL2BlockNumber() { try { const currentL2BlockNumber = await lineaRollupContract.methods.currentL2BlockNumber().call(); const blockNumberHex = '0x' + BigInt(currentL2BlockNumber).toString(16); console.log('Finalized L2 Block Number:', currentL2BlockNumber.toString()); console.log('Finalized L2 Block Number (Hex):', blockNumberHex); return { blockNumber: currentL2BlockNumber, blockNumberHex }; } catch (error) { console.error('Error fetching L2 block number:', error); } } getFinalizedL2BlockNumber(); ``` -------------------------------- ### Example ERC721Base Smart Contract Source: https://github.com/consensys/doc.linea/blob/main/docs/network/how-to/deploy-smart-contract/thirdweb.mdx This Solidity code defines an ERC721 contract that inherits from thirdweb's ERC721Base. It requires the name, symbol, royalty recipient address, and royalty basis points during deployment. Ensure you have the necessary thirdweb contracts installed. ```solidity // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@thirdweb-dev/contracts/base/ERC721Base.sol"; contract Contract is ERC721Base { constructor( string memory _name, string memory _symbol, address _royaltyRecipient, uint128 _royaltyBps ) ERC721Base(_name, _symbol, _royaltyRecipient, _royaltyBps) {} } ``` -------------------------------- ### Create and Format Volume on Ubuntu Source: https://github.com/consensys/doc.linea/blob/main/docs/network/how-to/run-a-node/volume-creation.mdx Use `fallocate` to create a file of a specified size and `mkfs.ext4` to format it as an ext4 filesystem. Mount the file using `mount -o loop`. ```bash fallocate -l 100G myfile.img ``` ```bash mkfs.ext4 myfile.img ``` ```bash mount -o loop myfile.img /mnt/myvolume ``` -------------------------------- ### Install DipDup CLI Source: https://github.com/consensys/doc.linea/blob/main/docs/network/build/tools/data-indexers/dipdup/quickstart.mdx Installs the DipDup CLI using a Python installer script. Ensure Python 3.11 is installed. ```bash curl -Lsf https://dipdup.io/install.py | python3 ``` -------------------------------- ### Navigate to Project Directory Source: https://github.com/consensys/doc.linea/blob/main/docs/network/build/launch-an-app/app.mdx Change into the newly created Next.js project directory to begin installing dependencies and configuring the app. ```bash cd my-linea-app ``` -------------------------------- ### Create a Foundry Project Source: https://github.com/consensys/doc.linea/blob/main/docs/network/how-to/deploy-smart-contract/foundry.mdx Initializes a new Foundry project with a sample contract, test, and script. ```bash forge init linea-tutorial ``` -------------------------------- ### Start Frontend Development Server Source: https://github.com/consensys/doc.linea/blob/main/docs/network/tutorials/voting-dapp.mdx Initiate the Next.js development server for the frontend application. ```bash pnpm dev ``` -------------------------------- ### Install Hardhat Source: https://github.com/consensys/doc.linea/blob/main/docs/network/how-to/deploy-smart-contract/hardhat.mdx Install Hardhat as a development dependency for your project. ```bash npm install --save-dev hardhat ``` -------------------------------- ### Create Project Directory Source: https://github.com/consensys/doc.linea/blob/main/docs/network/tutorials/marketplace-dapp.mdx Create a new directory for the frontend project and navigate into it. ```bash mkdir site cd site ``` -------------------------------- ### Initialize and Attach Disk Image on Windows Source: https://github.com/consensys/doc.linea/blob/main/docs/network/how-to/run-a-node/volume-creation.mdx Employ `diskpart` to select, create, and attach a virtual disk from a sparse file. This prepares the image for formatting. ```batch diskpart select vdisk file="myfile.img" create vdisk maximum=100000 attach vdisk exit ``` -------------------------------- ### Select Package Manager Source: https://github.com/consensys/doc.linea/blob/main/docs/network/tutorials/voting-dapp.mdx Choose your preferred package manager. pnpm is recommended for this tutorial. ```bash ? Please select the package manager you want to use: Yarn NPM ❯ pnpm ``` -------------------------------- ### Install dotenv Source: https://github.com/consensys/doc.linea/blob/main/docs/network/how-to/deploy-smart-contract/hardhat.mdx Install the dotenv package to load environment variables from your .env file. ```bash npm i -D dotenv ``` -------------------------------- ### Initialize Dynamic Provider and Connect Button Source: https://github.com/consensys/doc.linea/blob/main/docs/network/how-to/connect-wallet.mdx Set up the Dynamic context provider with your environment ID and wallet connectors, then include the DynamicConnectButton. ```tsx import { DynamicContextProvider, DynamicConnectButton } from "@dynamic-labs/sdk-react-core"; import { EthereumWalletConnectors } from "@dynamic-labs/ethereum"; export default function App() { return ( Connect wallet ); } ``` -------------------------------- ### Serve Local Build Source: https://github.com/consensys/doc.linea/blob/main/README.mdx After building the static content, run this command to serve the local build for testing. ```bash npm run serve ``` -------------------------------- ### Navigate to Site Directory Source: https://github.com/consensys/doc.linea/blob/main/docs/network/tutorials/voting-dapp.mdx Change the current directory to the 'site' package for frontend development. ```bash cd packages/site ``` -------------------------------- ### Initialize Node.js Project Source: https://github.com/consensys/doc.linea/blob/main/docs/network/how-to/deploy-smart-contract/hardhat.mdx Run this command to initialize a new Node.js project within your directory. ```bash npm init ``` -------------------------------- ### Set up Dynamic Context Provider Source: https://github.com/consensys/doc.linea/blob/main/docs/network/how-to/connect-wallet.mdx Wrap your application content with `DynamicContextProvider` and configure it with your environment ID and wallet connectors. ```tsx import { DynamicContextProvider } from "@dynamic-labs/sdk-react-core"; import { EthereumWalletConnectors } from "@dynamic-labs/ethereum"; export default function App() { return ( ); } ``` -------------------------------- ### Navigate to Project Directory Source: https://github.com/consensys/doc.linea/blob/main/docs/network/tutorials/voting-dapp.mdx Change your current directory to the newly created project folder. ```bash cd simple-voting-dapp ``` -------------------------------- ### Test Output Example Source: https://github.com/consensys/doc.linea/blob/main/docs/network/how-to/write-and-deploy-assertions.mdx Example output from running assertion tests, indicating successful execution of test cases. ```bash [PASS] test_assertionOwnershipChanged() (gas: 806650) [PASS] test_assertionOwnershipNotChanged() (gas: 804708) Suite result: ok. 2 passed; 0 failed; 0 skipped ``` -------------------------------- ### Build Static Documentation Source: https://github.com/consensys/doc.linea/blob/main/README.mdx This command generates static content into the 'build' directory, which can then be served using any static content hosting service. ```bash npm run build ``` -------------------------------- ### Initialize Hardhat Project Source: https://github.com/consensys/doc.linea/blob/main/docs/network/how-to/deploy-smart-contract/hardhat.mdx Initialize your Hardhat project. Follow the prompts to create a JavaScript project and accept default settings. ```bash npx hardhat init ``` -------------------------------- ### Initialize Next.js Project Source: https://github.com/consensys/doc.linea/blob/main/docs/network/tutorials/marketplace-dapp.mdx Command to initialize a new Next.js project with specified configurations. ```bash npx create-next-app@latest . ``` -------------------------------- ### Install Goldsky CLI Source: https://github.com/consensys/doc.linea/blob/main/docs/network/build/tools/data-indexers/goldsky/goldsky-mirror.mdx Install the Goldsky CLI globally using npm. This command is required before you can use any Goldsky CLI commands. ```bash npm install -g @goldskycom/cli ``` -------------------------------- ### Install Axios Source: https://github.com/consensys/doc.linea/blob/main/docs/api/reference/index.mdx Install the axios package using npm or yarn. This is required to make HTTP requests to the Linea RPC endpoint. ```bash npm i axios ``` ```bash yarn add axios ``` -------------------------------- ### Start Besu Node with Docker Compose Source: https://github.com/consensys/doc.linea/blob/main/docs/network/how-to/run-a-node/besu.mdx Execute this command in the terminal from the directory containing your `docker-compose.yml` file to start the Besu node. ```bash docker-compose up besu-node ``` -------------------------------- ### Initialize Envio Project - Choose Template Source: https://github.com/consensys/doc.linea/blob/main/docs/network/build/tools/data-indexers/envio.mdx Use this command to initialize a new Envio project. You will be prompted to choose between starting from a template or migrating from a subgraph. ```bash ? Would you like to start from a template or migrate from a subgraph? > "Template" "SubgraphMigration" [↑↓ to move, enter to select, type to filter] ```