### Install Dependencies for Native Installation Source: https://github.com/mezo-org/documentation/blob/main/src/content/docs/docs/developers/mezo-nodes/validator-kit.mdx Install necessary dependencies like curl, git, make, and build-essential. Also, install the Go programming language. ```bash # Ubuntu/Debian sudo apt update sudo apt install -y curl git make build-essential # Install Go curl -fsSL https://go.dev/dl/go1.21.0.linux-amd64.tar.gz | sudo tar -xzC /usr/local ``` -------------------------------- ### Start Local Development Node Source: https://github.com/mezo-org/documentation/blob/main/src/content/docs/docs/developers/getting-started/mezod.mdx Start a local development node for testing and debugging. This command is part of the development environment setup. ```bash make dev ``` -------------------------------- ### Install Pre-commit Hooks Source: https://github.com/mezo-org/documentation/blob/main/src/content/docs/docs/developers/features/mezo-earn/mezo-earn.md Set up pre-commit hooks for the repository to ensure code quality and consistency. This involves installing the pre-commit tool and then installing the hooks within the repository. ```bash # Install pre-commit tool brew install pre-commit # Install hooks in the repository pre-commit install ``` -------------------------------- ### Cosmos SDK Integration Example Source: https://github.com/mezo-org/documentation/blob/main/src/content/docs/docs/developers/getting-started/mezod.mdx Example of setting up a Cosmos SDK client context and transaction builder for interacting with the SDK. This is a foundational step for building integrated applications. ```go package main import ( "context" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/tx" ) func main() { // Create client context clientCtx := client.Context{} // Create transaction builder txBuilder := clientCtx.TxConfig.NewTxBuilder() // Build and send transaction // ... transaction logic } ``` -------------------------------- ### Set Up Environment Variables Source: https://github.com/mezo-org/documentation/blob/main/src/content/docs/docs/developers/musd/index.md Copy the example environment file and edit it with your specific configuration. ```bash cp .env.example .env # Edit .env with your configuration ``` -------------------------------- ### Install Dependencies Source: https://github.com/mezo-org/documentation/blob/main/src/content/docs/docs/developers/subgraphs/index.md Install project dependencies using npm or yarn. Ensure Node.js 18+ is installed. ```bash npm install # or yarn install ``` -------------------------------- ### Install x402 Packages with pnpm Source: https://github.com/mezo-org/documentation/blob/main/src/content/docs/docs/developers/getting-started/musd-payments-x402/x402-quickstart.mdx Installs the necessary @x402 packages and development dependencies for an Express.js server. Peer-dependency warnings during installation are expected and can be safely ignored if the commands exit with a zero status code. ```bash mkdir mezo-x402-server && cd mezo-x402-server pnpm init pnpm add @x402/paywall @x402/evm @x402/core @x402/express express pnpm add -D typescript tsx @types/express @types/node ``` -------------------------------- ### Start Mezo x402 seller server Source: https://github.com/mezo-org/documentation/blob/main/src/content/docs/docs/developers/getting-started/musd-payments-x402/x402-quickstart.mdx Start the server with Account B's address as the receiving address. Replace the placeholder with your actual account address. The server will listen on port 3000. ```bash EVM_ADDRESS=0xYOUR_ACCOUNT_B_ADDRESS_HERE \ pnpm exec tsx server.ts ``` -------------------------------- ### Start Mezod Light Client Source: https://github.com/mezo-org/documentation/blob/main/src/content/docs/docs/developers/getting-started/mezod.mdx Start a light client for Mezod, suitable for resource-constrained environments. This client does not store the full blockchain. ```bash mezod start --mode light ``` -------------------------------- ### Install Dependencies Source: https://github.com/mezo-org/documentation/blob/main/src/content/docs/docs/developers/features/mezo-earn/mezo-earn.md Install all project dependencies using the pnpm package manager. This step is crucial before compiling or running tests. ```bash pnpm install ``` -------------------------------- ### Start Node with Docker Compose Source: https://github.com/mezo-org/documentation/blob/main/src/content/docs/docs/developers/mezo-nodes/validator-kit.mdx Use Docker Compose to start the Mezo node services in detached mode. ```bash docker-compose up -d ``` -------------------------------- ### Run Development Server with npm Source: https://github.com/mezo-org/documentation/blob/main/README.md Starts the local development server for previewing documentation changes. Access the site at http://localhost:4321. ```bash npm run dev ``` -------------------------------- ### Build Mezo Node Natively Source: https://context7.com/mezo-org/documentation/llms.txt Installs Go, clones the mezod repository, builds the binary, and initializes a new node with a specified chain ID. ```bash # ── Native Build ───────────────────────────────────────────────────────────── sudo apt install -y curl git make build-essential curl -fsSL https://go.dev/dl/go1.21.0.linux-amd64.tar.gz | sudo tar -xzC /usr/local git clone https://github.com/mezo-org/mezod.git && cd mezod && make build ./mezod init mynode --chain-id mezo-mainnet ``` -------------------------------- ### Start Frontend Development Server Source: https://github.com/mezo-org/documentation/blob/main/src/content/docs/docs/developers/features/mezo-earn/mezo-earn.md Launch the development server for the Mezo Earn frontend application. This command is executed from the `dapp` directory. ```bash # Navigate to dapp directory cd dapp # Start development server pnpm dev ``` -------------------------------- ### Install and Authenticate Goldsky CLI Source: https://github.com/mezo-org/documentation/blob/main/src/content/docs/docs/developers/subgraphs/index.md Install the Goldsky CLI and log in to your Goldsky account. This is required for deploying subgraphs to Goldsky. ```bash npm install -g @goldsky/cli goldsky login ``` -------------------------------- ### Mezod Node Configuration Example Source: https://github.com/mezo-org/documentation/blob/main/src/content/docs/docs/developers/getting-started/mezod.mdx Example TOML configuration for the Mezod node, specifying consensus timeouts, P2P settings, and API enablement. ```toml # config.toml [consensus] timeout_commit = "1s" timeout_propose = "3s" [p2p] laddr = "tcp://0.0.0.0:26656" external_address = "YOUR_EXTERNAL_IP:26656" persistent_peers = "peer1@ip1:26656,peer2@ip2:26656" [api] enable = true address = "tcp://0.0.0.0:1317" ``` -------------------------------- ### Install Mezo Passport Dependencies Source: https://github.com/mezo-org/documentation/blob/main/src/content/docs/docs/developers/getting-started/index.mdx Install the necessary packages for Mezo Passport integration, including RainbowKit and Wagmi. ```bash npm install @mezo-org/passport @rainbow-me/rainbowkit wagmi viem@2.x @tanstack/react-query ``` -------------------------------- ### Start Mezod Full Node Source: https://github.com/mezo-org/documentation/blob/main/src/content/docs/docs/developers/getting-started/mezod.mdx Start a full node for the Mezod client. This node stores the entire blockchain history. ```bash mezod start ``` -------------------------------- ### Build Mezo Earn Contracts Source: https://context7.com/mezo-org/documentation/llms.txt Instructions for cloning the Mezo Earn repository, installing dependencies, building the Solidity contracts, and running tests. ```bash # Install and build from source # git clone https://github.com/mezo-org/tigris.git && cd tigris # pnpm install # cd solidity && forge build # pnpm test # runs Foundry tests # pnpm test:gas # with gas reporting ``` -------------------------------- ### Start Local Development Node Source: https://github.com/mezo-org/documentation/blob/main/src/content/docs/docs/developers/mezo-nodes/validator-kit.mdx Command to start a local Mezo node for development purposes using a specific Docker Compose file. Assumes `docker-compose.dev.yml` is present. ```bash docker-compose -f docker-compose.dev.yml up ``` -------------------------------- ### Install Graph CLI Source: https://github.com/mezo-org/documentation/blob/main/src/content/docs/docs/developers/subgraphs/index.md Install the Graph CLI globally. This tool is required for subgraph development and deployment. ```bash npm install -g @graphprotocol/graph-cli ``` -------------------------------- ### Install Helm Package Manager Source: https://github.com/mezo-org/documentation/blob/main/src/content/docs/docs/developers/mezo-nodes/validator-kit.mdx Download and install the Helm 3 package manager, which is required for deploying applications on Kubernetes. ```bash curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash ``` -------------------------------- ### Deploy Mezo Node with Kubernetes Helm Source: https://context7.com/mezo-org/documentation/llms.txt Installs Helm, then deploys a Mezo node configured as a validator using a Helm chart. ```bash # ── Kubernetes / Helm ──────────────────────────────────────────────────────── curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash helm install mezo-node ./helm/mezo-node \ --set node.type=validator \ --set node.name=my-validator ``` -------------------------------- ### Deploy Mezo Validator Node with Docker Source: https://context7.com/mezo-org/documentation/llms.txt Clones the validator-kit repository, configures environment variables in .env, and starts the Mezo node using Docker Compose. ```bash # ── Docker Deployment ──────────────────────────────────────────────────────── git clone https://github.com/mezo-org/validator-kit.git && cd validator-kit cp .env.example .env # configure NODE_TYPE, CHAIN_ID, MONIKER, key paths docker-compose up -d ``` -------------------------------- ### Get Redemption Hints using getRedemptionHints Source: https://github.com/mezo-org/documentation/blob/main/src/content/docs/docs/developers/musd/musd-redemptions/index.md Call this function on HintHelpers to obtain hints for a more gas-efficient redemption. Requires the amount in wei and current BTC price. ```solidity function getRedemptionHints( uint _amount, uint _price, uint _maxIterations ) external view returns (address firstRedemptionHint, uint partialRedemptionHintNICR) ``` -------------------------------- ### Install MUSD Project Dependencies Source: https://github.com/mezo-org/documentation/blob/main/src/content/docs/docs/developers/getting-started/index.mdx Install project dependencies for the MUSD smart contracts using pnpm. The `--frozen-lockfile` flag ensures that the exact versions specified in the lockfile are installed. ```bash pnpm install --frozen-lockfile cd solidity pnpm install --frozen-lockfile ``` -------------------------------- ### Build and Preview Frontend Source: https://github.com/mezo-org/documentation/blob/main/src/content/docs/docs/developers/features/mezo-earn/mezo-earn.md Build the frontend application for production and preview the production build. These commands are run from the `dapp` directory. ```bash # Build for production pnpm build # Preview production build pnpm preview ``` -------------------------------- ### Initialize Mezo Node Source: https://github.com/mezo-org/documentation/blob/main/src/content/docs/docs/developers/mezo-nodes/validator-kit.mdx Initialize a new Mezo node with a specified name and chain ID. This sets up the necessary configuration files. ```bash ./mezod init mynode --chain-id mezo-testnet ``` -------------------------------- ### Troubleshooting Configuration and Network Source: https://github.com/mezo-org/documentation/blob/main/src/content/docs/docs/developers/chains/index.md CLI commands for validating configuration, testing dry runs, checking RPC status, and viewing peer connections. ```bash # Check configuration syntax mezod config validate # Test configuration mezod start --dry-run # Test RPC connectivity curl -s http://localhost:26657/status | jq # Check peer connections mezod tendermint show-peers ``` -------------------------------- ### Download Go Dependencies Source: https://github.com/mezo-org/documentation/blob/main/src/content/docs/docs/developers/getting-started/mezod.mdx Download all necessary Go dependencies for the Mezod project. Requires Go 1.21+. ```bash go mod download ``` -------------------------------- ### Install tsx Development Dependency Source: https://github.com/mezo-org/documentation/blob/main/src/content/docs/docs/developers/getting-started/musd-payments-x402/x402-quickstart.mdx If the `tsx` command is not found, it may not have been installed as a development dependency. Rerun this command within your project directory. ```bash pnpm add -D tsx ``` -------------------------------- ### Start Mezod Archive Node Source: https://github.com/mezo-org/documentation/blob/main/src/content/docs/docs/developers/getting-started/mezod.mdx Start an archive node for Mezod, which stores all historical blockchain data. This is useful for deep analysis and state querying. ```bash mezod start --mode archive ``` -------------------------------- ### Clone Subgraph Repository Source: https://github.com/mezo-org/documentation/blob/main/src/content/docs/docs/developers/subgraphs/index.md Clone the subgraph repository to your local machine. Ensure you have Git installed. ```bash git clone https://github.com/mezo-org/subgraphs.git cd subgraphs ``` -------------------------------- ### Open Trove with Hints Source: https://github.com/mezo-org/documentation/blob/main/src/content/docs/docs/developers/musd/index.md Opens a new trove with provided debt and collateral amounts, utilizing hints for gas efficiency. Ensure you have the necessary contract interfaces and wallet connected. ```typescript async function openTroveWithHints( contracts: { borrowerOperations: Contract, troveManager: Contract, sortedTroves: Contract, hintHelpers: Contract }, wallet: Wallet, debtAmount: bigint, assetAmount: bigint ) { // Compute expected total debt by adding gas compensation and fee const gasCompensation = await contracts.troveManager.MUSD_GAS_COMPENSATION(); const expectedFee = await contracts.borrowerOperations.getBorrowingFee(debtAmount); const expectedTotalDebt = debtAmount + expectedFee + gasCompensation; const nicr = (assetAmount * BigInt(1e20)) / expectedTotalDebt; const { '0': approxHint } = await contracts.hintHelpers.getApproxHint(nicr, 15, 42); const { '0': upperHint, '1': lowerHint } = await contracts.sortedTroves.findInsertPosition(nicr, approxHint, approxHint); await contracts.borrowerOperations .connect(wallet) .openTrove(debtAmount, upperHint, lowerHint, { value: assetAmount }); } ``` -------------------------------- ### Clone Mezod Repository Source: https://github.com/mezo-org/documentation/blob/main/src/content/docs/docs/developers/getting-started/mezod.mdx Clone the Mezod repository to your local machine. Ensure you have Git installed. ```bash git clone https://github.com/mezo-org/mezod.git cd mezod ``` -------------------------------- ### Run Subgraph Tests Source: https://github.com/mezo-org/documentation/blob/main/src/content/docs/docs/developers/subgraphs/index.md Execute all unit tests for your subgraph or run specific tests. Ensure the Graph CLI is installed. ```bash # Run all tests npm test # Run specific test graph test ``` -------------------------------- ### GraphQL Queries for Subgraph Data Source: https://github.com/mezo-org/documentation/blob/main/src/content/docs/docs/developers/subgraphs/index.md Examples of GraphQL queries to retrieve data from a deployed subgraph, including filtering and ordering. ```graphql # Get recent transfers { transfers(first: 10, orderBy: timestamp, orderDirection: desc) { id from to amount timestamp transactionHash } } ``` ```graphql # Get token information { token(id: "1") { name symbol decimals totalSupply } } ``` ```graphql # Filter transfers by address { transfers(where: { from: "0x..." }) { id to amount timestamp } } ``` -------------------------------- ### Build Mezod Client Source: https://github.com/mezo-org/documentation/blob/main/src/content/docs/docs/developers/getting-started/mezod.mdx Compile the Mezod client binary. This command builds the executable for the chain client. ```bash make build ``` -------------------------------- ### Build Seller Server with Express and X402 Middleware Source: https://github.com/mezo-org/documentation/blob/main/src/content/docs/docs/developers/getting-started/musd-payments-x402/x402-quickstart.mdx Set up an Express server that uses the @x402/express payment middleware to protect a route. Ensure EVM_ADDRESS and FACILITATOR_URL are correctly configured. The middleware handles payment negotiation and validation. ```typescript import express, { type Request, type Response } from 'express'; import { paymentMiddleware } from '@x402/express'; import { x402ResourceServer, HTTPFacilitatorClient } from '@x402/core/server'; import { ExactEvmScheme } from '@x402/evm/exact/server'; import { createPaywall, evmPaywall } from '@x402/paywall'; const EVM_ADDRESS = process.env.EVM_ADDRESS; // Your Mezo Testnet receiving address (0x + 40 hex chars) const FACILITATOR_URL = 'https://facilitator.vativ.io/'; // Mezo-capable facilitator provided by community if (!EVM_ADDRESS) throw new Error('Set EVM_ADDRESS to your Mezo Testnet receiving address.'); if (!/^0x[0-9a-fA-F]{40}$/.test(EVM_ADDRESS)) { throw new Error(`EVM_ADDRESS must be a 0x-prefixed 40-hex-character address, got: ${EVM_ADDRESS}`); } const app = express(); const facilitatorClient = new HTTPFacilitatorClient({ url: FACILITATOR_URL }); // Bundled paywall UI: knows how to render MUSD at 18 decimals and connect EVM // wallets. Without this, the middleware falls back to a stub that defaults to // USDC formatting (6 decimals) and shows an "Install @x402/paywall" placeholder. const paywall = createPaywall() .withNetwork(evmPaywall) .build(); app.use( paymentMiddleware( { 'GET /paid': { accepts: [ { scheme: 'exact', price: '$0.001', network: 'eip155:31611', // Mezo Testnet, CAIP-2 string (not 'mezo-testnet') payTo: EVM_ADDRESS, }, ], description: 'A paid endpoint on Mezo', mimeType: 'application/json', }, }, new x402ResourceServer(facilitatorClient).register( 'eip155:*', // EVM-family scheme handler; route config above pins the actual chain new ExactEvmScheme(), ), undefined, // paywallConfig (defaults are fine) paywall, // ← the actual bundled UI provider ), ); app.get('/paid', (req: Request, res: Response) => { res.json({ message: 'Thank you for your payment.', servedAt: new Date().toISOString(), }); }); app.listen(3000, () => { console.log('seller listening on http://localhost:3000/paid'); }); ``` -------------------------------- ### Get Validator Gauge Address Source: https://github.com/mezo-org/documentation/blob/main/src/content/docs/docs/developers/mezo-nodes/validator-gauge.md Call `validatorToGauge` on the ValidatorsVoter contract to determine your validator's gauge address. This is a read-only operation. ```solidity function validatorToGauge(address validator) external view returns (address gauge) ``` -------------------------------- ### Build Mezod Binary Source: https://github.com/mezo-org/documentation/blob/main/src/content/docs/docs/developers/mezo-nodes/validator-kit.mdx Clone the mezod repository and build the binary. This command compiles the Mezo daemon from source. ```bash git clone https://github.com/mezo-org/mezod.git cd mezod make build ``` -------------------------------- ### Clone Validator Kit Repository Source: https://github.com/mezo-org/documentation/blob/main/src/content/docs/docs/developers/mezo-nodes/validator-kit.mdx Clone the validator kit repository to your local machine. Navigate into the cloned directory to proceed with setup. ```bash git clone https://github.com/mezo-org/validator-kit.git cd validator-kit ```