### Running Local Development Server with PNPM - Bash Source: https://github.com/worldcoin/world-id-docs/blob/main/README.md Starts the local development server for the documentation site using the command defined in package.json (likely 'pnpm dev'). This allows developers to preview changes locally before committing. Requires dependencies to be installed. ```Bash pnpm dev ``` -------------------------------- ### Building Production Bundle with PNPM - Bash Source: https://github.com/worldcoin/world-id-docs/blob/main/README.md Builds the static production-ready version of the documentation site using the command defined in package.json (likely 'pnpm build'). This creates optimized assets for deployment. Requires dependencies to be installed. ```Bash pnpm build ``` -------------------------------- ### Starting World ID Template Bash App Source: https://github.com/worldcoin/world-id-docs/blob/main/src/pages/world-id/quick-start/templates.mdx Executes the necessary commands to set up and run the World ID template application. First, it installs project dependencies using `pnpm i`, and then it launches the development server with `pnpm dev`. This command is used to get the template running locally after cloning and configuration. ```bash pnpm i && pnpm dev ``` -------------------------------- ### Setting up World ID Cloud Template Bash Source: https://github.com/worldcoin/world-id-docs/blob/main/public/llms-full.txt This command sequence is used to initialize and run the World ID Cloud template repository. It first installs project dependencies using pnpm (`pnpm i`) and then starts the development server (`pnpm dev`). This should be executed after cloning the template and configuring the `.env` file with your World ID `app_id` and `action`. ```bash pnpm i && pnpm dev ``` -------------------------------- ### Installing Dependencies with PNPM - Bash Source: https://github.com/worldcoin/world-id-docs/blob/main/README.md Installs all project dependencies listed in the package.json file using the pnpm package manager. pnpm is used for efficient dependency management. Requires pnpm to be installed globally or accessible. ```Bash pnpm install ``` -------------------------------- ### Cloning Repository and Initializing Env File (Bash) Source: https://github.com/worldcoin/world-id-docs/blob/main/public/llms-full.txt This command sequence downloads the simple-worldchain-node repository from GitHub, navigates into the newly created directory, and copies the example environment file (.env.example) to .env. The .env file is essential for configuring the node's network, execution client, and other settings before starting it. ```bash git clone https://github.com/worldcoin-foundation/simple-worldchain-node.git cd simple-worldchain-node cp .env.example .env ``` -------------------------------- ### Setting up Sign In World ID Template Bash Source: https://github.com/worldcoin/world-id-docs/blob/main/public/llms-full.txt Use this command to set up and run the 'Sign In with World ID Template' which uses NextAuth. It installs the necessary dependencies via pnpm (`pnpm i`) and then starts the local development server (`pnpm dev`). This command should be run after cloning the repository and configuring the required `.env` variables (`NEXTAUTH_URL`, `WLD_CLIENT_ID`, `WLD_CLIENT_SECRET`). ```bash pnpm i && pnpm dev ``` -------------------------------- ### Starting Local Web Server with PNPM (Bash) Source: https://github.com/worldcoin/world-id-docs/blob/main/public/llms-full.txt This command uses pnpm to execute the 'dev' script defined in the project's package.json file. It starts the local development web server for the World ID template application. This typically includes processes like automatic contract ABI regeneration. Requires pnpm to be installed and executed from the project's root directory. ```Bash pnpm dev ``` -------------------------------- ### Manual Installation of MiniKit-JS Source: https://github.com/worldcoin/world-id-docs/blob/main/src/pages/mini-apps/quick-start/installing.mdx Use this command with pnpm to install the core MiniKit-JS library. This package is framework-agnostic and provides the fundamental SDK functionality. ```bash pnpm install @worldcoin/minikit-js ``` -------------------------------- ### Activating Node.js Version - Bash Source: https://github.com/worldcoin/world-id-docs/blob/main/README.md Uses Node Version Manager (nvm) to switch to the project's required Node.js version, typically defined in a .nvmrc file. This ensures compatibility with the project's build tools and dependencies. Requires nvm installation. ```Bash nvm use ``` -------------------------------- ### Starting World Chain Node - Docker Compose/Bash Source: https://github.com/worldcoin/world-id-docs/blob/main/src/pages/world-chain/reference/node-setup.mdx This command starts the World Chain node containers defined in the `docker-compose.yml` file. The `-d` flag runs the containers in detached mode (background), and `--build` rebuilds images if needed before starting. Requires Docker and Docker Compose installed and the `.env` file configured. The output is the node running in the background. ```bash docker compose up -d --build ``` -------------------------------- ### Installing Worldcoin Mini Apps UI Kit React - bash Source: https://github.com/worldcoin/world-id-docs/blob/main/src/pages/mini-apps/design/ui-kit.mdx Installs the Worldcoin Mini Apps UI Kit React package using the npm package manager. Requires Node.js and npm to be installed. This command fetches the package from the npm registry and installs it in the current project's `node_modules` directory. ```bash npm install @worldcoin/mini-apps-ui-kit-react ``` -------------------------------- ### Manual Installation of MiniKit-React Source: https://github.com/worldcoin/world-id-docs/blob/main/src/pages/mini-apps/quick-start/installing.mdx Use this command with pnpm to install the MiniKit-React package. This package provides React hooks that simplify interaction with the MiniKit SDK within a React application. ```bash pnpm install @worldcoin/minikit-react ``` -------------------------------- ### Install Foundry CLI (Bash) Source: https://github.com/worldcoin/world-id-docs/blob/main/public/llms-full.txt This Bash command downloads and executes the official installation script for the Foundry command-line toolkit. Foundry is a suite of tools for Ethereum application development in Solidity. ```bash curl -L https://foundry.paradigm.xyz | bash ``` -------------------------------- ### Quick Start with Mini App Template Source: https://github.com/worldcoin/world-id-docs/blob/main/src/pages/mini-apps/quick-start/installing.mdx This command uses npx to run the create-mini-app script, which bootstraps a new mini app project based on a template. It's the fastest way to begin developing a mini app for World App. ```bash npx @worldcoin/create-mini-app@latest my-first-mini-app ``` -------------------------------- ### Installing Worldcoin IDKit Library Source: https://github.com/worldcoin/world-id-docs/blob/main/src/pages/world-id/quick-start/installation.mdx These snippets show how to install the Worldcoin IDKit library using different Node.js package managers. The library is required to integrate World ID verification into a web application. It needs Node.js and one of the specified package managers (npm, yarn, or pnpm) installed. ```bash npm install @worldcoin/idkit ``` ```bash yarn add @worldcoin/idkit ``` ```bash pnpm add @worldcoin/idkit ``` -------------------------------- ### Installing Sage Support Package - Bash Source: https://github.com/worldcoin/world-id-docs/blob/main/src/pages/mini-apps/sharing/sage-qa.mdx This command installs the necessary npm package for integrating the Sage Support React component into your project. It adds the `sage-support` library to your project's dependencies. ```bash npm install sage-support ``` -------------------------------- ### Installing Project Dependencies - Bash Source: https://github.com/worldcoin/world-id-docs/blob/main/public/llms-full.txt This command uses the pnpm package manager to install all the required dependencies for the World ID template application. This step must be performed after cloning the repository to prepare the project for building and running. ```bash pnpm install ``` -------------------------------- ### Installing Worldcoin IDKit Package Source: https://github.com/worldcoin/world-id-docs/blob/main/public/llms-full.txt Provides commands to install the `@worldcoin/idkit` package using common Node.js package managers (npm, yarn, pnpm). This package is required to integrate the World ID verification widget into your frontend application. Requires Node.js and one of the package managers installed. ```bash npm install @worldcoin/idkit ``` ```bash yarn add @worldcoin/idkit ``` ```bash pnpm add @worldcoin/idkit ``` -------------------------------- ### Example Get Permissions Success Payload - JSON Source: https://github.com/worldcoin/world-id-docs/blob/main/src/pages/mini-apps/commands/get-permissions.mdx Provides a sample JSON structure representing a successful response payload from the getPermissions command, illustrating the format of the returned permissions (e.g., notifications status), the 'success' status, timestamp, and version. ```json { "permissions": { "notifications": false }, "status": "success", "timestamp": "2025-03-11T18:21:49.741-07:00", "version": 1 } ``` -------------------------------- ### Install Foundry CLI toolkit Source: https://github.com/worldcoin/world-id-docs/blob/main/src/pages/world-chain/developers/deploy.mdx This command downloads and installs the Foundry CLI toolkit, which is essential for building, testing, and interacting with Solidity smart contracts. ```bash curl -L https://foundry.paradigm.xyz | bash ``` -------------------------------- ### Starting World Chain Node with Docker Compose (Bash) Source: https://github.com/worldcoin/world-id-docs/blob/main/public/llms-full.txt Use this command to start the World Chain node services defined in the docker-compose.yml file. The -d flag runs the containers in detached mode (in the background), and --build ensures images are built or rebuilt as needed before starting. ```bash docker compose up -d --build ``` -------------------------------- ### Installing Worldcoin Mini Apps UI Kit (npm) - Bash Source: https://github.com/worldcoin/world-id-docs/blob/main/public/llms-full.txt This command installs the Worldcoin Mini Apps UI Kit React package using npm. This UI kit provides pre-built React components following World's design guidelines to accelerate mini app development. It is a required dependency for utilizing the provided UI components. ```bash npm install @worldcoin/mini-apps-ui-kit-react ``` -------------------------------- ### Install Project Dependencies - Bash Source: https://github.com/worldcoin/world-id-docs/blob/main/src/pages/world-chain/developers/template.mdx Installs the required project dependencies using the pnpm package manager. Ensure pnpm (or an equivalent like npm/yarn) is installed beforehand. ```bash pnpm install ``` -------------------------------- ### Installing MiniKit-JS via npm (Bash) Source: https://github.com/worldcoin/world-id-docs/blob/main/public/llms-full.txt Uses the npm package manager to install the `@worldcoin/minikit-js` package. This is the core SDK dependency required for integrating Mini Apps with World App. It's typically used in Node.js or frontend projects using a bundler. ```bash npm install @worldcoin/minikit-js ``` -------------------------------- ### Installing MiniKit-React via npm (Bash) Source: https://github.com/worldcoin/world-id-docs/blob/main/public/llms-full.txt Uses the npm package manager to install the `@worldcoin/minikit-react` package. This package provides React-specific hooks and components to simplify integration with the MiniKit-JS SDK in React applications. It's an optional dependency for React developers. ```bash npm install @worldcoin/minikit-react ``` -------------------------------- ### Start Local Web Server - Bash Source: https://github.com/worldcoin/world-id-docs/blob/main/src/pages/world-chain/developers/template.mdx Starts the local development server for the World ID template web application using pnpm. Ensure necessary environment variables (`.env` file) like app ID, action ID, WalletConnect ID, and the deployed contract address are set. ```bash pnpm dev ``` -------------------------------- ### Example World Chat Deeplink URLs (Output) Source: https://github.com/worldcoin/world-id-docs/blob/main/src/pages/mini-apps/sharing/world-chat-qa.mdx Shows examples of the final URLs generated by the helper function for different quick action types (message draft, payment draft with amount, request draft with amount). These URLs are intended to be opened by the World App. ```plaintext // Message draft https://worldcoin.org/mini-app?app_id=app_e293fcd0565f45ca296aa317212d8741&path=%2Fjohndoe%2Fdraft%3Fmessage%3DHello // Payment draft with amount https://worldcoin.org/mini-app?app_id=app_e293fcd0565f45ca296aa317212d8741&path=%2Fjohndoe%2Fdraft%3Fpay%3D5.25 // Request draft with amount https://worldcoin.org/mini-app?app_id=app_e293fcd0565f45ca296aa317212d8741&path=%2Fjohndoe%2Fdraft%3Frequest%3D10 ``` -------------------------------- ### Installing React Hooks Package Worldcoin MiniKit bash Source: https://github.com/worldcoin/world-id-docs/blob/main/public/llms-full.txt Provides the pnpm command necessary to install the `@worldcoin/minikit-react` package. This package is a prerequisite for using React hooks like `useWaitForTransactionReceipt` to monitor the status of transactions sent via the Worldcoin MiniKit SDK in a React environment. ```bash pnpm i @worldcoin/minikit-react ``` -------------------------------- ### Get Cryptocurrency Prices Request cURL Source: https://github.com/worldcoin/world-id-docs/blob/main/public/llms-full.txt Demonstrates how to make a GET request using cURL to retrieve the latest prices of specified cryptocurrencies against specified fiat currencies using query parameters. ```bash curl -X GET "https://app-backend.worldcoin.dev/public/v1/prices?cryptoCurrencies=WLD&fiatCurrencies=USD" ``` -------------------------------- ### Checking MiniKit Installation Status React/Next.js Source: https://github.com/worldcoin/world-id-docs/blob/main/public/llms-full.txt This snippet shows how to use the `MiniKit.isInstalled()` method to check if the MiniKit SDK has been successfully installed and initialized, typically indicating that the application is running inside the World App. This is useful for implementing conditional logic or UI elements based on the execution environment. ```tsx // ... console.log(MiniKit.isInstalled()) ``` -------------------------------- ### Get Cryptocurrency Prices Request JavaScript Source: https://github.com/worldcoin/world-id-docs/blob/main/public/llms-full.txt Shows a basic structure for making a GET request using JavaScript's fetch API to query cryptocurrency prices. ```js fetch(apiUrl, { method: 'GET', }) ``` -------------------------------- ### Install IDKit Package Source: https://github.com/worldcoin/world-id-docs/blob/main/src/pages/world-id/id/cloud.mdx Install the `@worldcoin/idkit` package into your project using a package manager like npm, yarn, or pnpm. This library is required for integrating the World ID verification flow into your frontend application. ```bash npm install @worldcoin/idkit ``` ```bash yarn add @worldcoin/idkit ``` ```bash pnpm add @worldcoin/idkit ``` -------------------------------- ### Installing IDKit Library - World ID - Bash Source: https://github.com/worldcoin/world-id-docs/blob/main/public/llms-full.txt These snippets provide the commands to install the World ID IDKit library using different Node.js package managers: npm, yarn, and pnpm. You should choose the command corresponding to the package manager used in your project. ```bash npm install @worldcoin/idkit ``` ```bash yarn add @worldcoin/idkit ``` ```bash pnpm add @worldcoin/idkit ``` -------------------------------- ### Verify Proof - 200 OK JSON Response Source: https://github.com/worldcoin/world-id-docs/blob/main/public/llms-full.txt Example of a successful JSON response from the `/api/v2/verify/{app_id}` endpoint upon successful proof verification. ```json { "success": true, "action": "my_action", "nullifier_hash": "0x2bf8406809dcefb1486dadc96c0a897db9bab002053054cf64272db512c6fbd8", "created_at": "2023-02-18T11:20:39.530041+00:00" } ``` -------------------------------- ### Verify Proof - 400 User Already Verified JSON Response Source: https://github.com/worldcoin/world-id-docs/blob/main/public/llms-full.txt Example of a JSON response indicating the user has already successfully verified for the action previously. ```json { "code": "already_verified", "detail": "This person has already verified for this action.", "attribute": null } ``` -------------------------------- ### Example Generated DNA Deeplink URL (Bash) Source: https://github.com/worldcoin/world-id-docs/blob/main/public/llms-full.txt This is an example of the final deeplink URL generated by the `getDNADeeplinkUrl` function. It targets the World App mini app host with the DNA app ID and a URL-encoded path containing parameters for a specific quick action. ```bash https://worldcoin.org/mini-app?app_id=app_8e407cfbae7ae51c19b07faff837aeeb&path=%2Fwallet%3Ftab%3Dsend%26fromToken%3D0x79A02482A880bCE3F13e09Da970dC34db4CD24d1%26amount%3D1234500%26toToken%3D0x4200000000000000000000000000000000000006%26recipientAddress%3D0xRecipientAddressHere%26sourceAppId%3Dapp_a4f7f3e62c1de0b9490a5260cb390b56%26sourceDeeplinkPath%3D%252Fsome%252Fpath ``` -------------------------------- ### Running Contract Tests - bash Source: https://github.com/worldcoin/world-id-docs/blob/main/public/llms-full.txt This command executes the tests defined in the test directory using the Foundry test runner. It compiles the test contracts and runs the functions starting with 'test', reporting the results. ```bash forge test ``` -------------------------------- ### Send Event Listener Sign Message Command (app/page.tsx) Source: https://github.com/worldcoin/world-id-docs/blob/main/public/llms-full.txt Shows how to send a message signing command using MiniKit's commands property, which is part of the event listener pattern. It first checks if MiniKit is installed. ```tsx import { MiniKit, SignMessageInput } from '@worldcoin/minikit-js' const onSignMessage = () => { if (!MiniKit.isInstalled()) { return } const signMessagePayload: SignMessageInput = { message: "Hello world", }; MiniKit.commands.signMessage(signMessagePayload); }; ``` -------------------------------- ### Invoking Earn WLD Quick Action - URL Source: https://github.com/worldcoin/world-id-docs/blob/main/src/pages/mini-apps/sharing/earn-wld-qa.mdx This code snippet provides an example of the URL scheme used to invoke the Earn WLD Quick Action. The `app_id` parameter is mandatory and specifies the unique identifier for the Earn WLD mini-app. ```URL http://worldcoin.org/mini-app?app_id=app_b0d01dd8f2bdfbff06c9e123de487eb8 ``` -------------------------------- ### Verifying Proof Request (API) Source: https://github.com/worldcoin/world-id-docs/blob/main/src/pages/world-id/reference/api.mdx Provides examples for sending a POST request to the /api/v2/verify/{app_id} endpoint using cURL and JavaScript's fetch. This request is used to verify a World ID proof for a specific cloud action, requiring parameters like nullifier_hash, merkle_root, proof, verification_level, action, and signal_hash in the JSON body. Both examples include the necessary Content-Type: application/json header. ```bash curl -X POST "/api/v2/verify/{app_id}" \ -H "Content-Type: application/json" \ -d '{ "nullifier_hash": "0x2bf8406809dcefb1486dadc96c0a897db9bab002053054cf64272db512c6fbd8", "merkle_root": "0x2264a66d162d7893e12ea8e3c072c51e785bc085ad655f64c10c1a61e00f0bc2", "proof": "0x1aa8b8f3b2d2de5ff452c0e1a83e29d6bf46fb83ef35dc5957121ff3d3698a1119090fb...", "verification_level": "orb", "action": "my_action", "signal_hash": "0x00c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a4" }' ``` ```js fetch(apiUrl, { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ nullifier_hash: '0x2bf8406809dcefb1486dadc96c0a897db9bab002053054cf64272db512c6fbd8', merkle_root: '0x2264a66d162d7893e12ea8e3c072c51e785bc085ad655f64c10c1a61e00f0bc2', proof: '0x1aa8b8f3b2d2de5ff452c0e1a83e29d6bf46fb83ef35dc5957121ff3d3698a1119090fb...', verification_level: 'orb', action: 'my_action', signal_hash: '0x00c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a4', }), }) ``` -------------------------------- ### GraphQL Query: List World ID Apps Source: https://github.com/worldcoin/world-id-docs/blob/main/public/llms-full.txt Provides an example GraphQL query (`MyApps`) that fetches the `id` and `name` for all available `app` objects configured in the Developer Portal. This is a basic query demonstrating how to retrieve a list of resources. ```graphql query MyApps { app { id name } } ``` -------------------------------- ### Example Service Status API Response JSON Source: https://github.com/worldcoin/world-id-docs/blob/main/public/llms-full.txt This JSON object illustrates the expected structure of a response from a service status endpoint. It includes details about individual services, their status logs, uptime ratios, and overall category and system status. ```json { "services": [ { "name": "Crypto Transactions", "id": "crypto-transactions", "description": "", "categoryId": "mini-apps", "status": "ok", "logs": [ { "datetime": 1739546233, "status": "ok", "name": "Running again", "description": "Service outage" } ], "uptimeRatio": { "1": 99.7, "7": 100, "30": 100, "90": 100 } } ], "categories": [ { "id": "mini-apps", "name": "Mini Apps", "status": "ok" } ], "uptimeRatio": { "1": 98, "7": 98.7, "30": 99.6, "90": 99.9 }, "status": "ok" } ``` -------------------------------- ### Handling Notification Permission Response Event - MiniKit (tsx) Source: https://github.com/worldcoin/world-id-docs/blob/main/src/pages/mini-apps/commands/send-notifications.mdx Provides an example of subscribing to the `ResponseEvent.MiniAppRequestPermission` event to handle the outcome of a synchronous permission request. It uses `useEffect` to manage the subscription lifecycle, checking if MiniKit is installed before subscribing. Requires `@worldcoin/minikit-js`. ```tsx import { MiniKit, tokenToDecimals, Tokens, PayCommandInput, ResponseEvent } from '@worldcoin/minikit-js' // ... useEffect(() => { if (!MiniKit.isInstalled()) { console.error("MiniKit is not installed"); return; } MiniKit.subscribe( ResponseEvent.MiniAppRequestPermission, async (response: MiniAppRequestPermissionPayload) => { if (response.status == "success") { const response = await res.json(); // Handle the response } } ); return () => { MiniKit.unsubscribe(ResponseEvent.MiniAppRequestPermission); }; }, []); ``` -------------------------------- ### Create New Foundry Project (Bash) Source: https://github.com/worldcoin/world-id-docs/blob/main/public/llms-full.txt This Bash command initializes a new Foundry project named 'hello-world-chain' in the current directory and then navigates into the newly created project directory. This sets up the standard Foundry project structure. ```bash forge init hello-world-chain && cd hello-world-chain ``` -------------------------------- ### Implement Backend Proof Verification Route - TypeScript Source: https://github.com/worldcoin/world-id-docs/blob/main/src/pages/mini-apps/commands/verify.mdx Provides an example of a backend route (using Next.js API routes) for securely verifying the proof received from the mini app. It uses `verifyCloudProof` from `@worldcoin/minikit-js` and handles both verification success and failure. ```ts import { NextRequest, NextResponse } from 'next/server'; import { verifyCloudProof, IVerifyResponse, ISuccessResult } from '@worldcoin/minikit-js'; interface IRequestPayload { payload: ISuccessResult; action: string; signal: string | undefined; } export async function POST(req: NextRequest) { const { payload, action, signal } = (await req.json()) as IRequestPayload; const app_id = process.env.APP_ID as `app_${string}`; const verifyRes = (await verifyCloudProof(payload, app_id, action, signal)) as IVerifyResponse; // Wrapper on this if (verifyRes.success) { // This is where you should perform backend actions if the verification succeeds // Such as, setting a user as "verified" in a database return NextResponse.json({ verifyRes, status: 200 }); } else { // This is where you should handle errors from the World ID /verify endpoint. // Usually these errors are due to a user having already verified. return NextResponse.json({ verifyRes, status: 400 }); } } ``` -------------------------------- ### Accessing VUNI Mini-App via Worldcoin Quick Actions Source: https://github.com/worldcoin/world-id-docs/blob/main/src/pages/mini-apps/sharing/vuni-qa.mdx These examples demonstrate how to construct URLs to launch the VUNI mini-app using Worldcoin Quick Actions. The base URL is `https://worldcoin.org/mini-app`, and parameters like `app_id` and `path` are used to navigate to specific sections or pass configuration. ```text # Access pools with trades tab https://worldcoin.org/mini-app?app_id=app_10ca32093aa9ad0e52bc812d63daf818&path=%2Fpool%3Ftab%3Dtrades ``` ```text # View investor info with referrals tab https://worldcoin.org/mini-app?app_id=app_10ca32093aa9ad0e52bc812d63daf818&path=%2Finvestor%2F0x6917A2418aBDc514E1745207200bFbA75E1dfd6E%3Ftab%3Dreferrals ``` ```text # Access with referral code https://worldcoin.org/mini-app?app_id=app_10ca32093aa9ad0e52bc812d63daf818&path=%3Fref%3DGD9WWI ``` ```text # Access pools with stats tab (localized) https://worldcoin.org/mini-app?app_id=app_10ca32093aa9ad0e52bc812d63daf818&path=%2Fen%2Fpool%3Ftab%3Dstats ``` -------------------------------- ### Querying Worldcoin Status API with cURL Source: https://github.com/worldcoin/world-id-docs/blob/main/src/pages/mini-apps/reference/status-page.mdx This snippet shows how to make a GET request to the Worldcoin status API using the cURL command-line tool. It includes the `logs=true` query parameter to request historical status information for each service. This requires cURL installed on the system. ```bash curl -X GET "https://status.worldcoin.org/api/services?logs=true" ``` -------------------------------- ### Get Cryptocurrency Prices Response JSON Source: https://github.com/worldcoin/world-id-docs/blob/main/public/llms-full.txt An abridged example of the JSON response object for the price query endpoint. It shows the structure containing prices for different crypto assets (WLD, USDCE) against fiat currencies (USD), including amount and decimal values. ```json { "result": { "prices": { "WLD": { "USD": { "asset": "USD", "amount": "1510763", "decimals": 6, "symbol": "USD" } }, "USDCE": { "USD": { "asset": "USD", "amount": "1000058", "decimals": 6, "symbol": "USD" } } } } } ``` -------------------------------- ### Cloning World Chain Node Repository - Bash Source: https://github.com/worldcoin/world-id-docs/blob/main/src/pages/world-chain/reference/node-setup.mdx This snippet clones the `simple-worldchain-node` repository from GitHub, navigates into the created directory, and copies the example environment file to `.env`. Required dependencies are Git. The outcome is a local copy of the repository with a configuration file ready for editing. ```bash git clone https://github.com/worldcoin-foundation/simple-worldchain-node.git cd simple-worldchain-node cp .env.example .env ``` -------------------------------- ### Constructing World Companies Finder Quick Action URL - Plaintext Source: https://github.com/worldcoin/world-id-docs/blob/main/src/pages/mini-apps/sharing/world-companies-finder-qa.mdx This snippet provides an example URL demonstrating how to use the World Companies Finder Quick Action. It shows the base URL, the required application ID (`app_id`), and the `path=new` parameter to link directly to the page for adding a new business. ```Plaintext https://worldcoin.org/mini-app?app_id=app_a11be267c4baa35bca6d18b3cdd6a23c&path=new ``` -------------------------------- ### OIDC Authorization Request URL (HTTP) Source: https://github.com/worldcoin/world-id-docs/blob/main/public/llms-full.txt Provides an example URL for initiating the OpenID Connect authorization flow via the /authorize endpoint. This GET request includes required query parameters like redirect_uri, response_type, scope, and client_id, directing the user to the World ID sign-in page. ```http https://id.worldcoin.org/authorize?redirect_uri=https%3A%2F%2Fdocs.worldcoin.org%2Fworld-id%2Ftry-callback&response_type=code&scope=openid+profile+email&client_id=app_ce4cb73cb75fc3b73b71ffb4de178410 ``` -------------------------------- ### Programmatically Opening IDKit Widget using React Hook Source: https://github.com/worldcoin/world-id-docs/blob/main/src/pages/world-id/reference/idkit.mdx This snippet demonstrates how to use the useIDKit hook to programmatically control the IDKit widget's visibility from within a React component. It shows how to get the `open` and `setOpen` functions from the hook and trigger the widget, for example, within a useEffect hook, while still requiring the IDKitWidget component to be mounted somewhere in the application. ```JSX import { IDKitWidget, useIDKit } from '@worldcoin/idkit' const { open, setOpen } = useIDKit() useEffect(() => { setOpen(true) }, []) return (
) ``` -------------------------------- ### Deploying the Contract to World Chain Sepolia - bash Source: https://github.com/worldcoin/world-id-docs/blob/main/public/llms-full.txt This command deploys the HelloWorldChain contract to the World Chain Sepolia testnet using Foundry's 'forge create' command. It specifies the contract source and name, the RPC URL for the network, and the private key of the deploying wallet. Replace the placeholder private key with your actual generated key. ```bash forge create src/HelloWorldChain.sol:HelloWorldChain --rpc-url https://worldchain-sepolia.g.alchemy.com/public --private-key 0xcc1b30a6af68ea9a9917f1dda20c927704c5cdb2bbe0076901a8a0e40bf997c5 ``` -------------------------------- ### Sending Get Permissions Command (Async) - TSX Source: https://github.com/worldcoin/world-id-docs/blob/main/src/pages/mini-apps/commands/get-permissions.mdx Demonstrates how to call the getPermissions command using the asynchronous methods available in MiniKit. This approach uses await to directly get the payload as the result of the function call. ```tsx import { MiniKit, GetPermissionsPayload, Permission } from '@worldcoin/minikit-js' // Example function of how to use the command const getPermissions = useCallback( async () => { const payload = await MiniKit.commandsAsync.getPermissions(); // Handle the response }, [] ); ``` -------------------------------- ### Building Smart Contracts with Foundry - Bash Source: https://github.com/worldcoin/world-id-docs/blob/main/public/llms-full.txt This command first navigates into the 'contracts' directory within the project and then uses the Foundry CLI (`forge`) to build (compile) the Solidity smart contracts. This step is necessary before the contracts can be deployed or interacted with. ```bash cd contracts && forge build ``` -------------------------------- ### Wrapping App Root with MiniKitProvider React/Next.js Source: https://github.com/worldcoin/world-id-docs/blob/main/public/llms-full.txt This code demonstrates how to wrap the root layout or component of your application with the `MiniKitProvider`. This ensures that the MiniKit SDK is initialized and ready for use by any child components within your application tree. ```tsx export default async function Root({ children, }: Readonly<{ children: React.ReactNode }>) { return ( {children} ) } ``` -------------------------------- ### Example Usage of DNA Deeplink Generator - TypeScript Source: https://github.com/worldcoin/world-id-docs/blob/main/src/pages/mini-apps/sharing/dna-qa.mdx This TypeScript code provides an example demonstrating how to invoke the `getDNADeeplinkUrl` function with typical parameters for a DNA quick action. It shows how to pass token addresses, recipient, amount, and source application details to generate a functional deeplink URL. The example includes logging the resulting URL to the console. ```typescript const deeplinkUrl = getDNADeeplinkUrl({ fromToken: '0x79A02482A880bCE3F13e09Da970dC34db4CD24d1', toToken: '0x4200000000000000000000000000000000000006', recipientAddress: '0xRecipientAddressHere', amount: '1235', sourceAppId: 'app_a4f7f3e62c1de0b9490a5260cb390b56', sourceDeeplinkPath: '/path', }) console.log(deeplinkUrl) ``` -------------------------------- ### Initializing MiniKit SDK in React/Next.js Source: https://github.com/worldcoin/world-id-docs/blob/main/public/llms-full.txt This React component uses the useEffect hook to call `MiniKit.install` when the component mounts, initializing the MiniKit SDK and making it available throughout your application. It is marked as a client component for Next.js compatibility. Requires the `@worldcoin/minikit-js` dependency. ```tsx 'use client' // Required for Next.js import { ReactNode, useEffect } from 'react' import { MiniKit } from '@worldcoin/minikit-js' export default function MiniKitProvider({ children }: { children: ReactNode }) { useEffect(() => { // Passing appId in the install is optional // but allows you to access it later via `window.MiniKit.appId` MiniKit.install(appId?) }, []) return <>{children} } ``` -------------------------------- ### Create a new Foundry project Source: https://github.com/worldcoin/world-id-docs/blob/main/src/pages/world-chain/developers/deploy.mdx This command initializes a new Foundry project in a directory named `hello-world-chain` and then changes the current directory to the newly created project folder. ```bash forge init hello-world-chain && cd hello-world-chain ``` -------------------------------- ### Initializing MiniKit and Triggering Command (TSX) Source: https://github.com/worldcoin/world-id-docs/blob/main/public/llms-full.txt Provides a React component (`MiniKitProvider`) that initializes the MiniKit SDK using `MiniKit.install()` and immediately calls a command (`MiniKit.commands.walletAuth`) within the same `useEffect` hook. This prevents race conditions that can occur if a command is triggered before MiniKit is fully installed. It requires the `@worldcoin/minikit-js` dependency. ```tsx 'use client'\n\nimport { useEffect, ReactNode } from 'react'\nimport { MiniKit } from '@worldcoin/minikit-js'\n\nexport const MiniKitProvider = ({ children }: { children: ReactNode }) => {\n\tuseEffect(() => {\n\t\tMiniKit.install()\n\n\t\t// Add any commands you wish to trigger on start here to prevent race conditions\n\t\tMiniKit.commands.walletAuth({\n\t\t\t// ...\n\t\t})\n\t}, [])\n\n\treturn <>{children}\n} ``` -------------------------------- ### OIDC ID Token Redirect Example (HTTP) Source: https://github.com/worldcoin/world-id-docs/blob/main/public/llms-full.txt Provides an example of the redirect URL structure when using the implicit flow. After successful authentication, the user is redirected to the specified redirect_uri with the 'id_token' included as a fragment identifier. ```http https://example.app/api/auth/callback/worldcoin#id_token=eyJhbGciOiJSUzI1NiIsInR5cCI6I... ``` -------------------------------- ### Signing Up New User - cURL and JavaScript Source: https://github.com/worldcoin/world-id-docs/blob/main/src/pages/world-id/reference/internal-endpoints.mdx This snippet demonstrates how to sign up a new user using the `/v1/signup` endpoint. It requires the user's email, password, name, and team name. The user will receive a verification email after successful signup. Both cURL and JavaScript examples are provided. ```bash curl -X POST "/api/v1/signup" \ -H "Content-Type: application/json" \ -d '{ "email": "bob@worldidbot.com", "password": "987654321", "name": "Bob", "team_name": "The Bob Project" }' ``` ```js fetch('/api/v1/signup', { method: 'POST', https://www.worldcoin.cn/new-documentation/world-id-docs/internal-endpoints 'Content-Type': 'application/json', }, body: JSON.stringify({ email: 'bob@worldidbot.com', password: '987654321', name: 'Bob', team_name: 'The Bob Project', }), }) ``` -------------------------------- ### CDN Usage for MiniKit-JS (HTML) Source: https://github.com/worldcoin/world-id-docs/blob/main/src/pages/mini-apps/quick-start/installing.mdx This HTML snippet shows how to include MiniKit-JS directly from a CDN like jsdelivr. It uses an ES module import within a script tag. Remember to replace `[version]` with the specific version you want to use. ```html ``` -------------------------------- ### Sending Get Permissions Command (Event) - TSX Source: https://github.com/worldcoin/world-id-docs/blob/main/src/pages/mini-apps/commands/get-permissions.mdx Shows how to initiate the getPermissions command using the synchronous commands object in MiniKit. The response for this command is not returned directly but will be delivered via a separate event that must be subscribed to. ```tsx // Example function of how to use the command const getPermissions = useCallback( () => { const payload = MiniKit.commands.getPermissions(); }, [] ); ``` -------------------------------- ### Define Get Permissions Error Payload Type - TS Source: https://github.com/worldcoin/world-id-docs/blob/main/src/pages/mini-apps/commands/get-permissions.mdx Defines the TypeScript interface or type alias for the payload received when the getPermissions command encounters an error. It includes the 'error' status, an error code from the GetPermissionsErrorCodes enum, and the version. ```ts type MiniAppGetPermissionsErrorPayload = { status: 'error'; error_code: GetPermissionsErrorCodes; version: number; } ``` -------------------------------- ### Define Get Permissions Success Payload Type - TS Source: https://github.com/worldcoin/world-id-docs/blob/main/src/pages/mini-apps/commands/get-permissions.mdx Defines the TypeScript interface or type alias for the payload received when the getPermissions command successfully returns user permissions. It includes the 'success' status, an array of Permission objects, and the version. ```ts type MiniAppGetPermissionsSuccessPayload = { status: 'success'; permissions: Permission[]; version: number; // same version that was received from MiniKit }; ``` -------------------------------- ### Get World Services Status with Logs (cURL) Source: https://github.com/worldcoin/world-id-docs/blob/main/public/llms-full.txt Demonstrates how to make a GET request to the Worldcoin status API endpoint using the cURL command-line tool. The `logs=true` query parameter is included to request historical status logs for each service. ```bash curl -X GET "https://status.worldcoin.org/api/services?logs=true" ``` -------------------------------- ### Initiating Pay Command (Async) - TSX Source: https://github.com/worldcoin/world-id-docs/blob/main/public/llms-full.txt Demonstrates how to initiate a payment using the Worldcoin MiniKit with async handlers. It first fetches a reference ID from a backend endpoint (`/api/initiate-payment`), constructs the `PayCommandInput` payload with recipient address and token details, checks if MiniKit is installed, sends the command using `MiniKit.commandsAsync.pay`, and then handles the success response by sending the final payload to a backend confirmation endpoint (`/api/confirm-payment`). ```tsx import { MiniKit, tokenToDecimals, Tokens, PayCommandInput } from '@worldcoin/minikit-js' const sendPayment = async () => { const res = await fetch('/api/initiate-payment', { method: 'POST', }) const { id } = await res.json() const payload: PayCommandInput = { reference: id, to: '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045', // Test address tokens: [ { symbol: Tokens.WLD, token_amount: tokenToDecimals(1, Tokens.WLD).toString(), }, { symbol: Tokens.USDCE, token_amount: tokenToDecimals(3, Tokens.USDCE).toString(), }, ], description: 'Test example payment for minikit', } if (!MiniKit.isInstalled()) { return } const { finalPayload } = await MiniKit.commandsAsync.pay(payload) if (finalPayload.status == 'success') { const res = await fetch(`/api/confirm-payment`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(finalPayload), }) const payment = await res.json() if (payment.success) { // Congrats your payment was successful! } } } ``` -------------------------------- ### OIDC Authorization Code Redirect Example (HTTP) Source: https://github.com/worldcoin/world-id-docs/blob/main/public/llms-full.txt Shows an example of the redirect URL structure when using the authorization code flow. After successful authentication, the user is redirected to the specified redirect_uri with an authorization 'code' parameter appended to the query string. ```http https://example.app/api/auth/callback/worldcoin?code=e777d780f437330bbd79535b ``` -------------------------------- ### Initializing MiniKit and Calling Command TSX Source: https://github.com/worldcoin/world-id-docs/blob/main/src/pages/mini-apps/more/troubleshooting.mdx This code snippet demonstrates the correct pattern for initializing the Worldcoin MiniKit and immediately calling a command upon component mount using a React `useEffect` hook. Placing the command call inside the same effect as `MiniKit.install()` prevents race conditions, ensuring MiniKit is installed before commands are triggered. This snippet is typically used within a provider component. ```tsx 'use client' import { useEffect, ReactNode } from 'react' import { MiniKit } from '@worldcoin/minikit-js' export const MiniKitProvider = ({ children }: { children: ReactNode }) => { useEffect(() => { MiniKit.install() // Add any commands you wish to trigger on start here to prevent race conditions MiniKit.commands.walletAuth({ // ... }) }, []) return <>{children} } ``` -------------------------------- ### Including MiniKit-JS via CDN (HTML) Source: https://github.com/worldcoin/world-id-docs/blob/main/public/llms-full.txt Provides an HTML ` ``` -------------------------------- ### Example Usage Generating DNA Deeplink (TypeScript) Source: https://github.com/worldcoin/world-id-docs/blob/main/public/llms-full.txt This TypeScript snippet shows a practical example of using the `getDNADeeplinkUrl` function to create a deeplink URL. It passes specific parameters for a quick action (send/swap related based on parameters) and logs the generated URL. ```typescript const deeplinkUrl = getDNADeeplinkUrl({ fromToken: '0x79A02482A880bCE3F13e09Da970dC34db4CD24d1', toToken: '0x4200000000000000000000000000000000000006', recipientAddress: '0xRecipientAddressHere', amount: ‘1235', sourceAppId: 'app_a4f7f3e62c1de0b9490a5260cb390b56', sourceDeeplinkPath: ‘/path’, }); console.log(deeplinkUrl); ``` -------------------------------- ### Handle Verify Command Async - TSX Source: https://github.com/worldcoin/world-id-docs/blob/main/src/pages/mini-apps/commands/verify.mdx Demonstrates how to use the async handler pattern (`MiniKit.commandsAsync.verify`) to send a verify command and await its result directly. It includes checking if MiniKit is installed, handling the response payload (success or error), and making a backend API call to verify the proof. ```tsx import { MiniKit, VerifyCommandInput, VerificationLevel, ISuccessResult } from '@worldcoin/minikit-js'; const verifyPayload: VerifyCommandInput = { action: 'voting-action', // This is your action ID from the Developer Portal signal: '0x12312', // Optional additional data verification_level: VerificationLevel.Orb, // Orb | Device }; const handleVerify = async () => { if (!MiniKit.isInstalled()) { return; } // World App will open a drawer prompting the user to confirm the operation, promise is resolved once user confirms or cancels const {finalPayload} = await MiniKit.commandsAsync.verify(verifyPayload); if (finalPayload.status === 'error') { return console.log('Error payload', finalPayload); } // Verify the proof in the backend const verifyResponse = await fetch('/api/verify', { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ payload: finalPayload as ISuccessResult, // Parses only the fields we need to verify action: 'voting-action', signal: '0x12312', // Optional }), }); // TODO: Handle Success! const verifyResponseJson = await verifyResponse.json(); if (verifyResponseJson.status === 200) { console.log('Verification success!'); } }; ``` -------------------------------- ### Fetching World ID JWK Keys with JavaScript Fetch Source: https://github.com/worldcoin/world-id-docs/blob/main/public/llms-full.txt Demonstrates how to fetch JWK keys using the JavaScript `fetch` API. This call makes a GET request to the `/api/v1/jwks` endpoint to get the public keys needed for Hosted page UI JWT verification. ```js fetch('/api/v1/jwks') ``` -------------------------------- ### Initializing IDKit Standalone JavaScript Source: https://github.com/worldcoin/world-id-docs/blob/main/src/pages/world-id/reference/idkit.mdx Demonstrates how to initialize the Worldcoin IDKit standalone library for use in vanilla JavaScript applications. It requires importing `IDKit` and calling the static `.init()` method with configuration options such as `app_id`, `action`, and an `onSuccess` callback to handle verification results. ```javascript import { IDKit } from '@worldcoin/idkit-standalone' const onSuccess = (result) => { // handle success } IDKit.init({ app_id: 'app_lshSNnaJfdt6Sohu6YAA', action: 'my_action', onSuccess: onSuccess, }) ``` -------------------------------- ### Submitting User Signup Request (JavaScript Fetch) Source: https://github.com/worldcoin/world-id-docs/blob/main/public/llms-full.txt Illustrates how to make a POST request to the /api/v1/signup endpoint using the JavaScript fetch API. The request includes necessary user details such as email, password, name, and team_name in a JSON body. This is an alternative method for registering new users programmatically. ```js fetch('/api/v1/signup', { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ email: 'bob@worldidbot.com', password: '987654321', name: 'Bob', team_name: 'The Bob Project', }), }) ``` -------------------------------- ### Example World ID Success Result - JSON Source: https://github.com/worldcoin/world-id-docs/blob/main/public/llms-full.txt This JSON snippet provides an example of the structure and values contained within an `ISuccessResult` object, which is returned by IDKit upon a successful verification. It includes the Merkel root, nullifier hash, proof string, and verification level. ```json { "merkle_root": "0x1f38b57f3bdf96f05ea62fa68814871bf0ca8ce4dbe073d8497d5a6b0a53e5e0", "nullifier_hash": "0x0339861e70a9bdb6b01a88c7534a3332db915d3d06511b79a5724221a6958fbe", "proof": "0x063942fd7ea1616f17787d2e3374c1826ebcd2d41d2394...", "verification_level": "orb" } ``` -------------------------------- ### Compiling the Contract - bash Source: https://github.com/worldcoin/world-id-docs/blob/main/public/llms-full.txt This command compiles the smart contracts in the project's source directory using the Solidity compiler via Foundry. It generates contract artifacts, including ABI and bytecode, necessary for deployment and interaction. ```bash forge build ``` -------------------------------- ### Get Action Metadata - JavaScript Fetch Request Source: https://github.com/worldcoin/world-id-docs/blob/main/public/llms-full.txt This JavaScript `fetch` request demonstrates how to programmatically call the `/api/v1/precheck/{app_id}` endpoint. It sends a POST request with action details (`action`, `nullifier_hash`, `external_nullifier`) as a JSON string in the request body to get metadata for verification eligibility. ```javascript fetch(`/api/v1/precheck/${appId}`, { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ action: 'my_custom_action', nullifier_hash: '0x2bf8406809dcefb1486dadc96c0a897db9bab002053054cf64272db512c6fbd8', external_nullifier: '0x00949dd9a8c5b600304d010ce3a3cf012352070ae4b77504e17af77ee894cda', }), }) ``` -------------------------------- ### Initializing IDKit Standalone - JavaScript Source: https://github.com/worldcoin/world-id-docs/blob/main/public/llms-full.txt This JavaScript snippet shows how to import and initialize the `@worldcoin/idkit-standalone` package. The `.init()` method configures the World ID widget with the application ID, action identifier, and a success callback. ```javascript import { IDKit } from '@worldcoin/idkit-standalone' const onSuccess = (result) => { // handle success } IDKit.init({ app_id: 'app_lshSNnaJfdt6Sohu6YAA', action: 'my_action', onSuccess: onSuccess, }) ``` -------------------------------- ### Earn WLD Quick Action Deeplink Structure (Bash) Source: https://github.com/worldcoin/world-id-docs/blob/main/public/llms-full.txt This snippet shows the basic URL pattern required to create a deeplink that opens the Earn WLD mini app and navigates directly to its staking quick action screen. It primarily requires the unique application ID for the Earn WLD mini app. ```bash http://worldcoin.org/mini-app?app_id=app_b0d01dd8f2bdfbff06c9e123de487eb8 ```