How to Integrate with the Polygon Blockchain with Magic

How to Integrate with the Polygon Blockchain with Magic

Installation

Via Magic SDK, you can interact with Polygon. Polygon (formerly Matic) is EVM compatible so you can directly follow the Ethereum installation.

Configure Polygon

Polygon - Mainnet

Mainnet Block Explorer URL: https://explorer-mainnet.maticvigil.com/

const polygonOptions = { rpcUrl: 'https://rpc-mainnet.maticvigil.com/', // Polygon RPC URL chainId: 137, // Polygon chain id } // Setting network to Polygon const magic = new Magic('YOUR_PUBLISHABLE_LIVE_API_KEY', { network: polygonOptions });

Polygon - Testnet

Testnet Block Explorer URL: https://explorer-mumbai.maticvigil.com/

const polygonOptions = { rpcUrl: 'https://rpc-mumbai.matic.today/', // Polygon RPC URL chainId: 80001, // Polygon chain id } // Setting network to Smart Chain - Testnet const magic = new Magic('YOUR_PUBLISHABLE_TEST_API_KEY', { network: polygonOptions });

How to Integrate with the Polygon Blockchain with Magic