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://polygonscan.com/
01const customNodeOptions = {
02 rpcUrl: 'https://polygon-rpc.com/', // Polygon RPC URL
03 chainId: 137, // Polygon chain id
04}
05
06// Setting network to Polygon
07const magic = new Magic('YOUR_PUBLISHABLE_API_KEY', { network: customNodeOptions });
#Testnet
Testnet Block Explorer URL: https://mumbai.polygonscan.com/
01const customNodeOptions = {
02 rpcUrl: 'https://rpc-mumbai.maticvigil.com/', // Polygon RPC URL
03 chainId: 80001, // Polygon chain id
04}
05
06// Setting network to Polygon - Testnet
07const magic = new Magic('YOUR_PUBLISHABLE_API_KEY', { network: customNodeOptions });