### Download eventwatch.c for local installation example Source: https://docs.monad.xyz/execution-events/getting-started/c This set of commands creates a new directory for a CMake project that uses a locally installed SDK and downloads the 'eventwatch.c' source file from a GitHub URL. This prepares the environment for compiling 'eventwatch.c' using CMake's find_package functionality, pointing to the previously installed SDK. ```bash $ mkdir ~/src/event-sdk-example-c-find-package $ cd ~/src/event-sdk-example-c-find-package $ curl -O https://raw.githubusercontent.com/category-labs/monad/refs/heads/release/exec-events-sdk-v1.x/category/event/example/eventwatch.c ``` -------------------------------- ### Install Monad Event SDK locally with CMake Source: https://docs.monad.xyz/execution-events/getting-started/c This sequence of CMake and shell commands installs the Monad Event SDK ('libmonad_event.a') to a specified local directory ('/tmp/sdk-install-demo'). It first clones the SDK repository, then configures the build for the event category with Ninja, setting the installation prefix and build type. Finally, it builds the SDK and installs it. ```bash $ git clone -b release/exec-events-sdk-v1.x https://github.com/category-labs/monad.git \ ~/src/monad-exec-events-sdk $ cmake -S ~/src/monad-exec-events-sdk/category/event \ -B ~/build/monad-exec-events-sdk-v1-release -G Ninja \ -DCMAKE_INSTALL_PREFIX=/tmp/sdk-install-demo -DCMAKE_BUILD_TYPE=RelWithDebInfo $ cmake --build ~/build/monad-exec-events-sdk-v1-release $ cmake --install ~/build/monad-exec-events-sdk-v1-release ``` -------------------------------- ### Download Example Program Source - Shell Commands Source: https://docs.monad.xyz/execution-events/getting-started/c Commands to create a directory, navigate into it, and download the C example program source file (eventwatch.c) using curl. ```shell $ mkdir ~/src/event-sdk-example-c $ cd ~/src/event-sdk-example-c $ curl -O https://raw.githubusercontent.com/category-labs/monad/refs/heads/release/exec-events-sdk-v1.x/category/event/example/eventwatch.c ``` -------------------------------- ### Run Rust Block Explorer Example Source: https://docs.monad.xyz/execution-events/getting-started/final Command to run the Rust 'Block Explorer' TUI example from the upstream `monad-bft` repository. This provides a more sophisticated example of the execution event system. ```shell cargo run -p monad-exec-events --example explorer ``` -------------------------------- ### Create new Rust package and download example code Source: https://docs.monad.xyz/execution-events/getting-started/rust Steps to create a new Rust project using Cargo and download the example event watch program from GitHub. ```bash $ cargo new --bin event-sdk-example-rust $ cd event-sdk-example-rust $ curl https://raw.githubusercontent.com/category-labs/monad-bft/refs/heads/release/exec-events-sdk-v1.x/monad-exec-events/examples/eventwatch.rs > src/main.rs ``` -------------------------------- ### Run Rust Example Program Source: https://docs.monad.xyz/execution-events/getting-started/final Command to run the Rust SDK example program. Requires the execution daemon to be running with execution events enabled via the `--exec-event-ring` argument. ```shell cargo run -- -d ``` -------------------------------- ### Install Project Dependencies Source: https://docs.monad.xyz/guides/reown-guide Navigates to the project directory and installs necessary dependencies using npm. Supports alternative package managers like yarn, bun, or pnpm. ```bash cd my-monad-appkit-app npm install ``` -------------------------------- ### Install web3.py Source: https://docs.monad.xyz/reference/websockets Installs the web3.py library, a Python dependency for interacting with Ethereum blockchains, including WebSocket connections. ```bash pip install web3 ``` -------------------------------- ### Create CMakeLists.txt for Example Program - CMake Source: https://docs.monad.xyz/execution-events/getting-started/c A basic CMakeLists.txt file to set up a C project named 'eventwatch' and prepare for SDK integration. ```cmake cmake_minimum_required(VERSION 3.21) project(eventwatch LANGUAGES C) # # SDK setup ``` -------------------------------- ### Run Development Server Source: https://docs.monad.xyz/guides/reown-guide Starts the development server for the application. The app will typically be available at `http://localhost:3000`. Supports alternative commands for different package managers. ```bash npm run dev ``` -------------------------------- ### Install Project Dependencies Source: https://docs.monad.xyz/guides/blinks-guide Installs the required libraries for connecting wallets and managing application state. ```bash npm install connectkit @tanstack/react-query @dialectlabs/blinks ``` -------------------------------- ### Create New Project with AppKit CLI Source: https://docs.monad.xyz/guides/reown-guide Initiates the creation of a new project configured with Reown AppKit. Prompts for project name, framework (e.g., Next.js), and blockchain library (e.g., Wagmi or Ethers). ```bash npx @reown/appkit-cli ``` -------------------------------- ### Install ethers.js Source: https://docs.monad.xyz/reference/websockets Installs the ethers.js library, a JavaScript dependency for interacting with Ethereum blockchains, including WebSocket connections. ```bash npm install ethers ``` -------------------------------- ### Configure Environment Variables Source: https://docs.monad.xyz/templates/next-serwist-thirdweb Example environment variables required for Thirdweb and Web Push configuration. ```env # Thirdweb Configuration (Required) NEXT_PUBLIC_THIRDWEB_CLIENT_ID=your_thirdweb_client_id_here # Web Push (Required) WEB_PUSH_EMAIL=user@example.com WEB_PUSH_PRIVATE_KEY=your_vapid_private_key NEXT_PUBLIC_WEB_PUSH_PUBLIC_KEY=your_vapid_public_key ``` -------------------------------- ### Install Project Dependencies Source: https://docs.monad.xyz/templates/farcaster-miniapp/getting-started Installs the necessary project dependencies using Yarn. ```bash yarn ``` -------------------------------- ### Run Rust example program Source: https://docs.monad.xyz/execution-events/getting-started/rust Command to execute the compiled Rust program, demonstrating how to pass command-line arguments. ```bash cargo run -- -h ``` -------------------------------- ### Build and Start Project Commands Source: https://docs.monad.xyz/templates/next-serwist-0x-privy-embedded-wallet These commands are used to build the project after making changes, such as adding new tokens, and then to start the application. Running `npm run build` compiles your project, applying all modifications. `npm run start` then launches the application, making the new tokens available in the UI. ```bash npm run build npm run start ``` -------------------------------- ### Set up Local Environment Variables Source: https://docs.monad.xyz/templates/farcaster-miniapp/getting-started Copies the example environment file to `.env.local` for local development configuration. ```bash cp .env.example .env.local ``` -------------------------------- ### Install Foundryup (Shell) Source: https://docs.monad.xyz/guides/deploy-smart-contract/foundry Installs the Foundryup tool, which is the official installer for the Foundry toolchain. This command downloads and executes an installation script. ```shell curl -L https://foundry.paradigm.xyz | bash ``` -------------------------------- ### Run Development Server Source: https://docs.monad.xyz/templates/farcaster-miniapp/getting-started Starts the development server for the Farcaster Mini App template. ```bash yarn run dev ``` -------------------------------- ### Install Hardhat Dependencies Source: https://docs.monad.xyz/guides/scaffold-eth Navigates into the cloned Hardhat repository and installs project dependencies using Yarn. ```shell cd scaffold-monad-hardhat && yarn install ``` -------------------------------- ### Install Cloudflared via Homebrew Source: https://docs.monad.xyz/templates/farcaster-miniapp/getting-started Installs the `cloudflared` tool using the Homebrew package manager to expose local servers remotely. ```bash brew install cloudflared ``` -------------------------------- ### Install Foundry Binaries (Shell) Source: https://docs.monad.xyz/guides/deploy-smart-contract/foundry Installs the core Foundry binaries: forge, cast, anvil, and chisel. This command is run after foundryup has been installed. ```shell foundryup ``` -------------------------------- ### Install Foundry Dependencies Source: https://docs.monad.xyz/guides/scaffold-eth Navigates into the cloned repository and installs project dependencies using Yarn. This is required before running any commands. ```shell cd scaffold-monad-foundry && yarn install ``` -------------------------------- ### Build eventwatch with CMake, Ninja, and alternate compiler Source: https://docs.monad.xyz/execution-events/getting-started/c This command sequence demonstrates building the 'eventwatch' program using CMake with the Ninja build tool and specifying an alternative C compiler (gcc-15) via the CC environment variable. Similar to the previous example, it configures the build in a 'build' subdirectory and then uses 'ninja' to compile the project. ```bash $ CC=gcc-15 cmake -S ~/src/event-sdk-example-c -B ~/src/event-sdk-example-c/build -G Ninja $ cd ~/src/event-sdk-example-c/build $ ninja ``` -------------------------------- ### Example Command Line: Event Ring Path Source: https://docs.monad.xyz/execution-events/event-ring An example of the command-line parameter specifying only the event ring file path. ```bash --exec-event-ring /var/lib/hugetlbfs/user/monad/pagesize-2MB/event-rings/monad-exec-events ``` -------------------------------- ### Install Solana Actions Dependencies Source: https://docs.monad.xyz/guides/blinks-guide Installs necessary npm packages for building Solana Actions, including `@solana/actions`, `wagmi`, and `viem`. Assumes Node.js environment. ```bash npm install @solana/actions wagmi viem@2.x ``` -------------------------------- ### Start Local Blockchain Node (Foundry) Source: https://docs.monad.xyz/guides/scaffold-eth Starts a local blockchain node using Yarn. This command is essential for testing smart contract deployments locally. ```shell yarn chain ``` -------------------------------- ### Create and Configure .env.local Source: https://docs.monad.xyz/templates/next-serwist-privy-smart-wallet Copies the example environment file and outlines the required environment variables for Privy and Pimlico configuration. ```bash cp .env.example .env.local # Privy NEXT_PUBLIC_PRIVY_APP_ID=your_privy_app_id_here NEXT_PUBLIC_PRIVY_CLIENT_ID= # optional, you can leave this empty # Web Push WEB_PUSH_EMAIL=user@example.com WEB_PUSH_PRIVATE_KEY=your_vapid_private_key NEXT_PUBLIC_WEB_PUSH_PUBLIC_KEY=your_vapid_public_key # Pimlico NEXT_PUBLIC_PIMLICO_BUNDLER_URL=your_pimlico_bundler_url ``` -------------------------------- ### Install Project Dependencies Source: https://docs.monad.xyz/guides/deploy-smart-contract/hardhat Installs all necessary Node.js dependencies for the Hardhat project using npm. ```bash npm install ``` -------------------------------- ### Start NextJS App Source: https://docs.monad.xyz/guides/scaffold-eth Starts the NextJS application, allowing interaction with the deployed smart contract via a web interface. The app is accessible at http://localhost:3000. ```shell yarn start ``` -------------------------------- ### Example Command Line: Event Ring with Shifts Source: https://docs.monad.xyz/execution-events/event-ring An example of the command-line parameter specifying the event ring name along with descriptor and payload buffer shifts. ```bash --exec-event-ring monad-exec-events:21:29 ``` -------------------------------- ### Install Vercel CLI Source: https://docs.monad.xyz/templates/next-serwist-privy-embedded-wallet Installs the Vercel Command Line Interface globally on your system, enabling deployment and management of Vercel projects from your terminal. ```bash npm i -g vercel ``` -------------------------------- ### Fetch Monad Event SDK via FetchContent (CMake) Source: https://docs.monad.xyz/execution-events/getting-started/c This CMake snippet demonstrates how to declare and make available the execution events C SDK directly from a Git repository using FetchContent. It specifies the repository, tag, shallow clone, exclusion of submodules, and a subdirectory for the top-level CMakeLists.txt to build only the 'monad_event' library. It also disables the SDK's example to prevent naming conflicts. ```cmake include(FetchContent) FetchContent_Declare(exec_events_c_sdk GIT_REPOSITORY git@github.com:category-labs/monad.git GIT_TAG release/exec-events-sdk-v1.x GIT_SHALLOW TRUE GIT_SUBMODULES "" SOURCE_SUBDIR category/event) set(MONAD_EVENT_BUILD_EXAMPLE OFF CACHE INTERNAL "") FetchContent_MakeAvailable(exec_events_c_sdk) add_executable(eventwatch eventwatch.c) target_compile_options(eventwatch PRIVATE -Wall -Wextra -Wconversion -Werror) target_link_libraries(eventwatch PRIVATE monad_event) ``` -------------------------------- ### Start Local Hardhat Node Source: https://docs.monad.xyz/guides/deploy-smart-contract/hardhat Starts a local Hardhat development network, which is useful for testing smart contracts without deploying to a public network. ```bash npx hardhat node ``` -------------------------------- ### Start Envio Indexer Development Mode Source: https://docs.monad.xyz/guides/indexers/tg-bot-using-envio Starts the Envio indexer in development mode using the `pnpx envio dev` command. This command initiates the process of syncing blockchain data and makes the indexer accessible for querying. ```bash pnpx envio dev ``` -------------------------------- ### Deep Link Examples for Monad Wallet Source: https://docs.monad.xyz/guides/deeplinks-using-expo Various deep links demonstrating different swap scenarios for the Monad wallet. These examples cover swapping between different tokens and specifying amounts. ```plaintext rnwalletapp://swap?from=MON&to=USDC ``` ```plaintext rnwalletapp://swap?from=MON&to=USDC&amount=100 ``` ```plaintext rnwalletapp://swap?from=USDC&to=WMON&amount=1000 ``` -------------------------------- ### Clone Foundry Scaffold Source: https://docs.monad.xyz/guides/scaffold-eth Clones the Scaffold-ETH Foundry repository. This is the initial step to start a dApp project using the Foundry framework. ```shell git clone https://github.com/monad-developers/scaffold-monad-foundry.git ``` -------------------------------- ### Clone Repository using Git Source: https://docs.monad.xyz/templates/next-serwist-thirdweb Clones the Next.js Serwist Thirdweb repository from GitHub to your local machine. ```bash git clone https://github.com/monad-developers/next-serwist-thirdweb.git ``` -------------------------------- ### Get Transaction by Hash Example (JSON) Source: https://docs.monad.xyz/reference/json-rpc/eth_getTransactionByHash Provides an example JSON response for the eth_getTransactionByHash RPC method, detailing transaction properties such as type, chain ID, nonce, gas, gas price, sender, receiver, value, input data, and signature components. ```json { "type": "0x2", "chainId": "0x1", "nonce": "0x16d", "gas": "0x46a02", "maxFeePerGas": "0x7fc1a20a8", "maxPriorityFeePerGas": "0x59682f00", "to": "0x68b3465833fb72a70ecdf485e0e4c7bd8665fc45", "value": "0x4a6ed55bbcc180", "accessList": [], "input": "0x5ae401dc00000000000000000000000000000000000000000000000000000000628ced5b0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000000e442712a6700000000000000000000000000000000000000000000b3ff1489674e11c40000000000000000000000000000000000000000000000000000004a6ed55bbcc18000000000000000000000000000000000000000000000000000000000000000800000000000000000000000003cf412d970474804623bb4e3a42de13f9bca54360000000000000000000000000000000000000000000000000000000000000002000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000003a75941763f31c930b19c041b709742b0b31ebb600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000412210e8a00000000000000000000000000000000000000000000000000000000", "r": "0x7f2153019a74025d83a73effdd91503ceecefac7e35dd933adc1901c875539aa", "s": "0x334ab2f714796d13c825fddf12aad01438db3a8152b2fe3ef7827707c25ecab3", "yParity": "0x0", "v": "0x0", "hash": "0x0e07d8b53ed3d91314c80e53cf25bcde02084939395845cbb625b029d568135c", "blockHash": "0x883f974b17ca7b28cb970798d1c80f4d4bb427473dc6d39b2a7fe24edc02902d", "blockNumber": "0xe26e6d", "transactionIndex": "0xad", "from": "0x3cf412d970474804623bb4e3a42de13f9bca5436", "gasPrice": "0x50101df3a" } ``` -------------------------------- ### Configure Monad Testnet Network Source: https://docs.monad.xyz/guides/reown-guide Updates the `/src/config/index.ts` file to specify Monad Testnet as the network for the application, replacing the default networks. ```typescript import { mainnet, monadTestnet } from '@reown/appkit/networks' export const networks = [monadTestnet] as [AppKitNetwork, ...AppKitNetwork[]] ``` -------------------------------- ### ChainSight Oracles Source: https://docs.monad.xyz/tooling-and-infra/oracles ChainSight enhances oracles with no-code tools, aiming to reduce costs, mitigate single-operator risks, and foster scalable, open innovation. Developers can find detailed documentation for getting started. ```APIDOC ## ChainSight Oracles ### Description ChainSight offers no-code tools to improve oracle functionalities, focusing on cost reduction, minimizing risks associated with single operators, and promoting scalable, open innovation. It aims to simplify the integration and management of oracle services. ### Benefits - No-code tools for oracle implementation - Reduced costs - Mitigation of single-operator risks - Support for scalable, open innovation ### Getting Started Consult the ChainSight documentation for initial setup and usage instructions. ``` -------------------------------- ### Clone monad-mcp-tutorial repository Source: https://docs.monad.xyz/guides/monad-mcp Clones the GitHub repository containing starter code for the Monad MCP tutorial. Requires Git to be installed. ```bash git clone https://github.com/monad-developers/monad-mcp-tutorial.git ``` -------------------------------- ### Build and Run Commands for Eventwatch Source: https://docs.monad.xyz/execution-events/getting-started/c These commands demonstrate how to configure, build, and run the 'eventwatch' application using CMake and Ninja. The first command configures the build, the second builds the project, and the third executes the compiled application. ```bash $ cmake -S . -B build -G Ninja $ cmake --build build $ build/eventwatch ``` -------------------------------- ### Get Transaction by Block Hash and Index (JSON Example) Source: https://docs.monad.xyz/reference/json-rpc/eth_getTransactionByBlockHashAndIndex Provides an example JSON object representing transaction details fetched using `eth_getTransactionByBlockHashAndIndex`. This includes transaction type, chain ID, nonce, gas, fees, sender, receiver, value, access list, input data, signature components (r, s, v, yParity), hash, block hash, block number, transaction index, and the sender's address. ```json { "type": "0x2", "chainId": "0x1", "nonce": "0x16d", "gas": "0x46a02", "maxFeePerGas": "0x7fc1a20a8", "maxPriorityFeePerGas": "0x59682f00", "to": "0x68b3465833fb72a70ecdf485e0e4c7bd8665fc45", "value": "0x4a6ed55bbcc180", "accessList": [], "input": "0x5ae401dc00000000000000000000000000000000000000000000000000000000628ced5b0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000000e442712a6700000000000000000000000000000000000000000000b3ff1489674e11c40000000000000000000000000000000000000000000000000000004a6ed55bbcc18000000000000000000000000000000000000000000000000000000000000000800000000000000000000000003cf412d970474804623bb4e3a42de13f9bca54360000000000000000000000000000000000000000000000000000000000000002000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000003a75941763f31c930b19c041b709742b0b31ebb600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000412210e8a00000000000000000000000000000000000000000000000000000000", "r": "0x7f2153019a74025d83a73effdd91503ceecefac7e35dd933adc1901c875539aa", "s": "0x334ab2f714796d13c825fddf12aad01438db3a8152b2fe3ef7827707c25ecab3", "yParity": "0x0", "v": "0x0", "hash": "0x0e07d8b53ed3d91314c80e53cf25bcde02084939395845cbb625b029d568135c", "blockHash": "0x883f974b17ca7b28cb970798d1c80f4d4bb427473dc6d39b2a7fe24edc02902d", "blockNumber": "0xe26e6d", "transactionIndex": "0xad", "from": "0x3cf412d970474804623bb4e3a42de13f9bca5436", "gasPrice": "0x50101df3a" } ``` -------------------------------- ### Configure Environment Variables for Project ID Source: https://docs.monad.xyz/guides/reown-guide Sets up the `.env` file in the project root to store the Project ID obtained from the Reown Dashboard. Environment variables prefixed with `NEXT_PUBLIC_` are exposed to the client. ```dotenv NEXT_PUBLIC_PROJECT_ID="YOUR_PROJECT_ID_HERE" ``` -------------------------------- ### Build eventcap using CMake Toolchain Source: https://docs.monad.xyz/execution-events/getting-started/final Command to build the `eventcap` project using a CMake toolchain file, simplifying the configuration of compilers and flags like `-march=x86-64-v4`, `-stdlib=libc++`, and `-fexperimental-library`. ```shell $ cmake --toolchain -S ~/src/monad-eventcap/cmd/eventcap \ -B ~/build/monad-eventcap-release -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo ``` -------------------------------- ### JavaScript: Real-time Data Streaming Example Source: https://docs.monad.xyz/reference/websockets Illustrates how a JavaScript library might abstract away the underlying Geth real-time events protocol. It focuses on presenting real-time data through a different API design, without explicit mention of subscription names like 'newHeads'. ```javascript import { Web3 } from 'web3'; const web3 = new Web3('ws://localhost:8546'); web3.eth.subscribe('newHeads', (error, result) => { if (error) { console.error(error); } else { console.log(result); } }); ``` -------------------------------- ### Clone Cat Token Tutorial Repository Source: https://docs.monad.xyz/guides/indexers/ghost Clones the starter repository for the CatToken tutorial and navigates into the project directory. This is the initial setup step for the project. ```bash git clone https://github.com/chrischang/cat-token-tutorial.git cd cat-token-tutorial ``` -------------------------------- ### CMakeLists.txt Configuration for Eventwatch Source: https://docs.monad.xyz/execution-events/getting-started/c This CMakeLists.txt file configures the build for the 'eventwatch' executable. It specifies the minimum CMake version, project name, finds the required monad_exec_events_sdk package, defines the executable, sets compile options, and links the monad_event library. ```cmake cmake_minimum_required(VERSION 3.21) project(eventwatch LANGUAGES C) find_package(monad_exec_events_sdk REQUIRED PATHS /tmp/sdk-install-demo/lib/cmake/category-labs) add_executable(eventwatch eventwatch.c) target_compile_options(eventwatch PRIVATE -Wall -Wextra -Wconversion -Werror) target_link_libraries(eventwatch PRIVATE monad_event) ``` -------------------------------- ### Get Validator Sets (Paginated) Source: https://docs.monad.xyz/developer-essentials/staking/staking-precompile Fetches lists of validator IDs for consensus, snapshot, and execution contexts in a paginated manner. Each call returns a subset of validator IDs along with pagination controls (isDone, nextIndex), allowing efficient retrieval of large validator sets. The `startIndex` parameter controls the starting point of the retrieval. ```Solidity function getConsensusValidatorSet( uint32 startIndex ) external returns (bool isDone, uint32 nextIndex, uint64[] memory valIds); ``` ```Solidity function getSnapshotValidatorSet( uint32 startIndex ) external returns (bool isDone, uint32 nextIndex, uint64[] memory valIds); ``` ```Solidity function getExecutionValidatorSet( uint32 startIndex ) external returns (bool isDone, uint32 nextIndex, uint64[] memory valIds); ``` -------------------------------- ### Build and Run eventcap using clang-19 and libc++ Source: https://docs.monad.xyz/execution-events/getting-started/final Steps to clone the Monad repository, configure the CMake build for `eventcap` using clang-19 with specific CFLAGS and CXXFLAGS (including libc++ and `-fexperimental-library`), and build the project. ```shell $ git clone -b release/exec-events-sdk-v1.x https://github.com/category-labs/monad.git \ ~/src/monad-eventcap $ CC=clang-19 CFLAGS="-march=x86-64-v4" \ CXX=clang++-19 CXXFLAGS="-stdlib=libc++ -fexperimental-library -march=x86-64-v4" cmake \ -S ~/src/monad-eventcap/cmd/eventcap -B ~/build/monad-eventcap-release -G Ninja \ -DCMAKE_BUILD_TYPE=RelWithDebInfo $ cmake --build ~/build/monad-eventcap-release ``` -------------------------------- ### Install Dependencies with Yarn Source: https://docs.monad.xyz/templates/react-native-thirdweb-embedded-wallet Installs project dependencies using Yarn. This is a standard step for Node.js projects to manage package installations. ```bash yarn install ``` -------------------------------- ### Execute eventcap Source: https://docs.monad.xyz/execution-events/getting-started/final Command to execute the built `eventcap` program to see its help message. This utility decodes execution event payloads and performs other tasks related to the event system. ```shell $ ~/build/monad-eventcap-release/eventcap --help ``` -------------------------------- ### Build eventwatch with CMake and make Source: https://docs.monad.xyz/execution-events/getting-started/c This code block shows the command-line execution of CMake to configure the build for the 'eventwatch' program using the default compiler and the 'make' build system. It assumes the source code is located at '~/src/event-sdk-example-c' and the build output will be in '~/src/event-sdk-example-c/build'. After configuration, it navigates into the build directory and invokes 'make' to compile the project. ```bash $ cmake -S ~/src/event-sdk-example-c -B ~/src/event-sdk-example-c/build $ cd ~/src/event-sdk-example-c/build $ make ``` -------------------------------- ### Start App - Android (npm) Source: https://docs.monad.xyz/templates/react-native-privy-embedded-wallet Starts the React Native application in the Expo Go app on an Android emulator or device. This command uses npm to run the start script for Android. ```bash npm run android ``` -------------------------------- ### Clone Monad Farcaster Mini App Template Source: https://docs.monad.xyz/templates/farcaster-miniapp/getting-started Clones the Monad Farcaster Mini App template repository from GitHub to your local machine. ```bash git clone https://github.com/monad-developers/monad-miniapp-template.git ``` -------------------------------- ### Start App - iOS (npm) Source: https://docs.monad.xyz/templates/react-native-privy-embedded-wallet Starts the React Native application in the Expo Go app on an iOS simulator or device. This command uses npm to run the start script for iOS. ```bash npm run ios ``` -------------------------------- ### Set up .env file Source: https://docs.monad.xyz/guides/deploy-smart-contract/hardhat Copies the example environment file to .env. This file is used to store sensitive information like private keys. ```bash cp .env.example .env ``` -------------------------------- ### Add CMake Subproject - Add Subdirectory Source: https://docs.monad.xyz/execution-events/getting-started/c Integrates the SDK as a CMake subproject by adding its source directory. This makes the SDK's library target available to the parent project. ```cmake add_subdirectory(/category/event) ``` -------------------------------- ### Configure Rust project dependencies in Cargo.toml Source: https://docs.monad.xyz/execution-events/getting-started/rust Defines the project's metadata and dependencies, including the Monad execution event SDK packages sourced directly from a Git repository. ```toml [package] name = "event-sdk-example-rust" version = "0.1.0" edition = "2021" [dependencies] chrono = "0.4.34" clap = { version = "4.2", features = ["derive"] } lazy_static = "1.5.0" [dependencies.monad-exec-events] git = "https://github.com/category-labs/monad-bft" branch = "release/exec-events-sdk-v1.x" [dependencies.monad-event-ring] git = "https://github.com/category-labs/monad-bft" branch = "release/exec-events-sdk-v1.x" ``` -------------------------------- ### Install @vercel/og Package Source: https://docs.monad.xyz/templates/farcaster-miniapp/generating-custom-og-images This command installs the `@vercel/og` package, which is essential for generating images in your application. ```bash npm install @vercel/og ``` -------------------------------- ### Set Up Environment Variables for Deployment Source: https://docs.monad.xyz/guides/indexers/ghost Copies the example environment file and instructs to add private key and RPC URL for Monad Testnet. These variables are crucial for deploying the contract. ```bash cp .env.example .env ``` ```bash PRIVATE_KEY=your_private_key_here MONAD_TESTNET_RPC=https://testnet-rpc.monad.xyz ``` -------------------------------- ### CMake Toolchain File for clang-19 and libc++ Source: https://docs.monad.xyz/execution-events/getting-started/final Contents of a CMake toolchain file (`clang19-libcxx.cmake`) to simplify the build process for `eventcap` when using clang-19, libc++, and specific C++ standard library flags. ```cmake set(CMAKE_C_COMPILER clang-19) set(CMAKE_CXX_COMPILER clang++-19) set(CMAKE_ASM_FLAGS_INIT -march=x86-64-v4) set(CMAKE_C_FLAGS_INIT -march=x86-64-v4) set(CMAKE_CXX_FLAGS_INIT "-march=x86-64-v4 -stdlib=libc++ -fexperimental-library") ``` -------------------------------- ### Run eventwatch executable Source: https://docs.monad.xyz/execution-events/getting-started/c This command executes the compiled 'eventwatch' program with the '-h' flag to display its usage information, including available options and positional arguments. This is typically done after a successful build to verify the executable and understand its functionality. ```bash $ ./eventwatch -h ``` -------------------------------- ### eth_feeHistory RPC Method Response Example Source: https://docs.monad.xyz/reference/json-rpc/eth_feeHistory An example of the expected JSON response structure when calling the eth_feeHistory RPC method. It shows the format for gasUsedRatio and oldestBlock. ```json { "gasUsedRatio": [], "oldestBlock": "0x0" } ``` -------------------------------- ### Build Rust project and specify C compiler Source: https://docs.monad.xyz/execution-events/getting-started/rust Command to build the Rust project using Cargo. Shows how to set the CC environment variable to use a specific C compiler if needed. ```bash cargo build CC=gcc-15 cargo build ``` -------------------------------- ### Install Expo CLI Globally (npm) Source: https://docs.monad.xyz/templates/react-native-privy-embedded-wallet Installs the Expo CLI globally on your system, which is a prerequisite for managing and running Expo projects. Requires Node.js and npm. ```bash npm i -g expo-cli ``` -------------------------------- ### Start Execution Daemon with Event Ring Parameter Source: https://docs.monad.xyz/execution-events/event-ring This command starts the execution daemon with support for execution events. The optional string configures the event ring, defaulting to 'monad-exec-events' if omitted. ```bash --exec-event-ring [] ``` -------------------------------- ### Initialize Envio Project Source: https://docs.monad.xyz/guides/indexers/tg-bot-using-envio Initializes a new Envio project using the `pnpx envio init` command. This command guides the user through configuration steps such as selecting the language, blockchain ecosystem, ABI import method, contract details, and network ID. ```bash pnpx envio init ``` -------------------------------- ### GET Endpoint: Blink Metadata and UI Configuration (TypeScript) Source: https://docs.monad.xyz/guides/blinks-guide Defines the GET endpoint for a Blink action, returning metadata and UI configuration. It specifies how the action appears in clients, required parameters, and execution details. Dependencies include '@solana/actions'. ```typescript import { ActionGetResponse, } from "@solana/actions"; // GET endpoint returns the Blink metadata (JSON) and UI configuration export const GET = async (req: Request) => { // This JSON is used to render the Blink UI const response: ActionGetResponse = { type: "action", icon: `${new URL("/donate-mon.png", req.url).toString()}`, label: "1 MON", title: "Donate MON", description: "This Blink demonstrates how to donate MON on the Monad blockchain. It is a part of the official Blink Starter Guides by Dialect Labs. \n\nLearn how to build this Blink: https://dialect.to/docs/guides/donate-mon", // Links is used if you have multiple actions or if you need more than one params links: { actions: [ { // Defines this as a blockchain transaction type: "transaction", label: "0.01 MON", // This is the endpoint for the POST request href: `/api/actions/donate-mon?amount=0.01`, }, { type: "transaction", label: "0.05 MON", href: `/api/actions/donate-mon?amount=0.05`, }, { type: "transaction", label: "0.1 MON", href: `/api/actions/donate-mon?amount=0.1`, }, { // Example for a custom input field type: "transaction", href: `/api/actions/donate-mon?amount={amount}`, label: "Donate", parameters: [ { name: "amount", label: "Enter a custom MON amount", type: "number", }, ], }, ], }, }; // Return the response with proper headers return new Response(JSON.stringify(response), { status: 200, headers, }); }; ``` -------------------------------- ### Run Next.js Application Source: https://docs.monad.xyz/templates/next-serwist-privy-smart-wallet Commands to run the Next.js application in development and production modes. Includes building for PWA functionality. ```bash # Development Mode npm run dev # Production Mode: # For full PWA functionality (including install prompts): npm run build && npm run start ``` -------------------------------- ### Initialize Next.js Project Source: https://docs.monad.xyz/guides/blinks-guide Command to create a new Next.js project with TypeScript and other configurations. Requires Node.js 18.x.x or above. ```bash npx create-next-app@14 blink-starter-monad && cd blink-starter-monad ``` -------------------------------- ### Install Axios Package Source: https://docs.monad.xyz/guides/indexers/tg-bot-using-envio This command installs the 'axios' package, a popular promise-based HTTP client for the browser and Node.js, using the pnpm package manager. Axios is required for making HTTP requests to interact with APIs, such as the Telegram Bot API. ```bash pnpm i axios ``` -------------------------------- ### Monad EVM Transaction Header Start Event Structure (C) Source: https://docs.monad.xyz/execution-events/overview Defines the C structure for the 'start of transaction header' event payload. This event is recorded after a new transaction is decoded by the EVM and contains key transaction information. The structure includes the transaction hash, sender address, and the nested transaction header. ```c /// First event recorded when transaction processing starts struct monad_exec_txn_header_start { monad_c_bytes32 txn_hash; ///< Keccak hash of transaction RLP monad_c_address sender; ///< Recovered sender address struct monad_c_eth_txn_header txn_header; ///< Transaction header }; ``` -------------------------------- ### Example: Adding shMON Token Configuration Source: https://docs.monad.xyz/templates/next-serwist-0x-privy-embedded-wallet This example provides the concrete implementation for adding the 'shMON' token to the Monad testnet token configurations. It shows the correct structure for the `MONAD_TESTNET_TOKENS` array, the `MONAD_TESTNET_TOKENS_BY_SYMBOL` record (using 'shmon' as the key), and the `MONAD_TESTNET_TOKENS_BY_ADDRESS` record (using the lowercase contract address as the key). ```typescript // In MONAD_TESTNET_TOKENS array { chainId: 1, name: "shMonad", symbol: "shMON", decimals: 18, address: "0x3a98250F98Dd388C211206983453837C8365BDc1", logoURI: "put_your_logo_url_here_or_use_the_default_logo", }, // In MONAD_TESTNET_TOKENS_BY_SYMBOL record shmon: { chainId: 1, name: "shMonad", symbol: "shMON", decimals: 18, address: "0x3a98250F98Dd388C211206983453837C8365BDc1", logoURI: "put_your_logo_url_here_or_use_the_default_logo", }, // In MONAD_TESTNET_TOKENS_BY_ADDRESS record "0x3a98250F98Dd388C211206983453837C8365BDc1": { chainId: 1, name: "shMonad", symbol: "shMON", decimals: 18, address: "0x3a98250F98Dd388C211206983453837C8365BDc1", logoURI: "put_your_logo_url_here_or_use_the_default_logo", }, ``` -------------------------------- ### Get Validator Information Source: https://docs.monad.xyz/developer-essentials/staking/staking-precompile Retrieves detailed information about a specific validator. ```APIDOC ## GET /staking/getValidator ### Description Retrieves detailed information about a specific validator. ### Method `view` ### Endpoint `getValidator` ### Parameters #### Path Parameters None #### Query Parameters - **validatorId** (uint64) - Required - The ID of the validator to retrieve information for. ### Request Example ```json { "validatorId": 123 } ``` ### Response #### Success Response (200) - **authAddress** (address) - The authorization address of the validator. - **flags** (uint64) - Flags indicating the validator's status. - **stake** (uint256) - The total stake amount for the validator. - **accRewardPerToken** (uint256) - Accumulated reward per token. - **commission** (uint256) - The current commission rate. - **unclaimedRewards** (uint256) - The amount of unclaimed rewards. - **consensusStake** (uint256) - The stake amount recognized by consensus. - **consensusCommission** (uint256) - The commission amount recognized by consensus. - **snapshotStake** (uint256) - The stake amount at the last snapshot. - **snapshotCommission** (uint256) - The commission amount at the last snapshot. - **secpPubkey** (bytes memory) - The validator's secp public key. - **blsPubkey** (bytes memory) - The validator's BLS public key. ``` -------------------------------- ### Get Delegators Source: https://docs.monad.xyz/developer-essentials/staking/staking-precompile Retrieves a paginated list of delegators for a given validator. ```APIDOC ## GET /websites/monad_xyz/getDelegators ### Description Retrieves a paginated list of delegators for a given validator, starting from a specified delegator address. ### Method GET ### Endpoint /websites/monad_xyz/getDelegators ### Parameters #### Path Parameters - **validatorId** (uint64) - Required - The ID of the validator for which we want to know the delegators. - **startDelegator** (address) - Required - The address of the delegator to start the pagination from. ### Response #### Success Response (200) - **isDone** (bool) - Indicates whether the end of the list has been reached. - **nextDelegator** (address) - The next delegator address to use for pagination. - **delegators** (address[]) - An array of delegator addresses. #### Response Example ```json { "isDone": false, "nextDelegator": "0xdef456", "delegators": [ "0xabc123", "0xdef456", "0xghi789" ] } ``` ``` -------------------------------- ### Create Project Directory and Navigate Source: https://docs.monad.xyz/guides/indexers/tg-bot-using-envio Initializes a new project directory and changes the current directory into it. This is the first step in setting up the Envio HyperIndex project. ```bash mkdir envio-mon && cd envio-mon ``` -------------------------------- ### Get Delegators Source: https://docs.monad.xyz/developer-essentials/staking/staking-precompile Retrieves a paginated list of delegator addresses for a specific validator. ```APIDOC ## GET /staking/getDelegators ### Description Retrieves a paginated list of delegator addresses for a specific validator. ### Method `external` ### Endpoint `getDelegators` ### Parameters #### Path Parameters None #### Query Parameters - **validatorId** (uint64) - Required - The ID of the validator. - **startDelegator** (address) - Required - The starting delegator address for pagination. ### Request Example ```json { "validatorId": 123, "startDelegator": "0x000..." } ``` ### Response #### Success Response (200) - **isDone** (bool) - Indicates if this is the last page of results. - **nextDelegator** (address) - The next delegator address to start pagination from. - **delegators** (address[]) - An array of delegator addresses. ``` -------------------------------- ### Deploy Project with Vercel CLI Source: https://docs.monad.xyz/templates/next-serwist-privy-embedded-wallet Initiates the deployment process for your project using the Vercel CLI. This command will guide you through project configuration and deployment. ```bash vercel ``` -------------------------------- ### Get Delegations Source: https://docs.monad.xyz/developer-essentials/staking/staking-precompile Retrieves a paginated list of validator IDs that a delegator has staked with. ```APIDOC ## GET /staking/getDelegations ### Description Retrieves a paginated list of validator IDs that a delegator has staked with. ### Method `external` ### Endpoint `getDelegations` ### Parameters #### Path Parameters None #### Query Parameters - **delegator** (address) - Required - The address of the delegator. - **startValId** (uint64) - Required - The starting validator ID for pagination. ### Request Example ```json { "delegator": "0xabc...", "startValId": 0 } ``` ### Response #### Success Response (200) - **isDone** (bool) - Indicates if this is the last page of results. - **nextValId** (uint64) - The next validator ID to start pagination from. - **valIds** (uint64[]) - An array of validator IDs the delegator is staked with. ``` -------------------------------- ### Expose Localhost with Cloudflared Source: https://docs.monad.xyz/templates/farcaster-miniapp/getting-started Creates a tunnel to expose a local server running on `http://localhost:3000` to the internet using `cloudflared`. ```bash cloudflared tunnel --url http://localhost:3000 ``` -------------------------------- ### Get Withdrawal Request Source: https://docs.monad.xyz/developer-essentials/staking/staking-precompile Retrieves details of a withdrawal request for a delegator on a specific validator. ```APIDOC ## GET /staking/getWithdrawalRequest ### Description Retrieves details of a withdrawal request for a delegator on a specific validator. ### Method `external` ### Endpoint `getWithdrawalRequest` ### Parameters #### Path Parameters None #### Query Parameters - **validatorId** (uint64) - Required - The ID of the validator. - **delegator** (address) - Required - The address of the delegator. - **withdrawId** (uint8) - Required - The ID of the withdrawal request. ### Request Example ```json { "validatorId": 123, "delegator": "0xabc...", "withdrawId": 1 } ``` ### Response #### Success Response (200) - **withdrawalAmount** (uint256) - The amount requested for withdrawal. - **accRewardPerToken** (uint256) - Accumulated reward per token at the time of request. - **withdrawEpoch** (uint64) - The epoch in which the withdrawal was requested. ```