### Clone Android Quickstart Example Source: https://github.com/metamask/metamask-docs/blob/main/src/pages/quickstart/builder/embedded-wallets/android/stepContent/androidQuickStart.mdx Clone the Web3Auth Android quickstart application to follow along with a complete example. This command uses degit to download the example project. ```bash npx degit Web3Auth/web3auth-android-examples/android-quick-start w3a-android-quick-start ``` -------------------------------- ### Avalanche C-Chain Quickstart Guide Source: https://github.com/metamask/metamask-docs/blob/main/static/llms.txt This section provides a quickstart guide for integrating with the Avalanche C-Chain using MetaMask. It outlines the necessary steps and configurations for developers to get started. ```markdown - [Quickstart | MetaMask developer documentation](https://docs.metamask.io/services/reference/avalanche-c-chain/quickstart/): Avalanche C-Chain quickstart guide ``` -------------------------------- ### Optimism Quickstart Source: https://github.com/metamask/metamask-docs/blob/main/static/llms.txt Guide to getting started with Optimism network integration using MetaMask. ```APIDOC ## Optimism Quickstart ### Description This guide provides instructions for developers to quickly integrate with the Optimism network using MetaMask. ### Content Provides steps for setting up your environment and connecting to the Optimism network. ``` -------------------------------- ### Clone Angular Quickstart Application Source: https://github.com/metamask/metamask-docs/blob/main/src/pages/quickstart/builder/embedded-wallets/angular/stepContent/angularQuickStart.mdx Clone the Angular quickstart repository to get a complete example of the integration. ```bash npx degit Web3Auth/web3auth-examples/quick-starts/angular-quick-start w3a-quick-start ``` -------------------------------- ### Install MetaMask Embedded Wallets SDK and viem Source: https://github.com/metamask/metamask-docs/blob/main/src/pages/quickstart/builder/embedded-wallets/angular/stepContent/installation.mdx Use this command to install the necessary packages for the quickstart. This command installs the MetaMask Embedded Wallets SDK (Web3Auth) and viem. ```bash npm install --save @web3auth/modal viem ``` -------------------------------- ### Clone MetaMask SDK Examples Repository Source: https://github.com/metamask/metamask-docs/blob/main/metamask-connect/evm/quickstart/rainbowkit.md Alternatively, clone the entire MetaMask SDK examples repository and navigate to the specific RainbowKit quickstart directory. ```bash git clone https://github.com/MetaMask/metamask-sdk-examples cd metamask-sdk-examples/quickstarts/rainbowkit ``` -------------------------------- ### Install @metamask/create-gator-app CLI Source: https://github.com/metamask/metamask-docs/blob/main/gator_versioned_docs/version-1.2.0/get-started/use-the-cli.md Run this command to install the `@metamask/create-gator-app` package. This command initiates the interactive setup process for your project. ```bash npx @metamask/create-gator-app@latest ``` -------------------------------- ### Clone React Quickstart Application Source: https://github.com/metamask/metamask-docs/blob/main/src/pages/quickstart/builder/embedded-wallets/react/stepContent/reactQuickStart.mdx Clone the React quickstart application to follow along with a complete example. ```bash npx degit Web3Auth/web3auth-examples/quick-starts/react-quick-start w3a-quick-start ``` -------------------------------- ### Clone iOS/Swift Quickstart Application Source: https://github.com/metamask/metamask-docs/blob/main/src/pages/quickstart/builder/embedded-wallets/ios/stepContent/iOSQuickStart.mdx Clone the Web3Auth iOS quickstart application to get a complete example for integrating MetaMask Embedded Wallets. ```bash npx degit Web3Auth/web3auth-ios-examples/ios-quick-start w3a-ios-quick-start ``` -------------------------------- ### Install Dependencies and Run Dev Server Source: https://github.com/metamask/metamask-docs/blob/main/src/pages/tutorials/upgrade-eoa-to-smart-account.md Install project dependencies using npm and start the development server to view the application locally. ```bash npm install npm run dev ``` -------------------------------- ### Polygon POS Quickstart Source: https://github.com/metamask/metamask-docs/blob/main/static/llms.txt This is a quickstart guide for the Polygon network. ```APIDOC ## Polygon POS Quickstart ### Description Polygon quickstart guide. ### Method N/A ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ``` -------------------------------- ### Enable MFA Setup Flow Source: https://github.com/metamask/metamask-docs/blob/main/embedded-wallets/sdk/android/advanced/mfa.mdx This section demonstrates how to initiate the MFA setup flow. It provides examples for both default verifiers and custom JWT verifiers. ```APIDOC ## POST /enableMFA ### Description Triggers the Multi-Factor Authentication (MFA) setup flow for users. This method can be used with default login providers or custom JWT verifiers. ### Method POST ### Endpoint /enableMFA ### Parameters #### Request Body - **loginParams** (LoginParams) - Optional - Parameters used during custom verifiers. Required if using custom JWT verifiers, including the JWT token. ### Request Example (Default Verifier) ```kotlin val completableFuture = web3Auth.enableMFA() ``` ### Request Example (Custom JWT Verifier) ```kotlin val loginParams = LoginParams( Provider.JWT, extraLoginOptions = ExtraLoginOptions(id_token = "") ) val completableFuture = web3Auth.enableMFA(loginParams) ``` ### Response #### Success Response (200) Indicates that the MFA setup flow was successfully initiated. #### Response Example (No specific response body example provided in the source text, but success is indicated by the absence of an error.) ``` -------------------------------- ### Implement Installation Hook with onInstall Source: https://github.com/metamask/metamask-docs/blob/main/snaps/reference/entry-points.md Use the `onInstall` entry point to run actions after a Snap is successfully installed. Requires the `endowment:lifecycle-hooks` permission. This example shows a notification dialog. ```jsx import type { OnInstallHandler } from '@metamask/snaps-sdk' import { Box, Heading, Text } from '@metamask/snaps-sdk/jsx' export const onInstall: OnInstallHandler = async () => { await snap.request({ method: 'snap_dialog', params: { type: 'alert', content: ( Thank you for installing my Snap To use this Snap, visit the companion dapp at{' '} metamask.io. ), }, }) } ``` ```javascript import { heading, panel, text } from '@metamask/snaps-sdk' module.exports.onInstall = async () => { await snap.request({ method: 'snap_dialog', params: { type: 'alert', content: panel([ heading('Thank you for installing my Snap'), text('To use this Snap, visit the companion dapp at [metamask.io](https://metamask.io).'), ]), }, }) } ``` -------------------------------- ### Clone Next.js Quickstart Application Source: https://github.com/metamask/metamask-docs/blob/main/src/pages/quickstart/builder/embedded-wallets/nextjs/stepContent/nextjsQuickStart.mdx Use this command to clone the Next.js quickstart application for a complete example. ```shell npx degit Web3Auth/web3auth-examples/quick-starts/nextjs-quick-start w3a-quick-start ``` -------------------------------- ### Get IPFS Version Information (Example) Source: https://github.com/metamask/metamask-docs/blob/main/services/reference/ipfs/http-api-methods/version.md A basic example of how to fetch IPFS version details. Authentication is required. ```bash curl "https://ipfs.infura.io:5001/api/v0/version" \ -X POST \ -u ":" ``` -------------------------------- ### Start Development Server Source: https://github.com/metamask/metamask-docs/blob/main/gator_versioned_docs/version-1.2.0/get-started/use-scaffold-eth/smart-accounts.md Run this command in the project's root directory to start the frontend development server. Ensure Yarn is installed and configured. ```bash yarn start ``` -------------------------------- ### Initiate MFA Setup Process Source: https://github.com/metamask/metamask-docs/blob/main/embedded-wallets/sdk/js/usage/enable-mfa.mdx Use this snippet to start the MFA setup for users. Note that this function is intended for embedded wallets using social logins and will not work with external wallet connections. It triggers a redirect to the MFA setup page. ```javascript try { await web3auth.enableMFA() console.log('MFA setup process initiated') } catch (error) { console.error('Error enabling MFA:', error) } ``` -------------------------------- ### Clone React Native Quickstart Project Source: https://github.com/metamask/metamask-docs/blob/main/src/pages/quickstart/builder/embedded-wallets/react_native/stepContent/rnQuickStart.mdx Clone the React Native quickstart application to follow along with a complete example. This command uses degit to download the project template. ```bash npx degit Web3Auth/web3auth-react-native-examples/rn-bare-quick-start w3a-quick-start ``` -------------------------------- ### Navigate to Project Directory Source: https://github.com/metamask/metamask-docs/blob/main/metamask-connect/evm/quickstart/javascript.md Change the current directory to the cloned quickstart project. ```bash cd metamask-connect-javascript ``` -------------------------------- ### Clone MetaMask SDK Examples Repository Source: https://github.com/metamask/metamask-docs/blob/main/metamask-connect/evm/quickstart/connectkit.md Alternatively, clone the entire MetaMask SDK examples repository and navigate into the quickstarts/connectkit directory. This method downloads the full repository. ```bash git clone https://github.com/MetaMask/metamask-sdk-examples cd metamask-sdk-examples/quickstarts/connectkit ``` -------------------------------- ### Navigate to Project Directory Source: https://github.com/metamask/metamask-docs/blob/main/metamask-connect/evm/quickstart/dynamic.md Change into the cloned project directory to proceed with the setup. ```bash cd metamask-dynamic ``` -------------------------------- ### Switch to Initial Setup Branch Source: https://github.com/metamask/metamask-docs/blob/main/src/pages/tutorials/create-wallet-ai-agent.md Navigate to the cloned repository and switch to the 'initial-setup' branch. ```bash cd wallet-agent && git switch initial-setup ``` -------------------------------- ### Get Uncle Count via WebSocket Source: https://github.com/metamask/metamask-docs/blob/main/services/reference/_partials/_eth_getunclecountbyblockhash-request.mdx This example shows how to get the uncle count for a block hash using a WebSocket connection. Ensure you have `wscat` installed. Replace with your Infura API key. ```bash wscat -c wss://mainnet.infura.io/ws/v3/ -x '{"jsonrpc": "2.0", "method": "eth_getUncleCountByBlockHash", "params": ["0xb3b20624f8f0f86eb50dd04688409e5cea4bd02d700bf6e79e9384d47d6a5a35"], "id": 1}' ``` -------------------------------- ### Get Suggested Gas Fees (JavaScript) Source: https://github.com/metamask/metamask-docs/blob/main/services/reference/gas-api/api-reference/gasprices-type2.md This JavaScript example uses Axios to fetch suggested gas fees. Ensure you replace placeholders with your API key and secret, and install the Axios library. ```javascript const axios = require('axios') const apiKey = '' // Replace with your API key. const apiKeySecret = '' // Replace with your API key secret. const Auth = Buffer.from(apiKey + ':' + apiKeySecret).toString('base64') // The chain ID of the supported network. const chainId = 1 ;(async () => { try { const { data } = await axios.get( `https://gas.api.infura.io/networks/${chainId}/suggestedGasFees`, { headers: { Authorization: `Basic ${Auth}`, }, } ) console.log('Suggested gas fees:', data) } catch (error) { console.log('Server responded with:', error) } })() ``` -------------------------------- ### onInstall Entry Point Source: https://github.com/metamask/metamask-docs/blob/main/snaps/reference/entry-points.md The `onInstall` entry point serves as a lifecycle hook, allowing a Snap to execute actions immediately after it has been successfully installed by the user. ```APIDOC ## `onInstall` ### Description To implement a [lifecycle hook](../features/lifecycle-hooks.md) that runs an action upon installation, a Snap must expose the `onInstall` entry point. MetaMask calls the `onInstall` handler method after the Snap is installed successfully. :::note For MetaMask to call the Snap's `onInstall` method, you must request the [`endowment:lifecycle-hooks`](permissions.md#endowmentlifecycle-hooks) permission. ::: ### Parameters None. ### Example Usage This entry point is typically used to display a welcome message or guide the user on how to use the Snap. ### Example Response (Dialog) ```json { "result": null } ``` ``` -------------------------------- ### Run Full Example Source: https://github.com/metamask/metamask-docs/blob/main/metamask-connect/evm/quickstart/nodejs.md This command executes the Node.js example script. ```bash node index.mjs ``` -------------------------------- ### Plugin Usage Example Source: https://github.com/metamask/metamask-docs/blob/main/embedded-wallets/sdk/js/events.mdx Example of how to get and use a plugin. ```APIDOC ## Plugin Usage Example ### Description Example of how to get and use a plugin. ### Code Example ```javascript const plugin = web3auth.getPlugin('walletServices'); if (plugin) { // Use the plugin console.log(plugin.name); } ``` ``` -------------------------------- ### Create a New Snap Project Source: https://github.com/metamask/metamask-docs/blob/main/snaps/get-started/quickstart.md Use the `@metamask/create-snap` starter kit to initialize a new Snap project. Choose the command that best suits your package manager preference. ```bash yarn create @metamask/snap your-snap-name ``` ```bash npx @metamask/snap your-snap-name ``` ```bash npm create @metamask/snap your-snap-name ``` -------------------------------- ### Get Base Fee Percentile (JavaScript) Source: https://github.com/metamask/metamask-docs/blob/main/services/reference/gas-api/api-reference/basefeepercentile.md This JavaScript example demonstrates how to use the axios library to make a request to the Gas API for the base fee percentile. It includes authentication setup using an API key and secret, and error handling. ```javascript const axios = require('axios') const apiKey = '' // Replace with your API key. const apiKeySecret = '' // Replace with your API key secret. const Auth = Buffer.from(apiKey + ':' + apiKeySecret).toString('base64') // The chain ID of the supported network. const chainId = 1 ;(async () => { try { const { data } = await axios.get( `https://gas.api.infura.io/networks/${chainId}/baseFeePercentile`, { headers: { Authorization: `Basic ${Auth}`, }, } ) console.log('Base fee percentile:', data) } catch (error) { console.log('Server responded with:', error) } })() ``` -------------------------------- ### Get User Operation Status Request Example Source: https://github.com/metamask/metamask-docs/blob/main/services/reference/optimism/json-rpc-methods/bundler/pimlico_getuseroperationstatus.mdx Example of a JSON-RPC request to get the status of a user operation using its hash. Ensure the method name and parameters are correctly formatted. ```json { "id": 1, "jsonrpc": "2.0", "method": "pimlico_getUserOperationStatus", "params": [ "0x..." ] } ``` -------------------------------- ### eth_getBalance Request Example Source: https://github.com/metamask/metamask-docs/blob/main/services/reference/arbitrum/json-rpc-methods/eth_getbalance.mdx This is an example of a JSON-RPC request to get the balance of an Ethereum account on Arbitrum. ```json { "jsonrpc": "2.0", "id": 1, "method": "eth_getBalance", "params": [ "0x203F310746000000000000000000000000000000", "latest" ] } ``` -------------------------------- ### Start Development Server Source: https://github.com/metamask/metamask-docs/blob/main/src/pages/tutorials/create-wallet-ai-agent.md Run the development server to test the dapp interface locally. ```bash npm run dev ``` -------------------------------- ### Get IPFS Block Example Source: https://github.com/metamask/metamask-docs/blob/main/services/reference/ipfs/http-api-methods/block_get.md This example demonstrates how to fetch a specific IPFS block using its multihash. Replace the example multihash and API credentials with your own. ```bash curl "https://ipfs.infura.io:5001/api/v0/block/get?arg=QmaYL7E4gDTPNfLxrCEEEcNJgcHBJ55NxxTnxpDKWqMtJ3" \ -X POST \ -u ":" ``` -------------------------------- ### Clone Vue Quickstart Application Source: https://github.com/metamask/metamask-docs/blob/main/src/pages/quickstart/builder/embedded-wallets/vue/stepContent/vueQuickStart.mdx Clone the Vue quickstart application to follow along with a complete example. ```shell npx degit Web3Auth/web3auth-examples/quick-starts/vue-quick-start w3a-quick-start ``` -------------------------------- ### Initialize Go Module and Install Dependencies Source: https://github.com/metamask/metamask-docs/blob/main/services/tutorials/ethereum/send-a-transaction/send-a-transaction-go.md Initialize a Go module and install necessary libraries for interacting with the Ethereum blockchain. ```bash go mod init infura ``` ```bash go get github.com/ethereum/go-ethereum/common ``` ```bash go get github.com/ethereum/go-ethereum/core/types ``` ```bash go get github.com/ethereum/go-ethereum/crypto ``` ```bash go get github.com/ethereum/go-ethereum/rpc@v1.10.17 ``` -------------------------------- ### Example .env configuration Source: https://github.com/metamask/metamask-docs/blob/main/services/tutorials/ethereum/authenticate-with-jwt.md An example of how your .env file should be populated with Infura credentials and network details. ```text INFURA_API_KEY=8c101...6b26c77d8 JWT_KEY_ID=777e2caf...826bc4303f INFURA_NETWORK_URL=https://sepolia.infura.io/v3/ ``` -------------------------------- ### Set Up Environment Variables Source: https://github.com/metamask/metamask-docs/blob/main/gator_versioned_docs/version-1.2.0/get-started/use-scaffold-eth/smart-accounts.md Navigate to the project's nextjs package and copy the example environment file to create a local configuration. Update NEXT_PUBLIC_PIMLICO_API_KEY with your actual key. ```bash cd your-project-name/packages/nextjs cp .env.example .env.local ``` -------------------------------- ### Full Example: MetaMask SDK for Node.js Source: https://github.com/metamask/metamask-docs/blob/main/metamask-connect/evm/quickstart/nodejs.md This snippet shows how to create an EVM client, connect to MetaMask, retrieve account balance, sign a message, and disconnect. Ensure you replace 'YOUR_INFURA_API_KEY' with your actual Infura API key. ```javascript import { createEVMClient, getInfuraRpcUrls } from '@metamask/connect-evm' const evmClient = await createEVMClient({ dapp: { name: 'My Node.js App', url: 'https://myapp.com', }, api: { supportedNetworks: getInfuraRpcUrls({ infuraApiKey: 'YOUR_INFURA_API_KEY', }), }, }) // Connect — scan the QR code with the MetaMask mobile app const { accounts, chainId } = await evmClient.connect({ chainIds: ['0x1'] }) console.log('Connected:', accounts[0], 'on', chainId) // Get balance const provider = evmClient.getProvider() const balance = await provider.request({ method: 'eth_getBalance', params: [accounts[0], 'latest'], }) console.log('Balance:', balance) // Sign a message const message = '0x' + Buffer.from('Hello from Node.js!', 'utf8').toString('hex') const signature = await provider.request({ method: 'personal_sign', params: [message, accounts[0]], }) console.log('Signature:', signature) // Disconnect await evmClient.disconnect() console.log('Disconnected') ``` -------------------------------- ### Get Transaction Receipt Request Source: https://github.com/metamask/metamask-docs/blob/main/services/reference/linea/json-rpc-methods/eth_gettransactionreceipt.mdx This is an example of a JSON-RPC request to get a transaction receipt by its hash on Linea. Ensure you have the correct transaction hash. ```json { "method": "eth_getTransactionReceipt", "params": [ "0x5c5b667711677117117117117117117117117117117117117117117117117117" ], "id": 1, "jsonrpc": "2.0" } ``` -------------------------------- ### Clone Flutter Quickstart Application Source: https://github.com/metamask/metamask-docs/blob/main/src/pages/quickstart/builder/embedded-wallets/flutter/stepContent/flutterQuickStart.mdx Clone the Flutter quickstart application to follow along with a complete example. This command uses degit to download the project. ```bash npx degit Web3Auth/web3auth-flutter-examples/flutter-quick-start flutter-quick-start ``` -------------------------------- ### Create a new Snap project Source: https://github.com/metamask/metamask-docs/blob/main/snaps/learn/tutorials/transaction-insights.md Use the @metamask/create-snap starter kit to initialize a new Snap project. Ensure Node.js version 20.11 or later and Yarn are installed. ```bash yarn create @metamask/snap transaction-insights-snap ``` ```bash yarn install ``` -------------------------------- ### OnInstall Hook (JSX) Source: https://github.com/metamask/metamask-docs/blob/main/snaps/features/lifecycle-hooks.md Use the `onInstall` entry point to run code when a user installs the Snap. This example displays an alert dialog. ```tsx import type { OnInstallHandler } from '@metamask/snaps-sdk' import { Box, Heading, Text } from '@metamask/snaps-sdk/jsx' export const onInstall: OnInstallHandler = async () => { await snap.request({ method: 'snap_dialog', params: { type: 'alert', content: ( Installation successful To use this Snap, visit the companion dapp at{' '} metamask.io. ), }, }) } ``` -------------------------------- ### IPFS HTTP API - Object Get Example Source: https://github.com/metamask/metamask-docs/blob/main/services/reference/ipfs/http-api-methods/index.md Example of how to use the 'object/get' command with the IPFS HTTP API, including authentication, arguments, and flags. ```APIDOC ## POST /api/v0/object/get ### Description Retrieves the IPFS object description for a given hash. ### Method POST ### Endpoint https://ipfs.infura.io:5001/api/v0/object/get ### Parameters #### Query Parameters - **arg** (string) - Required - The IPFS hash of the object to retrieve. - **encoding** (string) - Optional - Specifies the encoding format for the response. Use 'json' for JSON output. ### Request Example ```bash curl -X POST -u ":" "https://ipfs.infura.io:5001/api/v0/object/get?arg=QmaaqrHyAQm7gALkRW8DcfGX3u8q9rWKnxEMmf7m9z515w&encoding=json" ``` ### Response #### Success Response (200) - **Links** (array) - An array of links to other IPFS objects. - **Name** (string) - The name of the link. - **Hash** (string) - The IPFS hash of the linked object. - **Size** (integer) - The size of the linked object in bytes. - **Data** (string) - The data associated with the object (base64 encoded). #### Response Example ```json { "Links": [ { "Name": "index.html", "Hash": "QmYftndCvcEiuSZRX7njywX2AGSeHY2ASa7VryCq1mKwEw", "Size": 1700 }, { "Name": "static", "Hash": "QmdtWFiasJeh2ymW3TD2cLHYxn1ryTuWoNpwieFyJriGTS", "Size": 2428803 } ], "Data": "CAE=" } ``` ``` -------------------------------- ### Install @metamask/snaps-sdk Source: https://github.com/metamask/metamask-docs/blob/main/snaps/features/custom-ui/index.md Install the SDK to enable custom UI components. This command should be run in your Snap's project directory. ```bash yarn add @metamask/snaps-sdk ``` -------------------------------- ### Clone MetaMask SDK Examples Repository Source: https://github.com/metamask/metamask-docs/blob/main/metamask-connect/evm/quickstart/web3auth.md Alternatively, clone the entire MetaMask SDK examples repository using git and then navigate into the specific partner directory for Web3Auth integration. ```bash git clone https://github.com/MetaMask/metamask-sdk-examples cd metamask-sdk-examples/partners/web3auth ``` -------------------------------- ### Initialize Project Directory Source: https://github.com/metamask/metamask-docs/blob/main/services/reference/gas-api/quickstart.md Creates a new project directory and initializes npm. ```bash mkdir new_project cd new_project npm init -y ``` -------------------------------- ### zks_getL1BatchBlockRange Response Example Source: https://github.com/metamask/metamask-docs/blob/main/services/reference/zksync/json-rpc-methods/zks_getl1batchblockrange.mdx This is an example JSON response for the zks_getL1BatchBlockRange method, indicating the start and end block numbers of the specified batch in hexadecimal format. ```json { "jsonrpc": "2.0", "result": ["0x116fec", "0x117015"], "id": 1 } ``` -------------------------------- ### Initiate MFA Setup with enableMFA Source: https://github.com/metamask/metamask-docs/blob/main/embedded-wallets/sdk/flutter/migration-guides/flutter-v3-to-v4.mdx Use the `enableMFA` method to start the MFA setup flow for logged-in users. Handle `UserCancelledException` for user cancellations. ```dart try { // focus-next-line await Web3AuthFlutter.enableMFA(); } on UserCancelledException { log("User cancelled."); } catch(e) { log("Unknown exception occurred"); } ``` ```dart try { final loginParams = LoginParams( loginProvider: Provider.jwt, extraLoginOptions: ExtraLoginOptions( id_token: "YOUR_JWT_TOKEN", ), ); // focus-next-line await Web3AuthFlutter.enableMFA(loginParams); } on UserCancelledException { log("User cancelled."); } catch(e) { log("Unknown exceptionoccurred"); } ``` -------------------------------- ### Create a new Snap project Source: https://github.com/metamask/metamask-docs/blob/main/snaps/learn/tutorials/gas-estimation.md Use the create-snap starter kit to initialize a new Snap project. Ensure you have Node.js version 20.11 or later and Yarn installed. ```bash yarn create @metamask/snap gas-estimation-snap ``` ```bash yarn install ``` -------------------------------- ### Get DAG Node Example - Bash Source: https://github.com/metamask/metamask-docs/blob/main/services/reference/ipfs/http-api-methods/dag_get.md Example of retrieving a specific DAG node using its key. This command demonstrates how to authenticate and specify the node to fetch. ```bash curl "https://ipfs.infura.io:5001/api/v0/dag/get?arg=QmZtmD2qt6fJot32nabSP3CUjicnypEBz7bHVDhPQt9aAy" \ -X POST \ -u ":" ``` -------------------------------- ### Initialize Web3 and Connect to Infura Source: https://github.com/metamask/metamask-docs/blob/main/services/tutorials/ethereum/retrieve-the-balance-of-an-erc-20-token.md Import the Web3 library and establish a connection to the Infura mainnet endpoint. Replace `` with your actual Infura API key. ```javascript const { Web3 } = require('web3') const web3 = new Web3( new Web3.providers.HttpProvider('https://mainnet.infura.io/v3/') ) ``` -------------------------------- ### Get User Operation Status Request Source: https://github.com/metamask/metamask-docs/blob/main/services/reference/avalanche-c-chain/json-rpc-methods/bundler/pimlico_getuseroperationstatus.mdx Example of a request to get the status of a user operation using its hash. Ensure the correct chain ID and method are specified. ```json { "id": 1, "jsonrpc": "2.0", "method": "pimlico_getUserOperationStatus", "params": [ "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef" ] } ``` -------------------------------- ### Get User Operation Status Response Example Source: https://github.com/metamask/metamask-docs/blob/main/services/reference/optimism/json-rpc-methods/bundler/pimlico_getuseroperationstatus.mdx Example of a JSON-RPC response for pimlico_getUserOperationStatus, indicating the status of the user operation. The 'result' field contains the operation status. ```json { "id": 1, "jsonrpc": "2.0", "result": { "status": "VALID" } } ``` -------------------------------- ### Usage Example Source: https://github.com/metamask/metamask-docs/blob/main/embedded-wallets/sdk/android/advanced/mfa.mdx Demonstrates how to initialize Web3Auth with custom MFA settings and perform a login with mandatory MFA. ```APIDOC ## Usage Example ### Initialize Web3Auth with MFA Settings ```kotlin import com.web3auth.core.Web3Auth import com.web3auth.core.types.Web3AuthOptions val web3Auth = Web3Auth( Web3AuthOptions( context = this, clientId = "YOUR_WEB3AUTH_CLIENT_ID", // Pass your Web3Auth Client ID, ideally using an environment variable network = Network.MAINNET, redirectUrl = Uri.parse("{YOUR_APP_PACKAGE_NAME}://auth"), mfaSettings = MfaSettings( deviceShareFactor = MfaSetting(true, 1, true), socialBackupFactor = MfaSetting(true, 2, true), passwordFactor = MfaSetting(true, 3, false), backUpShareFactor = MfaSetting(true, 4, false), passkeysFactor = MfaSetting(true, 5, true), authenticatorFactor = MfaSetting(true, 6, true), ) ) ) ``` ### Login with Mandatory MFA ```kotlin val loginResponse = web3Auth.login( LoginParams( Proider.GOOGLE, mfaLevel = MFALevel.MANDATORY ) ) ``` ``` -------------------------------- ### eth_getProof RPC Method Example Source: https://github.com/metamask/metamask-docs/blob/main/metamask-connect/evm/reference/json-rpc-api/eth_getProof.mdx This example demonstrates how to use the eth_getProof method with a provider to get an account proof. Ensure you have a valid provider instance and the correct parameters. ```javascript await provider.request({ method: 'eth_getProof', params: [ '0xe5cB067E90D5Cd1F8052B83562Ae670bA4A211a8', [ '0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421', '0x283s34c8e2b1456f09832c71e5d6a0b4f8c9e1d3a2b5c7f0e6d4a8b2c1f3e5d7', ], 'latest', ], }) ``` ```json { "id": 1, "jsonrpc": "2.0", "result": { "accountProof": [ "0xf90211a06a718c2c9da77c253b12d7b2569657901e37bb691718f5dda1b86157ab1dd5eda0e7f19ed5e21bccc8d3260236b24f80ad88b3634f5d005f37b838881f0e12f1bda0abb301291704e4d92686c0f5f8ebb1734185321559b8d717ffdca95c99591976a0d0c2026bfab65c3b95276bfa82af9dec860b485f8857f293c148d63a2182128fa0c98044ec9a1273a218bed58b478277dd39173ad7b8edb95c200423a6bc8fc25fa056e5a55d9ddccdbf49362857200bbb1f042d61187c9f5f9ddcff5d2f1fc984a2a02a5b7200af424114f99a4b5f0a21c19aac82209e431ed80bfde177adb1004bdfa0026e4374f0518ff44a80fa374838ecb86cc64ac93bb710fea6dff4198f947b27a03fea341d87984673ad523177ed52f278bf4d8f97e6531c8ece932aeede4802f4a0bfe2f4a7fcb78f7e9f080dea7b6977fb1d88c441696e4456dad92b9d34ff0f43a02a3eb5c0edb14626c9c629601027bd60178bb2b688a67cea4d179fc432436615a0747355b8e02f3b884b4ffe5cea1619e32515fea064cca98208591af8c744e894a0874253737bae37f020ad3bb7e3292c7c4a63cdc158af6b33aaa4deaef016dccba03d8192bc1fc6aa1548912e763a0b5013a94399cefad7b47cf388873b2b794068a09b67f9737c6028d796bfd1c5da57a6f45824dc891f848ea0e1f8019d1fb5fba8a0aa871f9de8da85960fcd8a22cdf21c27f11e3966c14a6737ffd414b98dda00b280", "0xf90211a0d360be1e1da1a0c32bc4c105833bd531e59d110684007b7c50fb2709002973eca0cf6dd1e350a7031b4e2ab49c899fd8bd47551c8565d8fd8d1d7796c83820c3b1a0eb0a88c29bb33989a589156f7bf07d9efc74034dd9d3f5b73385c3b45c3249bea02783c25f97a6ddb8dc07adf4b176991836d39184b1f678adeda832fff15e3664a00a4e288060045e587774d8a64993a7add73068b16863145e1e8eeb4602e18e19a0340851f4046ad1298962d6e47d05c66329549c839c158748aaad7ae00b943aefa085b127bc2a3bd17604283de21b2b3c9aa8f1d4b7b85c94d8105a46fe32c77688a00f531d62b3c5435324c01009c284fe31277e8d38302b75ea01be89f09e205969a00011c8351c0e3d639ac54b9d3a59de630b16a67de8270d7d6064d0a67e93f9cca048780d32b7f2db88650b51c46f46fd0a68795edee1fd5ecee6eb3595741d9669a0c91afd74eaf8e08a997061a62b354e2516fdc494e8e26cc50ceeb8f4a175608ba0e2c07f1b48fab80eecb340f5882e8c7b32ee416e4045c61f1df646a133487303a01a1eff78435a7a29a29463bdc3486ae81364b00bea82ba0fdf67a110770f2261a04f2eb440ba71c72da5fd7f0e439018d6671dc809f747213a1ea755848124e994a074ff9f37fce99daa3ed01dd763076450022996fc729be2cc43c61ec5182c2366a0b80b36b7b621112592f52390b89748d422e9b1517c4b0203b8176a53f89d4a6680", "0xf90211a0b25f283bd01a8c8b2418049f9585bc37ff2c1e2e12eab4b7f64ae1f26647389aa02ad96c150d7c3c9c194d30315456852cf6a0a940e0191ae5d04007454823d4e9a0b220cf7a855e2dbcc0b973134e2e119b982d7d40dbb1b27d99816c41f40e829aa049224431da84cbf1b7ae813abcc9ef4c1dfc1760f6ddc5d57f7354bf3cbf6cc4a015191f879ac115b362f0257fd3eedb789537e836574a5b1abf1c9982ebe3bdfea07913c1b6e7282569d2d421e9fa2257f5d1698e93303bc49b941704287d7aaefea0a526576981ce6fd9f2bd48dd2ca6d5272f2fbdc85f0ee35a295f6ccd97ae8765a0313fad407f0c737c29024c02a890c4ecc12d7771c05ab7b435e5087a7cdef4d9a0d2044603cba9d4afdaf6fd2470e729ef3a65242de71276f20d59accfa6b53a7ca0457caacb9370c09b15f7d904adefd2308be94e23669ba5f43241ffff5f438a0aa09fb2dd45a383a0cc088a72b14117e1e9b7d6889218f3ac7631e8de644c5cb76da0c675dcd4d3fb692b514851c6106e2b09e6f5661d56a0a32ae02e2efc1515c235a074949a59ff1bdba87548510d6e404ec4532f4456dfdec8e753d92fda11a3088ba0a328c6ab1ab8f70db4d23e95bb163c13ba0c508f063a5b1393a4efd7ff375f05a0c722fe3ce796998269373cbb2fc229b2bdf2c43c6c2df003309422e043ce6c03a024e69343286eec44fa4744f6907209116e5383cff3fa98fe81ba06e7e8d4366680" ] } } ``` -------------------------------- ### Switch Chain Example Source: https://github.com/metamask/metamask-docs/blob/main/embedded-wallets/sdk/js/usage/switch-chain.mdx Demonstrates switching to Sepolia Testnet and Ethereum Mainnet with error handling. Initialize Web3Auth before executing this code. ```javascript // Initialize Web3Auth first // ... // Switch to Sepolia Testnet try { await web3auth.switchChain({ chainId: '0xaa36a7' }) console.log('Successfully switched to Sepolia Testnet') } catch (error) { console.error('Error switching chain:', error) } // Later, switch to Ethereum Mainnet try { await web3auth.switchChain({ chainId: '0x1' }) console.log('Successfully switched to Ethereum Mainnet') } catch (error) { console.error('Error switching chain:', error) } ``` -------------------------------- ### Invoke Custom Snap API from a Dapp Source: https://github.com/metamask/metamask-docs/blob/main/snaps/learn/about-snaps/apis.md A dapp can install and interact with a Snap's custom API. This example shows how to request Snap installation and invoke the 'hello' method. ```javascript // Request permission to connect to the Snap. // If the Snap is not already installed, the user will be prompted to install it. await window.ethereum.request({ method: 'wallet_requestSnaps', params: { // Assuming the Snap is published to npm using the package name "hello-snap". 'npm:hello-snap': {}, }, }) // Invoke the "hello" JSON-RPC method exposed by the Snap. const response = await window.ethereum.request({ method: 'wallet_invokeSnap', params: { snapId: 'npm:hello-snap', request: { method: 'hello', }, }, }) console.log(response) // "world!" ```