Optimism API FAQ

The Optimism API follows the same JSON-RPC standard as Ethereum. Find methods that Alchemy supports for Optimism development (smart contracts & decentralized applications) on mainnet & testnets below.

What is Optimism?

Optimism is a layer 2 (L2) scaling solution for Ethereum. As an L2 solution Optimism operates on top of Ethereum’s mainnnet and because of this can utilize Ethereum’s strong security and support Ethereum dApps. All transactions that occur on Optimism are eventually posted and validated on the mainnet of Ethereum using Optimistic Rollups.

Founded by Jinglan Wang, Karl Floersch, and Kevin Ho in 2019, Optimism continues to grow as an L2 solution that offers higher throughput and reduced expenses compared to Ethereum.

How can I get started using the Optimism API?

It's simple! If you're using JavaScript and Node.js, simply install the Alchemy SDK, create an Alchemy object, and you'll be ready to start making Optimism node requests (for instance, getting the latest block) in a couple of lines of code.

After setting up a node project using npm init -y, install the SDK by running the following command in your shell:

npm install alchemy-sdk
yarn add alchemy-sdk

After installing the package, you can then import and use the SDK:

import { Network, Alchemy } from 'alchemy-sdk';

// Optional Config object, but defaults to demo api-key and eth-mainnet.
const settings = {
  apiKey: 'demo', // Replace with your Alchemy API Key.
  network: Network.OPT_MAINNET, // Replace with your network.
const alchemy = new Alchemy(settings);

// Access standard Ethers.js JSON-RPC node request

What type of Layer 2 solution is Optimism?

As a Layer 2 solution, Optimism is an Optimistic Rollup network. Optimistic rollups (ORUs) run parallel to the Ethereum Mainnet. ORUs bundle multiple transactions into one transaction and send them back to the Ethereum Chain. Optimistic rollups assume all transactions are valid unless challenged by a fraud-proof, which makes the chain extremely scalable.

Is Optimism EVM-compatible?

Yes! Optimism is fully compatible with all Solidity smart contracts and Ethereum libraries. As Optimism acts as a second layer operating on top of the main Ethereum network, it can utilize the Ethereum Virtual Machine just like Ethereum.

What is the Optimistic Virtual Machine (OVM)?

The Optimistic Virtual Machine (OVM) is an EVM-compatible virtual machine that executes transactions “optimistically,” which means it relies on the L1 chain to arbitrate disputes concerning the correctness of state transitions using fraud proofs.

How do I add Optimism to MetaMask Mainnet?

Adding Optimism to the Metamask takes four steps:

  1. Create a free Alchemy account
  2. Create an API key
  3. Choose custom RPC in Metamask
  4. Fill in the Optimism network details

What testnet should I use for Optimism?

Optimism’s main testnet is Goerli. Because Kovan is deprecated, it is recommended that all Optimism applications migrate from Kovan to the Opt-Goerli testnet.

How do I build an app on Optimism?

To start building a dApp on Optimism, sign up for Alchemy and log in. Then click the “Apps” tab and “Create App”, and you’re ready to build your new app on the Optimism mainnet!

How do you bridge Optimism to Ethereum?

You can find a number of bridges to use on the Optimism site. To use one of these bridges, connect your Metamask wallet to send and receive tokens between Optimism and Ethereum. Cross-chain bridges are instrumental components of the multi-chain future of blockchain.

What wallets can be used on Optimism?

Many Web3 wallets can be used on Optimism. As Optimism continues to grow, it supports many of the most popular wallets. Some wallets that people choose to use on Optimism include Metamask, Ledger Nano X, and SafePal S1.

What does Optimism use for gas?

Optimism uses ETH tokens for gas, and because Optimism transactions are bundled using Optimistic Rollups, the gas costs to complete the transaction on the Optimism network are usually cheaper than native transactions on Ethereum.

What projects are on Optimism?

Some of the most popular dApps on Optimism include Perpetual, Lyra, Synthetix, and Synapse.

Perpetual is a DeFi dApp that allows users to exchange perpetual contracts. Lyra, one of the first Dapps built natively on Optimism, is a crypto options exchange. Synthetix is a DeFi protocol built for trading derivatives trading, and Synapse is a cross-chain protocol for swapping assets between blockchains.

How do you withdraw ETH from Optimism?

Withdrawing ETH from Optimism takes three easy steps: go to The Optimism Gateway, enter the amount you would like to remove from the network, and click “Withdraw”. Because Optimism uses fraud poofs, it takes 7 days for withdraws to Ethereum to be completed.

What API does Optimism use?

Optimism uses the JSON-RPC API standard. The Optimism JSON-RPC API serves as the backbone for the Optimism network and powers any blockchain interaction.

In aggregate, this API suite allows users to read block/transaction data, query chain information, execute smart contracts, and store data on-chain. Developer interacts with Optimism’s base JSON-RPC APIs to communicate with its decentralized network of nodes.

What is an Optimism API key?

When accessing the Optimism network via a node provider, API providers like Alchemy require developers to use an API key to query the blockchain.

For the best development experience, we recommend that you sign up for a free API key! With a dedicated API key, developers can:

  • access higher request throughput and increased concurrent requests
  • query enhanced APIs, gaining access to free archive data, logs, and API abstractions
  • Leverage individualized usage metrics

Which libraries support Optimism?

Three libraries support Optimism, including Alchemy-web3, Web3.js, and Ethers. Of these three, Alchemy is an improvement over Web3 and Ethers libraries, providing enhanced API calls, upgraded WebSockets, and many other benefits.

What programming languages work with Optimism?

Many programming languages work with Optimism including Go, Javascript, Solidity, Typescript, and Shell. Javascript and Solidity are some of the best languages to use, Solidity for smart contracts and Javascript for off-chain requests.

Before you get started, update your Optimism RPC URL to Alchemy.

Types of Requests in the Optimism API

Getting Blocks

Retrieves information from a particular block in the blockchain.

Reading Transactions

Retrieves information on the state data for addresses regardless of whether it is a user or a smart contract.

Writing Transactions

Allows developers to both send ETH from one address to another, write data on-chain, and interact with smart contracts.

Account Information

Returns information regarding an address's stored on-chain data.

EVM/Smart Contract Execution

Allows developers to read data from the blockchain which includes executing smart contracts. However, no data is published to the Optimism network.

Event Logs

Returns logs which are records that denote/provide context on specific events within a smart contract, like a token transfer or a change of ownership for example.

Chain Information

Returns information on the Optimism network and internal settings.

Getting Uncles

Returns information on uncle blocks which are network rejected blocks and replaced by a canonical block instead.


Returns Optimism network configuration information.

Real-time Events

Introduces WebSocket-based requests/responses which leverage a network connection allowing developers to listen for changes continuously without the need for HTTP polling.

My question isn't here, where can I get help?

Don't worry, we got you. Check out our feel free to post in discord with any questions you have!