### Run Quickstart Example Source: https://docs.polygon.technology/interoperability/agglayer/developer-tools/agglayer-sdk/quickstart Executes the quickstart script using ts-node. ```bash npx ts-node quickstart-example.ts ``` -------------------------------- ### Complete Quickstart Example Source: https://docs.polygon.technology/interoperability/agglayer/developer-tools/agglayer-sdk/quickstart A full implementation combining route discovery, transaction building, and error handling. ```typescript import { AggLayerSDK } from '@agglayer/sdk'; async function quickstartExample() { try { const sdk = new AggLayerSDK(); const core = sdk.getCore(); console.log('SDK initialized'); const routes = await core.getRoutes({ fromChainId: 8453, // Base toChainId: 747474, // Katana fromTokenAddress: '0x4200000000000000000000000000000000000006', // WETH on Base toTokenAddress: '0xEE7D8BCFb72bC1880D0Cf19822eB0A2e6577aB62', // WETH on Katana amount: '1000000000000000000', // 1 ETH (18 decimals) fromAddress: '0xYourWalletAddress', slippage: 0.5, }); if (routes.length === 0) { console.log('No routes found for this combination'); return; } const bestRoute = routes[0]; console.log(`Best route: ${bestRoute.provider.join(' + ')}`); console.log(`Expected output: ${formatAmount(bestRoute.toAmount, 18)} WETH`); console.log(`Total cost: $${bestRoute.totalCostUSD}`); console.log(`Execution time: ${bestRoute.executionDuration}s`); const transaction = await core.getUnsignedTransaction(bestRoute); console.log('Transaction ready for wallet signing'); } catch (error) { console.error('Quickstart failed:', error); } } function formatAmount(amount: string, decimals: number = 18): string { return (Number(BigInt(amount)) / Number(BigInt(10 ** decimals))).toString(); } quickstartExample(); ``` -------------------------------- ### Guides Explorer Component Usage Source: https://docs.polygon.technology/resources/guides Example of how to instantiate the Guides Explorer component with required props. ```jsx ``` -------------------------------- ### Setup Ubuntu/Debian Environment Source: https://docs.polygon.technology/interoperability/agglayer/developer-tools/aggsandbox/installation Install essential build dependencies on Debian-based systems. ```bash sudo apt-get update sudo apt-get install -y build-essential curl ca-certificates ``` -------------------------------- ### Setup macOS Environment Source: https://docs.polygon.technology/interoperability/agglayer/developer-tools/aggsandbox/installation Install required build tools and handle architecture-specific build commands for Apple Silicon. ```bash # Install Xcode command line tools xcode-select --install # Install Homebrew dependencies brew install make git # Fix potential M1/M2 issues arch -arm64 make install ``` -------------------------------- ### Setup Windows WSL2 Environment Source: https://docs.polygon.technology/interoperability/agglayer/developer-tools/aggsandbox/installation Configure WSL2 and install necessary build tools. ```bash wsl --set-default-version 2 sudo apt-get update sudo apt-get install -y make git curl build-essential ``` -------------------------------- ### Copy Environment Configuration Source: https://docs.polygon.technology/interoperability/agglayer/developer-tools/aggsandbox/quickstart Copy the example environment file to `.env` to configure your AggSandbox setup. ```bash cp .env.example .env ``` -------------------------------- ### Run Installation Test Source: https://docs.polygon.technology/interoperability/agglayer/developer-tools/lxlyjs/installation Executes the test-installation.js script to verify the Lxly.js setup. ```bash node test-installation.js ``` -------------------------------- ### Install x402facilitators Source: https://docs.polygon.technology/payment-services/agentic-payments/x402/guides/using-x402facilitators Install the package using your preferred package manager. ```bash bun add @swader/x402facilitators # npm install @swader/x402facilitators ``` -------------------------------- ### Install dApp Launchpad CLI Source: https://docs.polygon.technology/tools/dApp-development/launchpad/quickstart Install the CLI globally to access the dapp-launchpad command. ```bash npm install -g @polygonlabs/dapp-launchpad ``` -------------------------------- ### Install AggSandbox CLI tool Source: https://docs.polygon.technology/interoperability/agglayer/developer-tools/aggsandbox/installation Clones the AggSandbox repository and installs the CLI tool using `make install`. Verify the installation by running `aggsandbox --help`. ```bash # Clone repository git clone https://github.com/agglayer/aggsandbox cd aggsandbox # Install CLI tool make install # Verify installation aggsandbox --help ``` -------------------------------- ### Monitor installation progress Source: https://docs.polygon.technology/pos/how-to/full-node/full-node-gcp Use screen to view the ongoing installation or snapshot bootstrap progress. ```bash # inside the connected session screen -dr ``` -------------------------------- ### Install Sequence Connect SDK Source: https://docs.polygon.technology/wallets/quickstart Install the required packages for the Sequence Connect integration. ```bash pnpm install @0xsequence/connect@6 wagmi viem ``` -------------------------------- ### Install SDK Dependencies Source: https://docs.polygon.technology/wallets/sdk/getting-started Install the required packages using npm, pnpm, or yarn. ```bash npm install @0xsequence/connect@6 wagmi viem # or pnpm install @0xsequence/connect@6 wagmi viem # or yarn add @0xsequence/connect@6 wagmi viem ``` -------------------------------- ### Clone AggSandbox Repository and Install Source: https://docs.polygon.technology/interoperability/agglayer/developer-tools/aggsandbox/quickstart Clone the AggSandbox repository and install the necessary tools using the make command. The CLI will be installed to `~/.local/bin`. ```bash git clone https://github.com/agglayer/aggsandbox cd aggsandbox make install ``` -------------------------------- ### Install Make and Git on Ubuntu/Debian and macOS Source: https://docs.polygon.technology/interoperability/agglayer/developer-tools/aggsandbox/installation Installs `make` and `git` on Ubuntu/Debian using `apt-get` and on macOS using Homebrew. Verify installations with `make --version` and `git --version`. ```bash # Ubuntu/Debian sudo apt-get update sudo apt-get install -y make git # macOS (with Homebrew) brew install make git # Verify installation make --version git --version ``` -------------------------------- ### Install AggSandbox CLI Source: https://docs.polygon.technology/interoperability/agglayer/get-started/quickstart Clone the repository and install the CLI tool using make. ```bash git clone https://github.com/agglayer/aggsandbox.git cd aggsandbox make install ``` -------------------------------- ### Define Guide Data and Options Source: https://docs.polygon.technology/resources/guides Configuration arrays and guide objects used to populate the explorer component. ```javascript export const useCaseOptions = ['Cross-border Payments', 'Stablecoin Integration', 'KYC & Compliance', 'Agentic Payments', 'Identity', 'Chain Deployment', 'Node Operations', 'Cross-chain', 'DeFi']; export const productOptions = ['Payments API', 'Embedded Wallets', 'x402 Protocol', 'Polygon Chain', 'Polygon CDK', 'Agglayer', 'Vault Bridge', 'Trails']; export const guides = [{ id: 'morpho-vault-deposit', title: 'Allow Your Users to Earn', description: 'Deposit USDC into a Morpho vault on Polygon using Trails and Sequence Embedded Wallets.', href: '/wallets/morpho-vault-deposit', products: ['Embedded Wallets', 'Trails'], useCases: ['DeFi', 'Cross-chain'], tags: ['Wallets', 'Interoperability'] }, { id: 'treasury-wallet', title: 'Automate USDC collection with a Treasury Wallet', description: 'Automate pull-and-push USDC flows from client wallets to a central treasury using Sequence Embedded Wallets and Smart Sessions.', href: '/wallets/treasury-wallet', products: ['Embedded Wallets'], useCases: ['Cross-border Payments', 'Stablecoin Integration'], tags: ['Wallets', 'Payments'] }, { id: 'become-a-validator', title: 'Become a Validator', description: 'Learn how to stake, run a validator node, and participate in Polygon Chain consensus.', href: '/pos/get-started/becoming-a-validator', products: ['Polygon Chain'], useCases: ['Node Operations'], tags: ['Polygon Chain'] }, { id: 'run-a-node', title: 'Run a Node', description: 'Set up and operate a full node or archive node on Polygon Chain.', href: '/pos/how-to/prerequisites', products: ['Polygon Chain'], useCases: ['Node Operations'], tags: ['Polygon Chain'] }]; ``` -------------------------------- ### Install Chain Indexer Framework Source: https://docs.polygon.technology/tools/chain-indexer-framework/usage Use these commands to install the framework package via npm or Yarn. ```bash npm install @maticnetwork/chain-indexer-framework ``` ```bash yarn add @maticnetwork/chain-indexer-framework ``` -------------------------------- ### Install Rust Source: https://docs.polygon.technology/interoperability/agglayer/developer-tools/aggsandbox/installation Use the official rustup script to install or reinstall the Rust toolchain. ```bash curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh ``` -------------------------------- ### Initialize POSClient Source: https://docs.polygon.technology/tools/matic-js/pos/client Initialize the POSClient with network, version, and provider details for parent and child chains. Ensure Matic.js is set up by following the get started guide. ```javascript import { POSClient,use } from "@maticnetwork/maticjs" import { Web3ClientPlugin } from '@maticnetwork/maticjs-web3' import HDWalletProvider from "@truffle/hdwallet-provider" // install web3 plugin use(Web3ClientPlugin); const posClient = new POSClient(); await posClient.init({ network: 'testnet', version: 'amoy', parent: { provider: new HDWalletProvider(privateKey, mainRPC), defaultConfig: { from : fromAddress } }, child: { provider: new HDWalletProvider(privateKey, childRPC), defaultConfig: { from : fromAddress } } }); ``` -------------------------------- ### Install x402-fetch and viem dependencies Source: https://docs.polygon.technology/payment-services/agentic-payments/x402/guides/quickstart-buyers Install the necessary packages for the x402 buyer client. Replace `bun` with `npm` or your preferred package manager if needed. ```bash bun install x402-fetch # or bun install x402-axios ``` ```bash bun install viem dotenv ``` -------------------------------- ### Initialize a new project Source: https://docs.polygon.technology/tools/dApp-development/launchpad/quickstart Create a new dApp project directory with default or custom templates. ```bash dapp-launchpad init ``` ```bash dapp-launchpad init --template typescript ``` ```bash dapp-launchpad list scaffold-templates ``` -------------------------------- ### Multi-Bridge Routing Example with AggLayerSDK Source: https://docs.polygon.technology/interoperability/agglayer/developer-tools/agglayer-sdk/multi-bridge-routes/step-by-step-guide/multi-bridge-routing-mainnet This TypeScript example shows how to use the AggLayerSDK to perform multi-bridge routing from Ethereum to Katana. It covers chain verification, route discovery, transaction building, and approval checks. Ensure the SDK is installed (`npm install @agglayer/sdk`). ```typescript import { AggLayerSDK } from '@agglayer/sdk'; async function multiBridgeExample() { try { console.log('Multi-Bridge Routing Example - Ethereum → Katana'); // Initialize SDK const sdk = new AggLayerSDK(); const core = sdk.getCore(); // Step 1: Verify supported chains const chains = await core.getAllChains(); const ethereumChain = chains.chains.find(c => c.chainId === 1); const katanaChain = chains.chains.find(c => c.chainId === 747474); console.log(`Ethereum supported: ${ethereumChain ? 'Yes' : 'No'}`); console.log(`Katana supported: ${katanaChain ? 'Yes' : 'No'}`); // Step 2: Discover routes const routes = await core.getRoutes({ fromChainId: 1, toChainId: 747474, fromTokenAddress: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', toTokenAddress: '0x203a662b0bd271a6ed5a60edfbd04bfce608fd36', amount: '1000000000', fromAddress: '0x222112d597336CB201221Bf3acC0a6230475aF99', slippage: 0.5, preferences: { prioritize: 'COST', }, }); if (routes.length === 0) { console.log('No routes found'); return; } // Step 3: Analyze best route const bestRoute = routes[0]; console.log(`Best route: ${bestRoute.provider.join(' + ')}`); console.log(`Expected output: ${formatAmount(bestRoute.toAmount, 6)} USDC`); console.log(`Total cost: $${bestRoute.totalCostUSD}`); console.log(`Execution time: ${bestRoute.executionDuration || 'N/A'}s`); // Step 4: Build transaction const transaction = await core.getUnsignedTransaction(bestRoute); console.log('Transaction ready for signing'); console.log(`To: ${transaction.to}`); console.log(`Gas limit: ${transaction.gasLimit}`); // Step 5: Check approval requirements const approvalStep = bestRoute.steps.find(step => step.estimate.approvalAddress); if (approvalStep) { console.log('Approval required before bridge transaction'); } else { console.log('No approval required'); } console.log('\nMulti-Bridge routing walkthrough completed!'); } catch (error) { console.error('Example failed:', error); } } function formatAmount(amount: string, decimals: number = 18): string { return (Number(BigInt(amount)) / Number(BigInt(10 ** decimals))).toString(); } multiBridgeExample(); ``` -------------------------------- ### Start development environment Source: https://docs.polygon.technology/tools/dApp-development/launchpad/quickstart Launch the local development environment, including the test blockchain and hot-reloading frontend. ```bash dapp-launchpad dev ``` -------------------------------- ### Copy Example Parameter File Source: https://docs.polygon.technology/chain-development/cdk/cdk-opgeth/devnet-deployment-guide Copy the example parameter file to create a new configuration for the sovereign genesis. ```bash cp ./tools/createSovereignGenesis/create-genesis-sovereign-params.json.example ./tools/createSovereignGenesis/create-genesis-sovereign-params.json ``` -------------------------------- ### Initialize New Project with dApp Launchpad CLI Source: https://docs.polygon.technology/tools/dApp-development/launchpad/commands Use the `init` command to create a new project. Specify a project name or let the CLI choose a random one. Use the `-t` option to select a scaffold template. ```bash dapp-launchpad init [PROJECT-NAME] ``` ```bash dapp-launchpad init -h ``` -------------------------------- ### View dApp Launchpad deployment help Source: https://docs.polygon.technology/tools/dApp-development/launchpad/smart-contracts Displays available options for the production deployment command. ```bash dapp-launchpad deploy -h ``` -------------------------------- ### Clone x402 Autopay Repository Source: https://docs.polygon.technology/payment-services/agentic-payments/x402/tools/autopay Clone the x402 Autopay repository from GitHub to start the installation process. ```bash git clone https://github.com/Swader/x402autopay ``` -------------------------------- ### View dApp Launchpad development help Source: https://docs.polygon.technology/tools/dApp-development/launchpad/smart-contracts Displays available options for the local development command. ```bash dapp-launchpad dev -h ``` -------------------------------- ### Start Aggkit Infrastructure Source: https://docs.polygon.technology/chain-development/cdk/cdk-opgeth/devnet-deployment-guide Launch the database and Aggkit services. ```bash docker compose up -d db ``` ```bash docker compose up -d bridge docker compose up -d aggkit ``` -------------------------------- ### Trails SDK - Swap Functionality Source: https://docs.polygon.technology/trails/index Example of using the `useQuote` hook from the Trails SDK to get a quote for swapping tokens and then executing the swap. ```APIDOC ## Trails SDK - Swap Functionality ### Description Exchange any token for any other token across chains using the Trails SDK. ### Usage ```tsx import { useQuote } from "0xtrails"; const { quote, swap } = useQuote({ fromTokenAddress: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", // ETH on Mainnet fromChainId: 1, toTokenAddress: "0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359", // USDC on Polygon toChainId: 137, swapAmount: "1000000000000000000", // 1 ETH in wei tradeType: "EXACT_INPUT", slippageTolerance: "0.005", onStatusUpdate: (status) => console.log("Swap status:", status), }); await swap(); ``` ``` -------------------------------- ### Configure project environment Source: https://docs.polygon.technology/tools/dApp-development/launchpad/quickstart Navigate to project directories and prepare environment files for frontend and smart contracts. ```bash cd ``` ```bash cd frontend cp .env.example .env ``` ```bash cd ../smart-contracts cp .env.example .env ``` -------------------------------- ### CLI Query Checkpoint Parameters Source: https://docs.polygon.technology/pos/architecture/heimdall_v2/checkpoints Use this CLI command to retrieve checkpoint parameters. No specific setup is required beyond having the heimdalld tool installed. ```bash heimdalld query checkpoint get-params ``` -------------------------------- ### L2 to L2 Bridging Configuration Source: https://docs.polygon.technology/interoperability/agglayer/developer-tools/aggsandbox/asset-bridging Example configuration for L2 to L2 bridging in multi-L2 mode. Ensure multi-L2 mode is started first. Sync time is longer for L2-L2 bridging, approximately 45-60 seconds. ```bash # Start multi-L2 mode first aggsandbox stop aggsandbox start --multi-l2 --detach # L2-1 → L2-2: LX=1, LY=2 # L2-2 → L2-1: LX=2, LY=1 # Sync time: ~45-60 seconds (longer for L2-L2) ``` -------------------------------- ### Start Sandbox Environment Source: https://docs.polygon.technology/interoperability/agglayer/developer-tools/aggsandbox/cli-commands Commands to initialize the sandbox, with options for background execution, rebuilding, and network configuration. ```bash aggsandbox start [OPTIONS] ``` ```bash # Basic start aggsandbox start --detach # Start with real data aggsandbox start --fork --detach # Start multi-L2 mode for L2-L2 testing aggsandbox start --multi-l2 --detach # Start with automatic claiming aggsandbox start --claim-all --detach ``` -------------------------------- ### Trails Widget - Fund Mode Source: https://docs.polygon.technology/trails/index Example of using the Trails Widget in 'fund' mode to deposit funds into any wallet or chain from any starting token. This mode includes a built-in onramp for credit card, bank, or crypto funding. ```APIDOC ## Trails Widget - Fund Mode ### Description Deposit funds into any wallet or chain from any starting token. Fund mode includes a built-in onramp: users can fund directly from a credit card, bank account, or existing crypto balance without leaving your app. ### Usage ```tsx import { TrailsWidget } from "0xtrails/widget"; ``` **Note:** The Widget surfaces onramp options (card, bank) alongside crypto funding automatically when `mode="fund"` is set. ``` -------------------------------- ### AggLayer SDK Initialization and Bridge Asset Transaction Source: https://docs.polygon.technology/interoperability/agglayer/developer-tools/agglayer-sdk/agglayer-native-bridge/operations/bridge-operations Example demonstrating AggLayer SDK initialization with custom RPC URLs and building a bridge asset transaction. Includes checking claim status and getting wrapped token addresses. ```typescript import { AggLayerSDK, SDK_MODES } from '@agglayer/sdk'; const sdk = new AggLayerSDK({ mode: [SDK_MODES.NATIVE], native: { defaultNetwork: 1, customRpcUrls: { 1: 'https://eth-mainnet.g.alchemy.com/v2/your-key', 747474: 'https://rpc.katana.network', }, }, }); const native = sdk.getNative(); const bridge = native.bridge('0x2a3DD3EB832aF982ec71669E178424b10Dca2EDe', 1); // Build bridge asset transaction const bridgeAssetTx = await bridge.buildBridgeAsset( { destinationNetwork: 20, destinationAddress: '0xRecipientAddress', amount: '10000000000', token: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', forceUpdateGlobalExitRoot: true, permitData: '0x', }, '0xUserAddress' ); // Check claim status const isClaimed = await bridge.isClaimed({ leafIndex: 12345, sourceBridgeNetwork: 0, }); // Get wrapped token address const wrappedAddress = await bridge.getWrappedTokenAddress({ originNetwork: 0, originTokenAddress: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', }); ``` -------------------------------- ### Use useTheme Hook for Theme and Modal Settings Source: https://docs.polygon.technology/wallets/sdk/hooks/use-theme Use the useTheme hook to get and set the current theme ('light' or 'dark') and the modal's position (e.g., 'center', 'top-right'). This example demonstrates updating theme and position based on user interactions. ```tsx import { useTheme } from '@0xsequence/connect' function App() { const { theme, setTheme, position, setPosition } = useTheme() return (

Theme Settings

Modal Position

) } ``` -------------------------------- ### Install Heimdall Source: https://docs.polygon.technology/pos/how-to/validator/validator-binaries Install the Heimdall binary using the installation script. ```bash curl -L https://raw.githubusercontent.com/0xPolygon/install/heimdall-v2/heimdall-v2.sh | bash -s -- ``` -------------------------------- ### Deploy smart contracts and frontend Source: https://docs.polygon.technology/tools/dApp-development/launchpad/commands Deploys project components to a specified network. Use the help flag to view available options. ```bash dapp-launchpad deploy -n CHAIN_NAME ``` ```bash dapp-launchpad deploy -h ``` -------------------------------- ### Agglayer SDK Working Example Source: https://docs.polygon.technology/interoperability/agglayer/developer-tools/agglayer-sdk/agglayer-native-bridge/operations/chain-management A comprehensive example demonstrating SDK initialization, network configuration, and registry interaction. ```typescript import { AggLayerSDK, SDK_MODES } from '@agglayer/sdk'; const sdk = new AggLayerSDK({ mode: [SDK_MODES.NATIVE], native: { defaultNetwork: 1, customRpcUrls: { 1: 'https://eth-mainnet.g.alchemy.com/v2/your-key', 747474: 'https://rpc.katana.network', }, }, }); const native = sdk.getNative(); // Get supported networks const supportedNetworks = native.getSupportedNetworks(); const defaultNetwork = native.getDefaultNetwork(); // Get network configuration const ethereumConfig = native.getNetwork(1); // Access chain registry const chainRegistry = native.getChainRegistry(); const allChains = chainRegistry.getAllChains(); const isSupported = chainRegistry.isChainSupported(747474); ``` -------------------------------- ### Install build-essential Package Source: https://docs.polygon.technology/pos/how-to/full-node/full-node-binaries This command is required to install the build-essential package on your system. Run this before proceeding with other installations. ```bash sudo apt-get update sudo apt-get install build-essential ``` -------------------------------- ### dapp-launchpad init Source: https://docs.polygon.technology/tools/dApp-development/launchpad/commands Initializes a new project in a new directory. If no project name is provided, a random name is chosen. ```APIDOC ## dapp-launchpad init ### Description Initializes a new project in a new directory. If no project name is provided, a random name is chosen. ### Method CLI Command ### Endpoint N/A ### Parameters #### Path Parameters - **PROJECT-NAME** (string) - Optional - The name of the project to initialize. #### Query Parameters N/A #### Request Body N/A ### Request Example ```bash dapp-launchpad init [PROJECT-NAME] ``` ### Options #### Command Options - **-t, --template [NAME]** (string) - Optional - Name of the scaffold template to use. To get the list of available templates, run `list scaffold-templates`. (default: "javascript") - **-h, --help** - Optional - Display help for command ### Response N/A ### Response Example N/A ``` -------------------------------- ### Install Dependencies with npm Source: https://docs.polygon.technology/tools/oracles/supra Install necessary dependencies by running this command in your project directory. Ensure Node.js is installed. ```bash npm install ``` -------------------------------- ### Install RabbitMQ on Ubuntu Source: https://docs.polygon.technology/pos/how-to/prerequisites Commands to update the package list, install dependencies, and install the RabbitMQ server package. ```bash sudo apt-get update sudo apt install build-essential sudo apt install erlang wget https://github.com/rabbitmq/rabbitmq-server/releases/download/v3.10.8/rabbitmq-server_3.10.8-1_all.deb sudo dpkg -i rabbitmq-server_3.10.8-1_all.deb ``` -------------------------------- ### Install Dependencies for Wallet Linking Source: https://docs.polygon.technology/wallets/wallet-linking Install the necessary packages for wallet linking using pnpm. Ensure you have @0xsequence/waas and wagmi installed. ```bash pnpm install @0xsequence/waas wagmi ``` -------------------------------- ### Start local development with Ethernal Source: https://docs.polygon.technology/tools/dApp-development/launchpad/smart-contracts Launches the local development environment with the Ethernal block explorer enabled. ```bash dapp-launchpad dev -e ``` -------------------------------- ### Enable and Start Heimdall Telemetry Service Source: https://docs.polygon.technology/pos/reference/telemetry-setup-guide Enable the telemetry service to start on boot and then start the service immediately. This ensures continuous monitoring. ```sh sudo systemctl enable telemetry.service sudo systemctl start telemetry.service ``` -------------------------------- ### Install Bor Package Source: https://docs.polygon.technology/pos/how-to/full-node/full-node-packages Use the installation script to set up Bor. Replace placeholders with the desired version, network, and node type. ```shell curl -L https://raw.githubusercontent.com/0xPolygon/install/main/bor.sh | bash -s -- ``` ```shell # Example: # curl -L https://raw.githubusercontent.com/0xPolygon/install/main/bor.sh | bash -s -- v2.2.9 mainnet sentry ``` -------------------------------- ### Install Docker on Ubuntu Source: https://docs.polygon.technology/pos/how-to/full-node/full-node-docker Commands to update the package index, install dependencies, add the official Docker GPG key, and install the Docker engine. ```bash sudo apt-get update sudo apt-get install ca-certificates curl gnupg lsb-release sudo mkdir -p /etc/apt/keyrings curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg echo \ "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \ $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null sudo apt-get update sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin ``` -------------------------------- ### CLI Command: aggsandbox start Source: https://docs.polygon.technology/interoperability/agglayer/developer-tools/aggsandbox/cli-commands Starts the sandbox environment with various configuration options for networking and data handling. ```APIDOC ## aggsandbox start ### Description Starts the sandbox environment with all required services. ### Parameters #### Options - **--detach, -d** (flag) - Optional - Start in background (detached mode) - **--build, -b** (flag) - Optional - Rebuild Docker images before starting - **--fork, -f** (flag) - Optional - Use real blockchain data from FORK_URL - **--multi-l2, -m** (flag) - Optional - Enable multi-L2 mode (adds L2-2 network) - **--claim-all, -c** (flag) - Optional - Auto-sponsor all claims ``` -------------------------------- ### Install WalletKit SDK with yarn Source: https://docs.polygon.technology/tools/wallets/walletkit Use yarn to install the necessary WalletKit packages. This command installs both the React link component and the core JavaScript SDK. ```bash yarn add @walletkit/react-link walletkit-js ``` -------------------------------- ### Install WalletKit SDK with npm Source: https://docs.polygon.technology/tools/wallets/walletkit Use npm to install the necessary WalletKit packages. This command installs both the React link component and the core JavaScript SDK. ```bash npm i @walletkit/react-link walletkit-js ``` -------------------------------- ### Install Heimdall via Shell Script Source: https://docs.polygon.technology/pos/how-to/validator/validator-packages Installs Heimdall binaries using the provided installation script. Specify version, network, and node type as arguments. ```shell curl -L https://raw.githubusercontent.com/0xPolygon/install/heimdall-v2/heimdall-v2.sh | bash -s -- ``` ```shell # Example: curl -L https://raw.githubusercontent.com/0xPolygon/install/heimdall-v2/heimdall-v2.sh | bash -s -- v0.2.16 mainnet sentry ``` -------------------------------- ### Configure AggSandbox environment variables Source: https://docs.polygon.technology/interoperability/agglayer/developer-tools/aggsandbox/installation Copies the example environment file and provides an example of how to edit it for network and service configurations. Available variables include RPC URLs, ports, and logging settings. ```bash # Copy example configuration cp .env.example .env # Edit configuration nano .env ``` ```dotenv # Network Configuration FORK_URL_L1=https://eth-mainnet.alchemyapi.io/v2/your-key FORK_URL_L2=https://polygon-mainnet.alchemyapi.io/v2/your-key # Service Ports L1_RPC_PORT=8545 L2_RPC_PORT=8546 BRIDGE_API_PORT=5577 # Docker Configuration DOCKER_COMPOSE_FILE=docker-compose.yml DOCKER_NETWORK=aggsandbox_default # Logging LOG_LEVEL=info DEBUG_MODE=false ``` -------------------------------- ### Install Bor via Shell Script Source: https://docs.polygon.technology/pos/how-to/validator/validator-packages Installs Bor binaries using the provided installation script. Supports optional version, network, and node type parameters. ```shell curl -L https://raw.githubusercontent.com/0xPolygon/install/main/bor.sh | bash ``` ```shell # structure curl -L https://raw.githubusercontent.com/0xPolygon/install/main/bor.sh | bash -s -- # Example: curl -L https://raw.githubusercontent.com/0xPolygon/install/main/bor.sh | bash -s -- v2.0.0 mainnet sentry ``` -------------------------------- ### Start Local Development Environment with dApp Launchpad CLI Source: https://docs.polygon.technology/tools/dApp-development/launchpad/commands The `dev` command starts a local Hardhat blockchain and a Next.js frontend server. Options allow for forking networks, resetting on changes, and enabling a chain explorer. ```bash dapp-launchpad dev [options] ``` ```bash dapp-launchpad dev -h ``` -------------------------------- ### Deploy to production Source: https://docs.polygon.technology/tools/dApp-development/launchpad/quickstart Deploy smart contracts and frontend to a specified chain. ```bash dapp-launchpad deploy -n ``` ```bash dapp-launchpad deploy -n CHAIN_NAME --only-smart-contracts ``` ```bash dapp-launchpad deploy -n CHAIN_NAME --only-frontend ``` ```bash generate smart-contracts-config -e production -n CHAIN_NAME ``` -------------------------------- ### Start Bor Service Source: https://docs.polygon.technology/pos/how-to/full-node/full-node-ansible Start the Bor service after Heimdall is synced. ```bash sudo service bor start ``` -------------------------------- ### Polygon Agent CLI: Setup and Wallet Creation Source: https://docs.polygon.technology/wallets/agentic-wallets Initialize a new agent profile, set the project access key, and create a new smart contract wallet. The wallet creation process requires a one-time browser approval. ```bash # 1. Create an EOA and get a project access key polygon-agent setup --name "MyAgent" # 2. Set your access key export SEQUENCE_PROJECT_ACCESS_KEY= # 3. Create a wallet (opens browser for one-time approval) polygon-agent wallet create ``` -------------------------------- ### Clean Ansible Setup Source: https://docs.polygon.technology/pos/how-to/full-node/full-node-ansible Remove and clean the existing Ansible setup. ```bash ansible-playbook playbooks/clean.yml ``` -------------------------------- ### Install Docker and Docker Compose on Ubuntu/Debian Source: https://docs.polygon.technology/interoperability/agglayer/developer-tools/aggsandbox/installation Installs Docker and Docker Compose using a script and direct download. Verify the installation with `docker --version` and `docker compose version`. ```bash # Install Docker (Ubuntu/Debian) curl -fsSL https://get.docker.com -o get-docker.sh sh get-docker.sh # Install Docker Compose sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose sudo chmod +x /usr/local/bin/docker-compose # Verify installation docker --version docker compose version ``` -------------------------------- ### Example: Deconvert Custom Tokens Source: https://docs.polygon.technology/chain-development/vault-bridge/reference/abi-reference Demonstrates checking available backing and approving tokens before deconversion. ```solidity // Check if deconversion is possible uint256 maxDeconvertable = nativeConverter.maxDeconvert(userAddress); require(amount <= maxDeconvertable, "Insufficient backing"); // Approve Custom Token for burning vbUSDC.approve(address(nativeConverter), amount); // Deconvert uint256 assets = nativeConverter.deconvert(amount, userAddress); ``` -------------------------------- ### Install build-essential Source: https://docs.polygon.technology/pos/how-to/validator/validator-binaries Install the build-essential package required for compiling software on both nodes. ```bash sudo apt-get install build-essential ``` -------------------------------- ### Initialize Client Configuration Source: https://docs.polygon.technology/interoperability/agglayer/developer-tools/lxlyjs/api-reference Configure the client with network providers and settings before performing operations. ```javascript await client.init({ network: 'testnet', providers: { 0: { provider: ethereumProvider, configuration: { bridgeAddress: '0x...' } }, 1: { provider: polygonProvider, configuration: { bridgeAddress: '0x...' } } } }); ```