Optimism 백서

Optimism

원문

bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 75쪽 중 1쪽

# Use the Docs with AI Source: https://docs.optimism.io/ai-docs Read the Optimism docs as an agent with llms.txt and per-page markdown, connect the hosted MCP server, and start from curated prompts. These docs are built to be read by AI assistants and agents, not just browsers. Every page is available as plain markdown, the whole site publishes a machine-readable index, and a hosted MCP server exposes search over the content. This page covers the three ways to put them to work: [reading the docs as an agent](#read-the-docs-as-an-agent), [connecting the hosted MCP server](#connect-the-hosted-mcp-server), and [starting from curated prompts](#prompt-starters). ## Read the Docs as an Agent ### The Documentation Index: llms.txt The site publishes an [llms.txt](https://llmstxt.org/) index at: ```text theme={null} https://docs.optimism.io/llms.txt ``` It is a plain-markdown listing of the site's pages with their URLs. Point an assistant at it to discover what exists before fetching individual pages. This is the recommended entry point for any agent working with these docs. ### Per-Page Markdown Every page is served as raw markdown at its own URL with `.md` appended. For example, the [Node Operator Overview](/node-operators/overview) page is available as: ```text theme={null} https://docs.optimism.io/node-operators/overview.md ``` Fetching the `.md` form skips the HTML shell, navigation, and scripts, so an assistant gets exactly the content of the page in a fraction of the tokens. Prefer it over the HTML URL whenever your tooling fetches pages programmatically. ### The Contextual Menu Every page in these docs has a contextual menu (next to the page title) with assistant-ready actions: * **Copy page**: copies the page as markdown, ready to paste into any chat. * **Open in ChatGPT**: opens a ChatGPT conversation preloaded with the page. * **Open in Claude**: opens a Claude conversation preloaded with the page. * **Copy MCP server URL**: copies the [hosted MCP server](#connect-the-hosted-mcp-server) address for your client configuration. Use it when you are reading a page and want to hand it to an assistant without constructing URLs by hand. ### Tips for Agents Reading These Docs * Start from `llms.txt` to map the site, then fetch only the `.md` pages you need. * These docs describe how to *use* the OP Stack. The normative protocol definition lives in the [OP Stack specifications](https://specs.optimism.io) - when a docs page and the specs disagree, the specs win. * Configuration flags and versions change between releases. Confirm load-bearing values against the linked source or release notes before acting on them. ## Connect the Hosted MCP Server The [Model Context Protocol (MCP)](https://modelcontextprotocol.io) is an open standard for connecting AI assistants to external tools and data sources. These docs are hosted on Mintlify, which [automatically generates and hosts an MCP server](https://www.mintlify.com/docs/ai/model-context-protocol) for the site. The server exposes a search tool over the documentation, so a connected assistant (Claude Code, Claude Desktop, Cursor, and others) can look up current OP Stack content instead of relying on stale training data. ### Option 1: The Hosted MCP Server (Recommended) The docs MCP server is available over HTTP at: ```text theme={null} https://docs.optimism.io/mcp ``` <Steps> <Step title="Add the server to your client"> For Claude Code, run: ```bash theme={null} claude mcp add --transport http optimism-docs https://docs.optimism.io/mcp ``` For Cursor, Claude Desktop, and other clients that use a JSON configuration, add the server URL: ```json theme={null} { "mcpServers": { "optimism-docs": { "url": "https://docs.optimism.io/mcp" } } } ``` You can also connect from any page of these docs: the contextual menu (next to the page title) includes an option to copy the MCP server details for your client. </Step> <Step title="Verify it works"> Ask your assistant: ```text theme={null} Using the optimism-docs MCP server, find the page about running a node from source and summarize its hardware requirements. ``` A correctly wired assistant calls the server's search tool, locates [Building and Running an OP Stack Node From Source](/node-operators/tutorials/run-node-from-source), and answers from the live page. </Step> </Steps> ### Option 2: Direct Fetching (No MCP Server Required) If your assistant can fetch web pages but does not support MCP, no setup is needed. The site's [machine-readable surfaces](#read-the-docs-as-an-agent) - the `llms.txt` index and per-page markdown - work with any assistant that can fetch URLs. Give it the index and the URL convention: ```text theme={null} The Optimism docs publish a machine-readable index at https://docs.optimism.io/llms.txt. Any page is available as raw markdown by appending .md to its URL. Use the index to find relevant pages, then fetch their .md versions. ``` Add that to your assistant's project instructions (for example `CLAUDE.md`, `.cursorrules`, or a system prompt) and it will resolve OP Stack questions against the live docs. If your tooling only reaches the network through MCP and cannot use the hosted server, the reference [fetch server](https://github.com/modelcontextprotocol/servers/tree/main/src/fetch) (`uvx mcp-server-fetch`) plus the instruction block above achieves the same result. If the hosted MCP endpoint is not responding, [open an issue](https://github.com/ethereum-optimism/optimism/issues) so we can investigate. ## Prompt Starters Copy-paste prompts for common OP Stack tasks, ready for any AI assistant that can fetch URLs. Each prompt names its intended persona, grounds the assistant in specific docs pages (fetched as [per-page markdown](#per-page-markdown)), and tells it what to produce. Replace the bracketed placeholders with your own details before sending. If your assistant cannot fetch URLs, open the linked pages and use the contextual menu's **Copy page** action to paste them in instead. ### Audit My Batcher Configuration for Cost **Persona:** chain operator Data availability is usually a chain's largest onchain operating cost, and the batcher configuration controls it. Grounding pages: [Configure the Batcher](/chain-operators/guides/configuration/batcher) and [Transaction Fees 101](/chain-operators/guides/management/transaction-fees-101). ```text theme={null} Read https://docs.optimism.io/chain-operators/guides/configuration/batcher.md and https://docs.optimism.io/chain-operators/guides/management/transaction-fees-101.md Here is my current op-batcher configuration: [paste your flags or env vars]. My chain posts roughly [N] transactions per day and targets [blobs / calldata]. Audit the configuration for data-availability cost: identify settings that increase posting cost, explain the trade-off each one controls (cost vs. latency vs. safety), and propose a revised configuration with reasoning. Flag any flag you are not sure still exists so I can check it against op-batcher --help for my release. ``` ### Walk Me Through the Deposit Flow **Persona:** app developer Understand what actually happens between an L1 deposit call and the transaction appearing on L2 before you build on it. Grounding pages: [Deposit Flow](/op-stack/bridging/deposit-flow) and [Deposit Transactions](/app-developers/tutorials/bridging/deposit-transactions). ```text theme={null} Read https://docs.optimism.io/op-stack/bridging/deposit-flow.md and https://docs.optimism.io/app-developers/tutorials/bridging/deposit-transactions.md Walk me through the full lifecycle of a deposit from L1 to L2: which contract I call, what events are emitted, how the L2 transaction is derived, and what latency and failure modes to expect. Then show me the minimal code to trigger a deposit from my app. I am building [describe your app]. ``` ### Plan a Fault-Proof Challenger Deployment **Persona:** chain operator Every permissionless fault-proof chain needs an honest challenger watching its dispute games. Grounding pages: [OP-Challenger Explainer](/op-stack/fault-proofs/challenger) and [How to Configure Challenger for Your Chain](/chain-operators/guides/configuration/op-challenger-config-guide). ```text theme={null} Read https://docs.optimism.io/op-stack/fault-proofs/challenger.md and https://docs.optimism.io/chain-operators/guides/configuration/op-challenger-config-guide.md I operate an OP Stack chain with fault proofs enabled on [network]. Produce a deployment plan for op-challenger: the role it plays, the resources and keys it needs, the bond funding it requires, the configuration I must set, and the monitoring I should attach. List open questions I need to answer about my own chain before deploying. ``` ### Bridge ETH From L1 in My App **Persona:** app developer Move ETH between Ethereum and an OP Stack chain programmatically. Grounding page: [Submitting Transactions From L1](/app-developers/tutorials/bridging/cross-dom-bridge-eth). ```text theme={null} Read https://docs.optimism.io/app-developers/tutorials/bridging/cross-dom-bridge-eth.md Using the approach in this tutorial, write the code for my app to bridge ETH from [L1 network] to [L2 network] and report deposit status to the user. My stack is [TypeScript framework / environment]. Point out where testnet and mainnet configuration differ, and what the user experience should show while the deposit is in flight. ``` ### Explain My Transaction's Fee Breakdown **Persona:** app developer OP Stack transactions pay an execution fee and a data-availability fee; estimating only one of them causes bugs. Grounding page: [Transaction Fees on OP Mainnet](/op-stack/transactions/fees). ```text theme={null} Read https://docs.optimism.io/op-stack/transactions/fees.md Explain every component of the fee my transaction pays on an OP Stack chain, how each is calculated, and which ones fluctuate with L1 gas prices. Then show me how to estimate the total fee for a transaction correctly in my app, and the common estimation mistakes to avoid. Here is my current estimation code: [paste code, optional]. ``` ### Debug a Stuck Withdrawal **Persona:** app developer Withdrawals are multi-step and time-delayed by design; most "stuck" withdrawals are actually mid-flight. Grounding pages: [Withdrawal Flow](/op-stack/bridging/withdrawal-flow) and [Transaction Finality](/op-stack/transactions/transaction-finality). ```text theme={null} Read https://docs.optimism.io/op-stack/bridging/withdrawal-flow.md and https://docs.optimism.io/op-stack/transactions/transaction-finality.md A withdrawal from [L2 network] appears stuck: [describe what you did, when, and the transaction hash or current status]. Using the withdrawal lifecycle in these docs, determine which stage the withdrawal is in, whether the delay is expected protocol behavior or an actual problem, and exactly what action (if any) unblocks the next step. ``` ## Contributing The prompts above are curated: each one maps to a task readers actually arrive with, and each grounds the assistant in maintained docs pages. To propose a new prompt or fix a stale one, [open an issue](https://github.com/ethereum-optimism/optimism/issues) or edit this page. # Bridging basics Source: https://docs.optimism.io/app-developers/guides/bridging/basics Learn about the fundamentals of sending data and tokens between Ethereum and OP Mainnet. OP Mainnet is a "Layer 2" system and is fundamentally connected to Ethereum. However, OP Mainnet is also a distinct blockchain with its own blocks and transactions. App developers commonly need to move data and tokens between OP Mainnet and Ethereum. This process of moving data and tokens between the two networks is called "bridging". ## Sending tokens One of the most common use cases for bridging is the need to send ETH or ERC-20 tokens between OP Mainnet and Ethereum. OP Mainnet has a system called the [Standard Bridge](./standard-bridge) that makes it easy to move tokens in both directions. If you mostly need to bridge tokens, make sure to check out the [Standard Bridge](./standard-bridge) guide. ## Sending data 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). Applications can use this system to have a contract on Ethereum interact with a contract on OP Mainnet, and vice versa. All of this is easily accessible with a simple, clean API. ## Next steps Ready to start bridging? Check out these tutorials to get up to speed fast. * [Learn how to bridge ERC-20 tokens with viem](/app-developers/tutorials/bridging/cross-dom-bridge-erc20) * [Learn how to create a standard or custom bridged token](/app-developers/tutorials/bridging/standard-bridge-standard-token) * [Learn how to submit transactions from L1](/app-developers/tutorials/bridging/cross-dom-bridge-eth) # Custom bridges Source: https://docs.optimism.io/app-developers/guides/bridging/custom-bridge Important considerations when building custom bridges for OP Mainnet. Custom token bridges are any bridges other than the [Standard Bridge](./standard-bridge). 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. This guide provides important information you should be aware of when building a custom bridge. <Info> Custom bridges can bring a significant amount of complexity and risk to any project. Before you commit to a custom bridge, be sure that the [Standard Bridge](./standard-bridge) definitely does not support your use case. [Building a custom bridged token](/app-developers/tutorials/bridging/standard-bridge-standard-token) is often sufficient for projects that need more flexibility. </Info> ## Guidelines Custom bridges can use any design pattern you can think of. However, with increased complexity comes increased risk. Consider directly extending or modifying the [`StandardBridge`](https://github.com/ethereum-optimism/optimism/blob/develop/packages/contracts-bedrock/src/universal/StandardBridge.sol) contract before building your own bridge contracts from scratch. Doing so will provide you with an audited foundation upon which you can add extra logic. If you choose not to extend the `StandardBridge` contract, you may still want to follow the interface that the `StandardBridge` provides. Bridges that extend this interface will be compatible with the [Superchain Bridges UI](https://app.optimism.io/bridge?utm_source=op-docs\&utm_medium=docs). You can read more about the design of the Standard Bridge in the guide on [Using the Standard Bridge](./standard-bridge). ## The Superchain Token List The [Superchain Token List](/app-developers/reference/tokens/tokenlist) exists to help users and developers find the right bridged representations of tokens native to another blockchain. 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). You **must** deploy your bridge to OP Sepolia before it can be added to the Superchain Token List. ## Next steps You can explore several examples of custom bridges for OP Mainnet: * [NFT Bridge](https://github.com/ethereum-optimism/optimism/blob/develop/packages/contracts-bedrock/src/L1/L1ERC721Bridge.sol) * [L2 DAI Token Bridge](https://optimistic.etherscan.io/address/0x467194771dae2967aef3ecbedd3bf9a310c76c65#code) and [deployed addresses](https://github.com/ethereum-optimism/ethereum-optimism.github.io/blob/master/data/DAI/data.json) * [SNX Bridge](https://github.com/ethereum-optimism/ethereum-optimism.github.io/blob/master/data/SNX/data.json) # Sending data between L1 and L2 Source: https://docs.optimism.io/app-developers/guides/bridging/messaging Understand how bridging between L1 and L2 works, the messenger contracts that carry messages, what messages cost, and why the challenge period exists. Smart contracts on L1 (Ethereum) can interact with smart contracts on L2 (OP Mainnet) through a process called "bridging". This page explains how bridging works: the messenger contracts that carry messages between layers, how long delivery takes in each direction, what messages cost, and why messages from L2 to L1 must wait out a challenge period. <Info> This is a high-level overview of the bridging process. For a step-by-step tutorial on how to send data between L1 and L2, check out the [Solidity tutorial](/app-developers/tutorials/bridging/cross-dom-solidity). </Info> ## Understanding contract calls 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. The interface for sending messages *between* Ethereum and OP Mainnet is designed to mimic the standard contract communication interface as much as possible. Here's how a contract on Ethereum might trigger a function within another contract on Ethereum: ```solidity theme={null} contract MyContract { function doTheThing(address myContractAddress, uint256 myFunctionParam) public { MyOtherContract(myContractAddress).doSomething(myFunctionParam); } } ``` Here, `MyContract.doTheThing` triggers a call to `MyOtherContract.doSomething`. Under the hood, Solidity is triggering the code for `MyOtherContract` by sending an [ABI encoded](https://docs.soliditylang.org/en/v0.8.23/abi-spec.html) call for the `doSomething` function. A lot of this complexity is abstracted away to simplify the developer experience. Solidity also has manual encoding tools that allow us to demonstrate the same process in a more verbose way. Here's how you might manually encode the same call: ```solidity theme={null} contract MyContract { function doTheThing(address myContractAddress, uint256 myFunctionParam) public { myContractAddress.call( abi.encodeCall( MyOtherContract.doSomething, ( myFunctionParam ) ) ); } } ``` Here you're using the [low-level "call" function](https://docs.soliditylang.org/en/v0.8.23/units-and-global-variables.html#members-of-address-types) and one of the [ABI encoding functions built into Solidity](https://docs.soliditylang.org/en/v0.8.23/units-and-global-variables.html#abi-encoding-and-decoding-functions). Although these two code snippets look a bit different, they're doing the exact same thing. Because of limitations of Solidity, **the OP Stack's bridging interface is designed to look like the second code snippet**. ## Basics of communication between layers 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). Communication between L1 and L2 is made possible by a pair of special smart contracts called the "messenger" contracts. Each layer has its own messenger contract, which serves to abstract away some lower-level communication details, a lot like how HTTP libraries abstract away physical network connections. We won't get into *too* much detail about these contracts here. The most important thing that you need to know is that each messenger contract has a `sendMessage` function that allows you to send a message to a contract on the other layer. ```solidity theme={null} function sendMessage( address _target, bytes memory _message, uint32 _minGasLimit ) public; ``` The `sendMessage` function has three parameters: 1. The `address _target` of the contract to call on the other layer. 2. The `bytes memory _message` calldata to send to the contract on the other layer. 3. The `uint32 _minGasLimit` minimum gas limit that can be used when executing the message on the other layer. This is basically equivalent to: ```solidity theme={null} address(_t
프로젝트로 돌아가기