You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: pages/builders/app-developers/bridging/basics.mdx
+5-5
Original file line number
Diff line number
Diff line change
@@ -1,29 +1,29 @@
1
1
---
2
-
title: Bridging Basics
2
+
title: Bridging basics
3
3
lang: en-US
4
4
description: Learn about the fundamentals of sending data and tokens between Ethereum and OP Mainnet.
5
5
---
6
6
7
-
# Bridging Basics
7
+
# Bridging basics
8
8
9
9
OP Mainnet is a "Layer 2" system and is fundamentally connected to Ethereum.
10
10
However, OP Mainnet is also a distinct blockchain with its own blocks and transactions.
11
11
App developers commonly need to move data and tokens between OP Mainnet and Ethereum.
12
12
This process of moving data and tokens between the two networks is called "bridging".
13
13
14
-
## Sending Tokens
14
+
## Sending tokens
15
15
16
16
One of the most common use cases for bridging is the need to send ETH or ERC-20 tokens between OP Mainnet and Ethereum.
17
17
OP Mainnet has a system called the [Standard Bridge](./standard-bridge) that makes it easy to move tokens in both directions.
18
18
If you mostly need to bridge tokens, make sure to check out the [Standard Bridge](./standard-bridge) guide.
19
19
20
-
## Sending Data
20
+
## Sending data
21
21
22
22
Under the hood, the Standard Bridge is just an application that uses the OP Mainnet [message passing system to send arbitrary data between Ethereum and OP Mainnet](./messaging).
23
23
Applications can use this system to have a contract on Ethereum interact with a contract on OP Mainnet, and vice versa.
24
24
All of this is easily accessible with a simple, clean API.
25
25
26
-
## Next Steps
26
+
## Next steps
27
27
28
28
Ready to start bridging?
29
29
Check out these tutorials to get up to speed fast.
Copy file name to clipboardExpand all lines: pages/builders/app-developers/bridging/custom-bridge.mdx
+3-3
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,12 @@
1
1
---
2
-
title: Custom Bridges
2
+
title: Custom bridges
3
3
lang: en-US
4
4
description: Important considerations when building custom bridges for OP Mainnet.
5
5
---
6
6
7
7
import { Callout } from'nextra/components'
8
8
9
-
# Custom Bridges
9
+
# Custom bridges
10
10
11
11
Custom token bridges are any bridges other than the [Standard Bridge](./standard-bridge).
12
12
You may find yourself in a position where you need to build a custom token bridge because the Standard Bridge doesn't completely support your use case.
@@ -35,7 +35,7 @@ The [Superchain Token List](/chain/tokenlist) exists to help users and developer
35
35
Once you've built and tested your custom bridge, make sure to register any tokens meant to flow through this bridge by [making a pull request against the Superchain Token List repository](https://github.com/ethereum-optimism/ethereum-optimism.github.io#adding-a-token-to-the-list).
36
36
You **must** deploy your bridge to OP Sepolia before it can be added to the Superchain Token List.
37
37
38
-
## Next Steps
38
+
## Next steps
39
39
40
40
You can explore several examples of custom bridges for OP Mainnet:
Copy file name to clipboardExpand all lines: pages/builders/app-developers/bridging/messaging.mdx
+11-11
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,12 @@
1
1
---
2
-
title: Sending Data Between L1 and L2
2
+
title: Sending data between L1 and L2
3
3
lang: en-US
4
4
description: Learn how bridging works between L1 and L2, how to use it, and what to watch out for.
5
5
---
6
6
7
7
import { Callout } from'nextra/components'
8
8
9
-
# Sending Data Between L1 and L2
9
+
# Sending data between L1 and L2
10
10
11
11
Smart contracts on L1 (Ethereum) can interact with smart contracts on L2 (OP Mainnet) through a process called "bridging".
12
12
This page explains how bridging works, how to use it, and what to watch out for.
@@ -16,7 +16,7 @@ This page explains how bridging works, how to use it, and what to watch out for.
16
16
For a step-by-step tutorial on how to send data between L1 and L2, check out the [Solidity tutorial](/builders/app-developers/tutorials/cross-dom-solidity).
17
17
</Callout>
18
18
19
-
## Understanding Contract Calls
19
+
## Understanding contract calls
20
20
21
21
It can be easier to understand bridging if you first have a basic understanding of how contracts on EVM-based blockchains like OP Mainnet and Ethereum communicate within the *same* network.
22
22
The interface for sending messages *between* Ethereum and OP Mainnet is designed to mimic the standard contract communication interface as much as possible.
@@ -57,7 +57,7 @@ Here you're using the [low-level "call" function](https://docs.soliditylang.org/
57
57
Although these two code snippets look a bit different, they're doing the exact same thing.
58
58
Because of limitations of Solidity, **the OP Stack's bridging interface is designed to look like the second code snippet**.
59
59
60
-
## Basics of Communication Between Layers
60
+
## Basics of communication between layers
61
61
62
62
At a high level, the process for sending data between L1 and L2 is pretty similar to the process for sending data between two contracts on Ethereum (with a few caveats).
63
63
Communication between L1 and L2 is made possible by a pair of special smart contracts called the "messenger" contracts.
@@ -121,17 +121,17 @@ contract MyContract {
121
121
You can find the addresses of the `L1CrossDomainMessenger` and the `L2CrossDomainMessenger` contracts on OP Mainnet and OP Sepolia on the [Contract Addresses](/chain/addresses) page.
122
122
</Callout>
123
123
124
-
## Communication Speed
124
+
## Communication speed
125
125
126
126
Unlike calls between contracts on the same blockchain, calls between Ethereum and OP Mainnet are *not* instantaneous.
127
127
The speed of a cross-chain transaction depends on the direction in which the transaction is sent.
128
128
129
-
### For L1 to L2 Transactions
129
+
### For L1 to L2 transactions
130
130
131
131
Transactions sent from L1 to L2 take **approximately 1-3 minutes** to get from Ethereum to OP Mainnet, or from Sepolia to OP Sepolia.
132
132
This is because the Sequencer waits for a certain number of L1 blocks to be created before including L1 to L2 transactions to avoid potentially annoying [reorgs](https://www.alchemy.com/overviews/what-is-a-reorg).
133
133
134
-
### For L2 to L1 Transactions
134
+
### For L2 to L1 transactions
135
135
136
136
Transactions sent from L2 to L1 take **approximately 7 days** to get from OP Mainnet to Ethereum, or from OP Sepolia to Sepolia.
137
137
This is because the bridge contract on L1 must wait for the L2 state to be *proven* to the L1 chain before it can relay the message.
@@ -177,9 +177,9 @@ modifier onlyOwner() {
177
177
}
178
178
```
179
179
180
-
## Fees For Sending Data Between L1 and L2
180
+
## Fees for sending data between L1 and L2
181
181
182
-
### For L1 to L2 Transactions
182
+
### For L1 to L2 transactions
183
183
184
184
The majority of the cost of an L1 to L2 transaction comes from the smart contract execution on L1.
185
185
When sending an L1 to L2 transaction, you send to the [`L1CrossDomainMessenger`](https://github.com/ethereum-optimism/optimism/blob/111f3f3a3a2881899662e53e0f1b2f845b188a38/packages/contracts-bedrock/src/L1/L1CrossDomainMessenger.sol) contract, which then sends a call to the [`OptimismPortal`](https://github.com/ethereum-optimism/optimism/blob/111f3f3a3a2881899662e53e0f1b2f845b188a38/packages/contracts-bedrock/src/L1/OptimismPortal.sol) contract.
@@ -195,7 +195,7 @@ The amount of L1 gas charged increases when more people are sending L1 to L2 tra
195
195
You should always add a buffer of at least 20% to the gas limit for your L1 to L2 transaction to avoid running out of gas.
196
196
</Callout>
197
197
198
-
### For L2 to L1 Transactions
198
+
### For L2 to L1 transactions
199
199
200
200
Each message from L2 to L1 requires three transactions:
201
201
@@ -211,7 +211,7 @@ Each message from L2 to L1 requires three transactions:
211
211
The total cost of an L2 to L1 transaction is therefore the combined cost of the L2 initialization transaction and the two L1 transactions.
212
212
The L1 proof and finalization transactions are typically significantly more expensive than the L2 initialization transaction.
213
213
214
-
## Understanding the Challenge Period
214
+
## Understanding the challenge period
215
215
216
216
One of the most important things to understand about L1 ⇔ L2 interaction is that **mainnet messages sent from Layer 2 to Layer 1 cannot be relayed for at least 7 days**.
217
217
This means that any messages you send from Layer 2 will only be received on Layer 1 after this one week period has elapsed.
Copy file name to clipboardExpand all lines: pages/builders/app-developers/contracts/compatibility.mdx
+4-4
Original file line number
Diff line number
Diff line change
@@ -1,21 +1,21 @@
1
1
---
2
-
title: Solidity Compatibility
2
+
title: Solidity compatibility
3
3
lang: en-US
4
4
description: Learn about the differences between OP Mainnet and Ethereum when building Solidity contracts.
5
5
---
6
6
7
-
# Solidity Compatibility
7
+
# Solidity compatibility
8
8
9
9
OP Mainnet is designed to be [EVM equivalent](https://web.archive.org/web/20231127160757/https://medium.com/ethereum-optimism/introducing-evm-equivalence-5c2021deb306), which means OP Mainnet looks exactly like Ethereum in every way possible.
10
10
Almost all Ethereum tooling works out of the box on OP Mainnet, including the [Solidity](https://soliditylang.org/) smart contract language.
11
11
However, there are a few minor differences between OP Mainnet and Ethereum that you should be aware of when building Solidity contracts.
12
12
13
-
## EVM/Opcode Differences
13
+
## EVM/Opcode differences
14
14
15
15
Most smart contracts will work on OP Mainnet without any changes.
16
16
Check out the [Differences Between Ethereum and OP Mainnet](/chain/differences#opcodes) page for a detailed list of the few differences you should know about.
17
17
18
-
## Gas Differences
18
+
## Gas differences
19
19
20
20
OP Mainnet uses the same gas costs as Ethereum.
21
21
However, OP Mainnet also charges an [L1 Data Fee](/stack/transactions/fees#l1-data-fee) for the cost of publishing an L2 transaction to L1.
Copy file name to clipboardExpand all lines: pages/builders/app-developers/contracts/optimization.mdx
+6-6
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,12 @@
1
1
---
2
-
title: Contract Optimization on OP Mainnet
2
+
title: Contract optimization on OP Mainnet
3
3
lang: en-US
4
4
description: Learn how to optimize contracts for OP Mainnet and what to look out for when you do so.
5
5
---
6
6
7
7
import { Callout } from'nextra/components'
8
8
9
-
# Contract Optimization on OP Mainnet
9
+
# Contract optimization on OP Mainnet
10
10
11
11
OP Mainnet is designed to be [EVM equivalent](https://web.archive.org/web/20231127160757/https://medium.com/ethereum-optimism/introducing-evm-equivalence-5c2021deb306), which means OP Mainnet looks exactly like Ethereum in every way possible.
12
12
One large and mostly unavoidable discrepancy between OP Mainnet and Ethereum is a slight [difference in transaction fee models](/stack/transactions/fees).
@@ -36,12 +36,12 @@ This is the basic premise that makes OP Mainnet contract optimization slightly d
36
36
37
37
## Considerations
38
38
39
-
### Additional Complexity
39
+
### Additional complexity
40
40
41
41
Contract optimizations can create additional complexity, which can in turn create additional risk.
42
42
Developers should always consider whether this added complexity is worth the reduction in cost.
43
43
44
-
### Changing Economics
44
+
### Changing economics
45
45
46
46
Various potential upgrades to OP Mainnet may also make optimizations to the L1 Data Fee less relevant.
47
47
For instance, [EIP-4844](https://www.eip4844.com/), if adopted, should significantly reduce the cost of publishing data to Ethereum and would therefore also decrease the L1 Data Fee.
@@ -57,7 +57,7 @@ If you expect your contracts to be used mostly in the short term or you have the
57
57
58
58
## Techniques
59
59
60
-
### Calldata Compression
60
+
### Calldata compression
61
61
62
62
Compressing user data on the client side and decompressing it on the contract side can be an effective way to decrease costs on OP Mainnet.
63
63
This technique decreases the amount of data provided by the user in exchange for a significant increase in onchain computation.
@@ -66,7 +66,7 @@ Although several libraries exist to perform this calldata compression, none of t
66
66
As a result, links to these libraries have been explicitly omitted here to avoid encouraging developers from using potentially buggy software.
67
67
Most of these libraries can be found with a quick search online but, as always, be careful with code you find on the internet.
68
68
69
-
### Custom Encoding
69
+
### Custom encoding
70
70
71
71
The [Solidity ABI encoding scheme](https://docs.soliditylang.org/en/v0.8.23/abi-spec.html#argument-encoding) is not particularly data efficient.
72
72
Contracts can often reduce the amount of calldata provided by defining a custom argument encoding protocol.
Copy file name to clipboardExpand all lines: pages/builders/app-developers/contracts/system-contracts.mdx
+9-9
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,12 @@
1
1
---
2
-
title: Using OP Mainnet System Contracts
2
+
title: Using OP Mainnet system contracts
3
3
lang: en-US
4
4
description: Learn how to work with OP Mainnet contracts directly from other contracts and how to work with contracts from the client side.
5
5
---
6
6
7
7
import { Steps } from'nextra/components'
8
8
9
-
# Using OP Mainnet System Contracts
9
+
# Using OP Mainnet system contracts
10
10
11
11
System contracts on Ethereum (L1) and OP Mainnet (L2) are an important part of the OP Mainnet ecosystem.
12
12
You may want to interact with these system contracts for any number of reasons, including:
@@ -18,15 +18,15 @@ You may want to interact with these system contracts for any number of reasons,
18
18
19
19
In this tutorial, you'll learn how to work with OP Mainnet contracts directly from other contracts and how to work with them from the client side.
20
20
21
-
## Before You Begin
21
+
## Before you begin
22
22
23
23
You'll need to find the address of the particular contract that you want to interact with before you can actually interact with it.
24
24
25
25
* Check out the [Networks and Connection Details page](/chain/networks) for links to public RPC endpoints and contract addresses.
26
26
* Find the addresses for all networks on the [Contract Addresses](/chain/addresses) page.
27
27
* Use the JSON file including contract addresses for all Superchain networks in the [Superchain Registry](https://github.com/ethereum-optimism/superchain-registry/blob/main/superchain/extra/addresses/addresses.json).
28
28
29
-
## Using System Contracts in Solidity
29
+
## Using system contracts in Solidity
30
30
31
31
All you need to interact with the OP Mainnet system contracts from another contract is an address and an interface.
32
32
You can follow [the instructions above](#finding-contract-addresses) to find the address of the contract you want to interact with.
@@ -42,7 +42,7 @@ Install the package as follows:
42
42
npm install @eth-optimism/contracts-bedrock
43
43
```
44
44
45
-
### Importing Contracts
45
+
### Importing contracts
46
46
47
47
Simply import the desired contract or interface from the `@eth-optimism/contracts-bedrock` package:
48
48
@@ -57,14 +57,14 @@ For example, if you wanted to import the [`L1CrossDomainMessenger`](https://gith
57
57
import { L1CrossDomainMessenger } from "@eth-optimism/contracts/L1/messaging/L1CrossDomainMessenger.sol";
58
58
```
59
59
60
-
### Getting L2 Contract Addresses
60
+
### Getting L2 contract addresses
61
61
62
62
System contracts on L2 are "pre-deployed" to special addresses that are the same on most OP Stack chains.
63
63
You can find these addresses on the [Contract Addresses](/chain/addresses) page.
64
64
These addresses are also provided as constants in the [`Predeploys`](https://github.com/ethereum-optimism/optimism/blob/v1.1.4/packages/contracts-bedrock/src/libraries/Predeploys.sol) contract for use in Solidity.
65
65
</Steps>
66
66
67
-
## Using System Contracts in JavaScript
67
+
## Using system contracts in JavaScript
68
68
69
69
You can also interact with the OP Mainnet system contracts from the client side.
70
70
<Steps>
@@ -77,7 +77,7 @@ Install the package as follows:
77
77
npm install @eth-optimism/contracts-ts
78
78
```
79
79
80
-
### Getting Contract Artifacts and Interfaces
80
+
### Getting contract artifacts and interfaces
81
81
82
82
You can use the `@eth-optimism/contracts-ts` package to easily access the address or ABI of any OP Mainnet contract.
You can then feed this address and ABI into your favorite web3 library to interact with the contract.
97
97
98
98
`@eth-optimism/contracts-ts` also exports [React hooks](https://wagmi.sh/cli/api/plugins/react) and [wagmi actions](https://wagmi.sh/react/api/actions) for interacting with OP Mainnet contracts.
Copy file name to clipboardExpand all lines: pages/builders/app-developers/overview.mdx
+5-5
Original file line number
Diff line number
Diff line change
@@ -1,17 +1,17 @@
1
1
---
2
-
title: App Developer Overview
2
+
title: App developer overview
3
3
lang: en-US
4
4
description: Learn about deploying contracts, cross-chain messaging, and tutorials to help you build applications on OP Mainnet.
5
5
---
6
6
7
7
import { Cards, Card } from'nextra/components'
8
8
9
-
# App Developer Overview
9
+
# App developer overview
10
10
11
11
If you're a developer looking to build on OP Mainnet, you've come to the right place.
12
12
In this area of the Optimism Docs you'll find everything you need to know about building OP Mainnet applications.
13
13
14
-
## Getting Started
14
+
## Getting started
15
15
16
16
If you're brand new to OP Mainnet, try starting with the guide on [deploying a basic contract](/chain/getting-started).
17
17
It'll get you familiar with the basic steps required to get a contract deployed to the network.
@@ -28,7 +28,7 @@ You might also want to check out the [testing on OP Networks guide](/chain/testi
28
28
<Cardtitle="Testing Apps on OP Mainnet"href="/chain/testing/testing-apps"icon={<imgsrc="/img/icons/shapes.svg" />} />
29
29
</Cards>
30
30
31
-
## Bridging and Messaging
31
+
## Bridging and messaging
32
32
33
33
Looking to build an application that sends ETH, tokens, or data between OP Mainnet and Ethereum?
34
34
You'll find some useful guides and tutorials in this area of the docs.
@@ -65,7 +65,7 @@ They'll help you get a head start when building your first Optimistic project.
65
65
66
66
You can also [suggest a new tutorial](https://github.com/ethereum-optimism/docs/issues/new?assignees=\&labels=tutorial%2Cdocumentation%2Ccommunity-request\&projects=\&template=suggest_tutorial.yaml\&title=%5BTUTORIAL%5D+Add+PR+title) if you have something specific in mind. We'd love to grow this list!
67
67
68
-
## Next Steps
68
+
## Next steps
69
69
70
70
If you still can't find the content you're looking for, there's a few options to get extra help.
0 commit comments