Optimistic Ethereum is a rollup scaling solution that allows users to submit transactions on the Ethereum network and get them executed faster for a much lower gas cost. From the perspectives of users and developers, this is a "parallel universe" called Layer 2, or L2, where users typically have the same addresses as they do on the Ethereum blockchain (also called Layer 1 or L1). There are gateways that allow messages and assets to be transferred between the universes.

The Optimism network API largely uses the same JSON-RPC specification as Ethereum and Infura supports all the necessary API methods for building a fully functional application on the Optimistic Ethereum network.

Why are transactions cheaper on Optimism?

On L1 Ethereum, thousands of nodes run your transaction to verify that the proposed block that includes it is valid. This process is expensive and has to be paid for. Unlike on L1 Ethereum, Optimistic roll ups provide faster and cheaper transactions because it allows users to perform most of their tasks off-chain in a "layer 2" protocol. On Optimistic Ethereum, the smart contract has only two tasks: deposits/withdrawals and verifying proofs of transactions on chain. This makes the process more efficient and a lot cheaper.

Why is this safe?

The great thing about decentralization is you can trust that transactions are executed correctly because there are thousands of computers executing them. Honest miners would reject such a transaction. With rollups, you don't have that level of redundancy.

The answer, in the case of optimistic rollups, is incentives. Every node in the network has to put up a stake before it can propose a new block with the execution results of a transaction. Every other node can check up on those results, and if it thinks they are incorrect, dispute them. The dispute is resolved on L1, so it is as trustworthy as anything else in Ethereum. Whichever node lies, either proposer or disputer, loses its stake and most of it goes to the other node involved.

Of course, the whole point is to avoid running transactions in L1. This system achieves that by making it pointless to cheat. Any proposer who attempts to cheat is going to be caught by the other nodes, lose its stake, and not get the invalid transaction result accepted as valid. A disputer can force a single transaction to go into L1 arbitration as a denial of service attack, but the stake is high enough that it wouldn't be worth doing.

How does Infura work with Optimism?

Infura exposes endpoints for Optimistic Ethereum (the production network) and Optimistic Kovan (the test network). You use them the same way you use any other network, by selecting them from the menu and using the specified endpoint.

There are a few small differences between building on Layer 1 Ethereum and Optimism:

1. You must use the JSON-RPC API as we do not support Websockets yet.
2. Search filters are not yet supported

How to Get Started on Optimism...

The main difference between Optimism and regular L1 Ethereum (other than the cost) is the access point URL.

| Network          | RPC URL |

… If you are using the Truffle development environment

Infura users can add the free Truffle Optimism add-on directly on their Infura dashboard. The Truffle Optimism box also contains the configuration definitions required to use Infura. Currently, you will need to manually add the gas costs of transactions when you use Truffle to run deployments or tests on Optimistic Kovan or the main Optimistic Ethereum network.

… If you are using Hardhat

To use Optimistic Ethereum or Kovan, edit hardhat.config.js's modules.export.networks to add these definitions:

"optimistic-kovan": {
    url: 'https://optimism-kovan.infura.io/v3/<Infura Project ID>',
    accounts: { mnemonic: <your account mnemonic goes here> },
    gasPrice: 15000000,
    ovm: true // This sets the network as using the ovm and ensure
                      // contract will be compiled against that.
"optimistic-ethereum": {
  url: 'https://optimism-mainnet.infura.io/v3/<Infura Project ID>',
  accounts: { mnemonic: <your account mnemonic goes here> },
  gasPrice: 15000000,
  ovm: true // This sets the network as using the ovm and ensure
                    // contract will be compiled against that.

Then you simply run:

npx hardhat --network optimistic-<kovan or ethereum> <command>

… If you are using Remix

When you use the Remix Optimism plugin to develop for Optimism, network connections are created through the wallet. If you use MetaMask, you can select the network Custom RPC and fill in the details: