How to connect to Optimism L2 with Magic

How to connect to Optimism L2 with Magic

Resources

Demo

Guide

Installation

Via Magic SDK, you can connect to Optimism. Optimism is EVM compatible so you can directly follow the Ethereum installation.

Configure Optimism

Mainnet

Mainnet Block Explorer: https://optimistic.etherscan.io

const customNodeOptions = { rpcUrl: 'https://mainnet.optimism.io', chainId: 10, } // Setting network to Optimism const magic = new Magic('YOUR_PUBLISHABLE_LIVE_API_KEY', { network: customNodeOptions });

Testnet

Testnet Block Explorer: https://kovan-optimistic.etherscan.io

const customNodeOptions = { rpcUrl: 'https://kovan.optimism.io', chainId: 69 } // Setting network to Optimism const magic = new Magic('YOUR_PUBLISHABLE_TEST_API_KEY', { network: customNodeOptions });

How to connect to Optimism L2 with Magic