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

#Mainnet

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

const customNodeOptions = {
  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: customNodeOptions });

#Testnet

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

const customNodeOptions = {
  rpcUrl: 'https://rpc-mumbai.matic.today/', // Polygon RPC URL
  chainId: 80001, // Polygon chain id
}

// Setting network to Polygon - Testnet
const magic = new Magic('YOUR_PUBLISHABLE_TEST_API_KEY', { network: customNodeOptions });
How to Integrate with the Polygon Blockchain with Magic