### Quickstart: setup, wallet creation, and operations Source: https://docs.polygon.technology/wallets/agentic-wallets A step-by-step quickstart covering setup, access key export, wallet creation, funding, balances, sending, swapping, and agent registration. All commands are dry-run by default; add --broadcast to execute. ```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 # 4. Fund the wallet polygon-agent fund # 5. Start operating polygon-agent balances polygon-agent send --symbol USDC --to 0x... --amount 10 --broadcast polygon-agent swap --from USDC --to USDT --amount 5 --broadcast # 6. Register your agent onchain polygon-agent agent register --name "MyAgent" --broadcast ``` -------------------------------- ### Install and setup Polygon Agent CLI Source: https://docs.polygon.technology/payment-services/agentic-payments/solutions/treasury-yield-sweep Install the CLI globally, initialize the treasury agent, and create a smart wallet with DeFi capabilities enabled. ```bash npm install -g @polygonlabs/agent-cli polygon-agent setup --name "treasury" polygon-agent wallet create --defi --usdc-limit 50000 ``` -------------------------------- ### Install and Setup Polygon Agent CLI Source: https://docs.polygon.technology/payment-services/agentic-payments/solutions/cross-corridor-payouts Install the CLI globally and initialize the treasury agent with a specified USDC limit. ```bash npm install -g @polygonlabs/agent-cli polygon-agent setup --name "ap-treasury" polygon-agent wallet create --usdc-limit 100000 ``` -------------------------------- ### Setup and create smart wallet example Source: https://docs.polygon.technology/payment-services/agentic-payments/cli/setup-and-wallets A complete workflow for initializing a machine, creating a smart wallet with specific spending caps and DeFi access, and verifying the wallet status. ```bash # One-time per machine polygon-agent setup --name "treasury" # Smart wallet with caps polygon-agent wallet create \ --name treasury \ --chain polygon \ --usdc-limit 1000 \ --usdt-limit 1000 \ --defi # Confirm polygon-agent wallet list polygon-agent wallet address --name treasury ``` -------------------------------- ### Install and set up Polygon Agent CLI for Polymarket Source: https://docs.polygon.technology/payment-services/agentic-payments/solutions/polymarket-hedging Installs the @polygonlabs/agent-cli globally, creates a hedging desk wallet with a USDC limit, and performs one-time Polymarket setup: importing an EOA private key and approving the proxy wallet. The smart wallet funds the Polymarket proxy on each buy; size --usdc-limit to match the maximum notional you intend to hedge. ```bash npm install -g @polygonlabs/agent-cli polygon-agent setup --name "hedging-desk" polygon-agent wallet create --usdc-limit 5000 # One-time Polymarket setup polygon-agent polymarket set-key 0xYOUR_EOA_PRIVATE_KEY polygon-agent polymarket approve --broadcast ``` -------------------------------- ### Install WalletKit with npm Source: https://docs.polygon.technology/tools/wallets/walletkit Install the @walletkit/react-link and walletkit-js packages to get started with the SDK. This is an alternative to yarn. ```bash npm i @walletkit/react-link walletkit-js ``` -------------------------------- ### Install Heimdall (specific version example) Source: https://docs.polygon.technology/pos/how-to/validator/validator-packages Example command to install a specific Heimdall version, node type, and network. This example installs v0.11.0 for mainnet sentry. Heimdall versions below v0.11.0 fell out of consensus at the Kyoto hardfork. ```shell # Example: curl -L https://raw.githubusercontent.com/0xPolygon/install/heimdall-v2/heimdall-v2.sh | bash -s -- v0.11.0 mainnet sentry ``` -------------------------------- ### dapp-launchpad init help Source: https://docs.polygon.technology/tools/dApp-development/launchpad/commands Displays help for the `init` command. ```bash dapp-launchpad init -h ``` -------------------------------- ### Install Bor specific version example Source: https://docs.polygon.technology/pos/how-to/full-node/full-node-packages Example command to install a specific version of Bor for a sentry node on Mainnet. ```shell # Example: # curl -L https://raw.githubusercontent.com/0xPolygon/install/main/bor.sh | bash -s -- v2.2.9 mainnet sentry ``` -------------------------------- ### Install Heimdall specific version example Source: https://docs.polygon.technology/pos/how-to/full-node/full-node-packages Example command to install a specific version of Heimdall for a validator node on Mainnet. ```shell # Example: # curl -L https://raw.githubusercontent.com/maticnetwork/install/heimdall-v2/heimdall-v2.sh | bash -s -- v0.2.15 mainnet validator ``` -------------------------------- ### Install Sequence Connect and Indexer packages Source: https://docs.polygon.technology/wallets/treasury-wallet Install the frontend and backend dependencies. The frontend uses @0xsequence/connect, wagmi, and viem for client session grants, while the backend uses @0xsequence/indexer for monitoring. ```bash # Frontend (client session grant) pnpm install @0xsequence/connect wagmi viem # Backend (monitoring) pnpm install @0xsequence/indexer ``` -------------------------------- ### Initialize a new dApp Launchpad project Source: https://docs.polygon.technology/tools/dApp-development/launchpad/quickstart Creates a new directory, scaffolds a minimal dApp project, and installs required packages. Replace with your project name. ```bash dapp-launchpad init ``` -------------------------------- ### Clean up sentry node setup Source: https://docs.polygon.technology/pos/how-to/validator/validator-ansible Runs the clean playbook to start over if an issue occurs during setup. ```sh ansible-playbook -l sentry playbooks/clean.yml ``` -------------------------------- ### Setup project and create wallet Source: https://docs.polygon.technology/payment-services/agentic-payments/cli/index Initializes the project and creates a smart wallet. The setup command writes the EOA and OMS access key to ~/.polygon-agent/builder.json. The wallet create command opens a browser approval flow and pairs a smart wallet using a six-digit code. ```bash polygon-agent setup --name "my-project" polygon-agent wallet create ``` -------------------------------- ### ABIManager Example: Set and Get ABI for ERC20PredicateProxy Source: https://docs.polygon.technology/tools/matic-js/advanced/abi-manager Concrete example using 'testnet' and 'amoy' as network and version. Sets and gets the ABI for 'ERC20PredicateProxy' with bridge type 'pos'. The 'abi value' is a placeholder. ```javascript import { ABIManager } from '@maticnetwork/maticjs' const manager = new ABIManager('testnet','amoy'); await manager.init(); // set abi manager.setABI('ERC20PredicateProxy','pos', 'abi value'); // get abi manager.getABI('ERC20PredicateProxy','pos'); ``` -------------------------------- ### GET /transactions example response Source: https://docs.polygon.technology/interoperability/agglayer/integrations/bridge-hub/api-reference Example JSON response for the /transactions endpoint, showing a transaction object and the nextStartAfterCursor for pagination. ```json { "data": [ { "hubUID": "tx-0001", "sourceNetwork": 1, "destinationNetwork": 2442, "transactionHash": "0xabc123...", "blockNumber": 19500000, "timestamp": 1710000000, "leafType": "ASSET", "originTokenNetwork": 1, "originTokenAddress": "0x0000000000000000000000000000000000000000", "receiverAddress": "0xdef456...", "fromAddress": "0x789abc...", "amount": "1000000000000000000", "depositCount": 42, "leafIndexForProof": 42, "globalIndex": "42", "status": "READY_TO_CLAIM", "lastUpdatedAt": 1710000300, "claimTransactionHash": null, "claimBlockNumber": null, "claimTimestamp": null } ], "nextStartAfterCursor": "eyJsYXN0SWQiOiJ0eC0wMDAxIn0=" } ``` -------------------------------- ### Install v2 packages for buyers and sellers Source: https://docs.polygon.technology/payment-services/agentic-payments/x402/guides/migration-v1-to-v2 Install commands for v2 packages. Buyers install @x402/fetch, @x402/core, @x402/evm, and viem. Sellers using Express install @x402/express, @x402/core, @x402/evm, and express. ```bash # Buyers npm install @x402/fetch @x402/core @x402/evm viem # Sellers (Express) npm install @x402/express @x402/core @x402/evm express ``` -------------------------------- ### Clean up validator node setup Source: https://docs.polygon.technology/pos/how-to/validator/validator-ansible Runs the Ansible playbook 'playbooks/clean.yml' to start over if an issue is encountered during the validator node setup. ```sh ansible-playbook -l validator playbooks/clean.yml ``` -------------------------------- ### Start the development environment Source: https://docs.polygon.technology/tools/dApp-development/launchpad/quickstart Starts the local test blockchain, deploys contracts, and lists pre-funded wallets. Open http://localhost:3000 in a browser. Changes to smart contract or frontend code update automatically. ```bash dapp-launchpad dev ``` -------------------------------- ### Monitor installation progress with screen Source: https://docs.polygon.technology/pos/how-to/full-node/full-node-gcp Use screen to watch the installation progress, especially when bootstrapping from a snapshot. Disconnect with Control+a d. ```bash # inside the connected session screen -dr ``` -------------------------------- ### JSON response structure for GET /bridges Source: https://docs.polygon.technology/interoperability/agglayer/integrations/aggkit-bridge-service/api-reference Example JSON response from the GET /bridges endpoint, showing the bridges array and pagination object. ```json { "bridges": [ { "tx_hash": "0x8d1b60d0eaab6f609955bdd371e8004f47349cc809ff1bee81dc9d37237a031c", "deposit_count": 42, "origin_network": 0, "destination_network": 1, "origin_address": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", "destination_address": "0x70997970C51812dc3A010C7d01b50e0d17dc79C8", "amount": "1000000000000000000", "block_timestamp": 1695563045, "ready_for_claim": true } ], "pagination": { "page": 1, "limit": 10, "total": 150 } } ``` -------------------------------- ### Deploy consumer instance with environment variables Source: https://docs.polygon.technology/interoperability/agglayer/integrations/bridge-hub/deployment Start a new consumer with the network's configuration using environment variables. Set NETWORK_ID, NETWORK, BRIDGE_CONTRACT_ADDRESS, BRIDGE_SERVICE_URL, and MONGODB_CONNECTION_URI, then run 'bun start'. ```bash NETWORK_ID=42161 \ NETWORK=mainnet \ BRIDGE_CONTRACT_ADDRESS=0x... \ BRIDGE_SERVICE_URL=https://aggkit-42161.example.com \ MONGODB_CONNECTION_URI=mongodb://... \ bun start ``` -------------------------------- ### GET /sync-status - Component Synchronization Status - curl request Source: https://docs.polygon.technology/interoperability/agglayer/integrations/aggkit-bridge-service/api-reference Example request to get the synchronization status of L1, L2, and bridge components. ```bash curl "http://localhost:5577/bridge/v1/sync-status" ``` -------------------------------- ### dapp-launchpad init command 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. The `-t, --template` option specifies the scaffold template (default: `"javascript"`). ```bash dapp-launchpad init [PROJECT-NAME] ``` -------------------------------- ### Initialize Matic.js with Web3ClientPlugin and use() Source: https://docs.polygon.technology/tools/matic-js/get-started Imports and installs the Web3ClientPlugin from @maticnetwork/maticjs-web3 using use(). This is the setup shown for coding with Matic.js after installing the relevant libraries. ```javascript import { use } from '@maticnetwork/maticjs' import { Web3ClientPlugin } from '@maticnetwork/maticjs-web3' // install web3 plugin use(Web3ClientPlugin) ``` -------------------------------- ### SDK Installation Source: https://docs.polygon.technology/cross-chain/api-reference/overview Install the @0xtrails/api SDK package and initialize the client with your base URL and access key. ```APIDOC ## SDK Installation ### Description Install the SDK package and initialize the client. ### Installation pnpm install @0xtrails/api ### Initialization import { TrailsApi } from "@0xtrails/api"; const trails = new TrailsApi({ baseUrl: "https://trails-api.sequence.app/rpc/Trails/", accessKey: process.env.TRAILS_ACCESS_KEY, }); ``` -------------------------------- ### OMSWallet.init(publishableKey:) Source: https://docs.polygon.technology/wallets/sdk/swift/api-reference Initializes the OMSWallet SDK with a publishable key. ```APIDOC ## OMSWallet.init(publishableKey:) ### Description Initializes the OMSWallet SDK with a publishable key. ### Method Initializer ### Signature public convenience init(publishableKey: String) throws ### Parameters - **publishableKey** (String) - Required - The publishable key for the SDK. ### Throws An error if initialization fails. ``` -------------------------------- ### View production deployment help Source: https://docs.polygon.technology/tools/dApp-development/launchpad/smart-contracts Displays all available options for the production deployment command. ```bash dapp-launchpad deploy -h ``` -------------------------------- ### GET /health-check - Example Response Source: https://docs.polygon.technology/interoperability/agglayer/integrations/bridge-hub/api-reference JSON response indicating the service is healthy. ```json { "status": "success", "data": { "status": "success", "message": "All services are working correctly" } } ``` -------------------------------- ### Copy smart contracts environment file Source: https://docs.polygon.technology/tools/dApp-development/launchpad/quickstart Copies the .env.example file to .env in the smart-contracts directory. Set PRIVATE_KEY_DEPLOYER to a private key from a wallet you control; other variables are optional. ```bash cd ../smart-contracts cp .env.example .env ``` -------------------------------- ### GET /transactions example request Source: https://docs.polygon.technology/interoperability/agglayer/integrations/bridge-hub/api-reference Example curl command to query bridge transactions with status filter and limit. Returns JSON with transaction data and pagination cursor. ```bash curl "https://bridge-hub.example.com/transactions?status=READY_TO_CLAIM&limit=2" ``` -------------------------------- ### Read API: Get ERC20 balance Source: https://docs.polygon.technology/tools/matic-js/api-architecture Read methods do not publish anything on the blockchain and do not consume gas. This example gets the balance of an ERC20 token for a user address. ```javascript const erc20 = posClient.erc20(''); const balance = await erc20.getBalance('') ``` -------------------------------- ### Copy Parameter File Template Source: https://docs.polygon.technology/chain-development/cdk/cdk-opgeth/devnet-deployment-guide Create the configuration file by copying the provided example template. ```bash cp ./tools/createSovereignGenesis/create-genesis-sovereign-params.json.example ./tools/createSovereignGenesis/create-genesis-sovereign-params.json ``` -------------------------------- ### GET /health-check - Example Request Source: https://docs.polygon.technology/interoperability/agglayer/integrations/bridge-hub/api-reference Curl command to check the service health status. ```bash curl "https://bridge-hub.example.com/health-check" ``` -------------------------------- ### Example Response for GET /claims Source: https://docs.polygon.technology/interoperability/agglayer/integrations/aggkit-bridge-service/api-reference The JSON response structure returned when querying claim transactions. ```json { "claims": [ { "tx_hash": "0xa9fa5418144f7c8c1b78cd0e5560d6550411667ef937b554636a613f933b3d9f", "global_index": "0x000000000000000000000000000000000000000000000000000000000000002a", "amount": "1000000000000000000", "block_timestamp": 1695563145, "bridge_tx_hash": "0x8d1b60d0eaab6f609955bdd371e8004f47349cc809ff1bee81dc9d37237a031c" } ] } ``` -------------------------------- ### Install dependencies for Fetch client Source: https://docs.polygon.technology/payment-services/agentic-payments/x402/guides/quickstart-buyers Install the necessary x402 v2 packages and viem for signing when using the Fetch API. ```bash bun install @x402/fetch @x402/core @x402/evm viem dotenv ``` -------------------------------- ### GET /token-mappings - Example Request Source: https://docs.polygon.technology/interoperability/agglayer/integrations/bridge-hub/api-reference Curl command to retrieve token address mappings between networks. ```bash curl "https://bridge-hub.example.com/token-mappings" ``` -------------------------------- ### Create an npm project Source: https://docs.polygon.technology/tools/dApp-development/common-tools/hardhat Initialize a new npm project in a dedicated directory. ```bash mkdir hardhat-test cd hardhat-test/ npm init ``` -------------------------------- ### Install V2 packages for buyers and sellers Source: https://docs.polygon.technology/payment-services/agentic-payments/x402/guides/migration-v1-to-v2 Use these commands to install the necessary V2 packages for both buyer and seller environments. ```bash npm install @x402/axios @x402/core @x402/evm # Sellers npm install @x402/express @x402/core @x402/evm ``` -------------------------------- ### GET /token-metadata - Example Request Source: https://docs.polygon.technology/interoperability/agglayer/integrations/bridge-hub/api-reference Curl command to retrieve token metadata including name, symbol, and decimals. ```bash curl "https://bridge-hub.example.com/token-metadata" ``` -------------------------------- ### Install the SDK Source: https://docs.polygon.technology/wallets/sdk/typescript/quickstart Install the @polygonlabs/oms-wallet package using pnpm. ```bash pnpm add @polygonlabs/oms-wallet ``` -------------------------------- ### x402-pay command examples Source: https://docs.polygon.technology/payment-services/agentic-payments/cli/x402-pay Shows two example invocations of polygon-agent x402-pay: a simple GET request and a POST request with method, body, and header flags. The command always settles USDC as part of the call; there is no --broadcast flag. ```bash polygon-agent x402-pay --url https://api.example.com/v1/lookups/company ``` ```bash polygon-agent x402-pay \ --url https://api.example.com/v1/inference \ --method POST \ --body '{"prompt":"hi"}' \ --header "X-Trace-Id:abc" ```