From 274b142e88521b93518a056a74bac7ba25c34de1 Mon Sep 17 00:00:00 2001 From: soyboy <85043086+sbvegan@users.noreply.github.com> Date: Wed, 6 Nov 2024 16:33:58 -0800 Subject: [PATCH 1/2] removing out of date files --- .../app-developers/contracts/_meta.json | 3 - .../contracts/compatibility.mdx | 24 -- .../app-developers/contracts/optimization.mdx | 79 ---- .../contracts/system-contracts.mdx | 100 ----- pages/builders/app-developers/tutorials.mdx | 2 - .../app-developers/tutorials/_meta.json | 1 - .../tutorials/first-contract.mdx | 367 ------------------ public/_redirects | 6 +- 8 files changed, 5 insertions(+), 577 deletions(-) delete mode 100644 pages/builders/app-developers/contracts/compatibility.mdx delete mode 100644 pages/builders/app-developers/contracts/optimization.mdx delete mode 100644 pages/builders/app-developers/contracts/system-contracts.mdx delete mode 100644 pages/builders/app-developers/tutorials/first-contract.mdx diff --git a/pages/builders/app-developers/contracts/_meta.json b/pages/builders/app-developers/contracts/_meta.json index c4b36699f..6e2ad3d2e 100644 --- a/pages/builders/app-developers/contracts/_meta.json +++ b/pages/builders/app-developers/contracts/_meta.json @@ -1,6 +1,3 @@ { - "compatibility": "Solidity compatibility", - "system-contracts": "System contracts", - "optimization": "Cost optimization", "superchain-erc20": "SuperchainERC20" } diff --git a/pages/builders/app-developers/contracts/compatibility.mdx b/pages/builders/app-developers/contracts/compatibility.mdx deleted file mode 100644 index 7133db286..000000000 --- a/pages/builders/app-developers/contracts/compatibility.mdx +++ /dev/null @@ -1,24 +0,0 @@ ---- -title: Solidity compatibility -lang: en-US -description: Learn about the differences between OP Mainnet and Ethereum when building Solidity contracts. ---- - -# Solidity compatibility - -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. -Almost all Ethereum tooling works out of the box on OP Mainnet, including the [Solidity](https://soliditylang.org/) smart contract language. -However, there are a few minor differences between OP Mainnet and Ethereum that you should be aware of when building Solidity contracts. - -## EVM/Opcode differences - -Most smart contracts will work on OP Mainnet without any changes. -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. - -## Gas differences - -OP Mainnet uses the same gas costs as Ethereum. -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. -This fee is charged based on the size of a transaction in bytes. -As a result, smart contract optimization techniques can differ slightly on OP Mainnet. -Refer to the [Contract Optimization guide](./optimization) for more information. diff --git a/pages/builders/app-developers/contracts/optimization.mdx b/pages/builders/app-developers/contracts/optimization.mdx deleted file mode 100644 index 534ba1c67..000000000 --- a/pages/builders/app-developers/contracts/optimization.mdx +++ /dev/null @@ -1,79 +0,0 @@ ---- -title: Contract optimization on OP Mainnet -lang: en-US -description: Learn how to optimize contracts for OP Mainnet and what to look out for when you do so. ---- - -import { Callout } from 'nextra/components' - -# Contract optimization on OP Mainnet - -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. -One large and mostly unavoidable discrepancy between OP Mainnet and Ethereum is a slight [difference in transaction fee models](/stack/transactions/fees). -This difference means that there are some opportunities to optimize OP Mainnet contracts to better take advantage of the OP Mainnet fee model. - -This guide explains the basic concepts that allow you to optimize OP Mainnet contracts and provides several examples of how you might take advantage of these concepts. -You'll also get a better understanding of the tradeoffs and risks involved with potential contract optimizations. -By the end of this guide you should have a clear understanding of how OP Mainnet contracts can be optimized and whether or not these optimizations make sense for your application. - - -Contract optimizations are powerful but can also create additional contract complexity. -Some types of optimizations may also become unnecessary as OP Mainnet evolves. -Make sure to read through all of the considerations on this page before committing to any optimizations. - - -## Fundamentals - -App developers might already be familiar with the concept of [gas optimization](https://github.com/0xisk/awesome-solidity-gas-optimization) to decrease the cost of interacting with smart contracts. -Gas optimization can reduce the amount of gas used by a contract and make your application cheaper (and therefore improve user experience). - -OP Mainnet contracts can be gas optimized to reduce overall transaction costs, just like contracts on Ethereum. -However, OP Mainnet transactions must also pay for another fee called the L1 Data Fee which accounts for the cost of publishing transaction data to Ethereum. -At the time this guide was written, this L1 Data Fee made up the majority of the cost of most transactions on OP Mainnet. - -Because the L1 Data Fee tends to be larger than the execution gas fee, **OP Mainnet contracts can be further optimized by increasing the amount of storage/execution used in order to decrease the amount of user-provided data in each transaction.** -This is the basic premise that makes OP Mainnet contract optimization slightly different than on Ethereum. - -## Considerations - -### Additional complexity - -Contract optimizations can create additional complexity, which can in turn create additional risk. -Developers should always consider whether this added complexity is worth the reduction in cost. - -### Changing economics - -Various potential upgrades to OP Mainnet may also make optimizations to the L1 Data Fee less relevant. -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. - -OP Mainnet also uses an [EIP-1559](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1559.md) mechanism that automatically increases the base fee as chain usage increases. -Optimizations based on reducing the L1 Data Fee may become less relevant if the base fee becomes a larger part of the total transaction cost. - - -Generally speaking, **developers should assume that L1 Data Fee optimizations will become less useful as time goes on**. -If you expect your contracts to be used for long periods of time, you may wish to avoid optimizations that can potentially decrease long-term gas efficiency. -If you expect your contracts to be used mostly in the short term or you have the ability to upgrade contracts in the future, optimizations may be better suited for you. - - -## Techniques - -### Calldata compression - -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. -This technique decreases the amount of data provided by the user in exchange for a significant increase in onchain computation. - -Although several libraries exist to perform this calldata compression, none of these libraries have been audited as of the writing of this page. -As a result, links to these libraries have been explicitly omitted here to avoid encouraging developers from using potentially buggy software. -Most of these libraries can be found with a quick search online but, as always, be careful with code you find on the internet. - -### Custom encoding - -The [Solidity ABI encoding scheme](https://docs.soliditylang.org/en/v0.8.23/abi-spec.html#argument-encoding) is not particularly data efficient. -Contracts can often reduce the amount of calldata provided by defining a custom argument encoding protocol. - -Custom argument encodings can be combined with stored data to further reduce costs. -For example, `address` arguments could potentially be replaced with a `uint64` pointer that performs a lookup in a stored mapping of `uint64 => address`. -This would cut out a significant number of bytes with further reductions if the total number of addresses that need to be looked up is small (which would allow `uint64` to be reduced to `uint32` or less). - -Custom encodings are typically less complex than general-purpose calldata compression libraries but carry additional complexity no matter what. -When combined with stored data, application-specific custom encodings can be significantly more efficient than general-purpose compression mechanisms. diff --git a/pages/builders/app-developers/contracts/system-contracts.mdx b/pages/builders/app-developers/contracts/system-contracts.mdx deleted file mode 100644 index 4178a81a4..000000000 --- a/pages/builders/app-developers/contracts/system-contracts.mdx +++ /dev/null @@ -1,100 +0,0 @@ ---- -title: Using OP Mainnet system contracts -lang: en-US -description: Learn how to work with OP Mainnet contracts directly from other contracts and how to work with contracts from the client side. ---- - -import { Steps } from 'nextra/components' - -# Using OP Mainnet system contracts - -System contracts on Ethereum (L1) and OP Mainnet (L2) are an important part of the OP Mainnet ecosystem. -You may want to interact with these system contracts for any number of reasons, including: - -* Sending messages between L1 and L2 -* Sending tokens between L1 and L2 -* Querying information about the current [L1 data fee](/stack/transactions/fees#the-l1-data-fee) -* And lots more! - -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. - -## Before you begin - -You'll need to find the address of the particular contract that you want to interact with before you can actually interact with it. - -* Check out the [Networks and Connection Details page](/chain/networks) for links to public RPC endpoints and contract addresses. -* Find the addresses for all networks on the [Contract Addresses](/chain/addresses) page. -* 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). - -## Using system contracts in Solidity - -All you need to interact with the OP Mainnet system contracts from another contract is an address and an interface. -You can follow [the instructions above](#finding-contract-addresses) to find the address of the contract you want to interact with. -Now you simply need to import the appropriate contracts. - - -### Installing via NPM - -You can use the [`@eth-optimism/contracts-bedrock`](https://www.npmjs.com/package/@eth-optimism/contracts-bedrock?activeTab=readme) npm package to import system contracts and their interfaces. -Install the package as follows: - -```bash -npm install @eth-optimism/contracts-bedrock -``` - -### Importing contracts - -Simply import the desired contract or interface from the `@eth-optimism/contracts-bedrock` package: - -```solidity -import { SomeOptimismContract } from "@eth-optimism/contracts-bedrock/path/to/SomeOptimismContract.sol"; -``` - -Please note that `path/to/SomeOptimismContract` is the path to the contract [within this folder](https://github.com/ethereum-optimism/optimism/blob/v1.1.4/packages/contracts-bedrock/src). -For example, if you wanted to import the [`L1CrossDomainMessenger`](https://github.com/ethereum-optimism/optimism/blob/v1.1.4/packages/contracts-bedrock/src/L1/L1CrossDomainMessenger.sol) contract, you would use the following import: - -```solidity -import { L1CrossDomainMessenger } from "@eth-optimism/contracts/L1/messaging/L1CrossDomainMessenger.sol"; -``` - -### Getting L2 contract addresses - -System contracts on L2 are "pre-deployed" to special addresses that are the same on most OP Stack chains. -You can find these addresses on the [Contract Addresses](/chain/addresses) page. -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. - - -## Using system contracts in JavaScript - -You can also interact with the OP Mainnet system contracts from the client side. - -### Installing via NPM - -You can use the [`@eth-optimism/contracts-ts`](https://www.npmjs.com/package/@eth-optimism/contracts-ts?activeTab=readme) npm package to import system contracts and their interfaces. -Install the package as follows: - -```bash -npm install @eth-optimism/contracts-ts -``` - -### Getting contract artifacts and interfaces - -You can use the `@eth-optimism/contracts-ts` package to easily access the address or ABI of any OP Mainnet contract. - -Here's an example of how you can grab the ABI and address of the `L2OutputOracleProxy` contract on OP Mainnet (chain ID 10): - -```ts -import { - l2OutputOracleProxyABI, - l2OutputOracleAddresses, -} from '@eth-optimism/contracts-ts' - -// Note that the address is keyed by chain ID! -console.log(l2OutputOracleAddresses[10], l2OutputOracleProxyABI) -``` -### Interacting with the contract -You can then feed this address and ABI into your favorite web3 library to interact with the contract. - -`@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. -Check out the full [README](https://github.com/ethereum-optimism/optimism/tree/v1.1.4/packages/contracts-ts#readme) for more information. - diff --git a/pages/builders/app-developers/tutorials.mdx b/pages/builders/app-developers/tutorials.mdx index 807686a51..9376b72b8 100644 --- a/pages/builders/app-developers/tutorials.mdx +++ b/pages/builders/app-developers/tutorials.mdx @@ -17,8 +17,6 @@ This section provides information on bridging erc 20 tokens to op mainnet with t - - diff --git a/pages/builders/app-developers/tutorials/_meta.json b/pages/builders/app-developers/tutorials/_meta.json index 45ddaf362..c3a3283a0 100644 --- a/pages/builders/app-developers/tutorials/_meta.json +++ b/pages/builders/app-developers/tutorials/_meta.json @@ -1,5 +1,4 @@ { - "first-contract": "Deploying your first contract on OP Mainnet", "cross-dom-solidity": "Communicating between chains in Solidity", "cross-dom-bridge-eth": "Bridging ETH with Viem", "cross-dom-bridge-erc20": "Bridging ERC-20 tokens with the Optimism SDK", diff --git a/pages/builders/app-developers/tutorials/first-contract.mdx b/pages/builders/app-developers/tutorials/first-contract.mdx deleted file mode 100644 index 03acec0c1..000000000 --- a/pages/builders/app-developers/tutorials/first-contract.mdx +++ /dev/null @@ -1,367 +0,0 @@ ---- -title: Deploying your first contract on OP Mainnet -lang: en-US -description: Learn how to write and deploy your first contract on OP Mainnet using the MetaMask browser extension. ---- - -import { Callout, Steps } from 'nextra/components' - -# Deploying your first contract on OP Mainnet - - -**This tutorial is meant for developers who are new to OP Mainnet and Solidity.** -If you're already familiar with Solidity, consider reading the [OP Mainnet Differences](/chain/differences) guide to understand how OP Mainnet differs from Ethereum. -OP Mainnet is designed to "just work" with existing Ethereum tooling, so you can use the tools you already know like [Hardhat](https://hardhat.org/) or [Foundry](https://getfoundry.sh) just like you would on Ethereum. - - -This tutorial walks you through the process of deploying your first smart contract to OP Mainnet using the [Remix](https://remix.ethereum.org) in-browser Solidity IDE. - -## Dependencies - -* Firefox or any Chromium-based browser (Chrome, Brave, Edge, etc.) - -## Wallet setup - -You'll need access to an [Ethereum wallet](https://ethereum.org/en/wallets/) if you want to deploy a smart contract. -This tutorial uses [MetaMask](https://metamask.io), a popular browser extension wallet, just to get you started. -MetaMask is also available as a mobile application, but it's typically easier to use the browser extension for development. -If you already have MetaMask installed, you can skip this section. - - -Browser-based wallets like MetaMask are convenient for development, but they're not the most secure option. -You should never store large amounts of ETH or ERC-20 tokens in a browser-based wallet. -If you're planning to store a significant amount of ETH or ERC-20 tokens, consider using a hardware wallet instead. - - - - -{

Install the MetaMask extension for your browser

} - -Head over to [metamask.io](https://metamask.io) and click the "Download" button. -You'll then be given an option to install the MetaMask extension for your browser. -If using a Chromium-based browser, you may be prompted to install the MetaMask extension from the Chrome Web Store. -An onboarding page will pop up once the extension is installed. - -![MetaMask download page.](/img/builders/app-developers/tutorials/first-contract/mm-install.png) - -{

Continue to create a new wallet

} - -MetaMask will ask you to accept their terms of service. -Read them carefully, then tick the box to accept them. -Once you've accepted the terms of service, you can create a new wallet by clicking the "Create a new wallet" button. - -![MetaMask wallet creation page.](/img/builders/app-developers/tutorials/first-contract/mm-start.png) - -{

Decide if you want to share usage data

} - -After starting the wallet creation process you'll be asked if you'd like to share usage data with MetaMask. -This is entirely up to you. -Select "I agree" or "No thanks" depending on your preference. - -{

Create a password

} - -You'll be asked to create a password for your wallet. -This password will be used to encrypt your wallet, so make sure it's a strong one that you won't forget. - -You'll be asked to confirm that you understand MetaMask cannot recover your password if you lose it. -You may want to store this password in a password manager. -Remember, browser-based wallets are great for development but are not the most secure option. -Consider looking into a hardware wallet if you're planning to store a significant amount of ETH or ERC-20 tokens. - -Once you've written down your password, click "Create a new wallet" to continue. - -![MetaMask password creation page.](/img/builders/app-developers/tutorials/first-contract/mm-password.png) - -{

Watch the short security video

} - -MetaMask will now show you a short video about wallet security. -If this is your first time using MetaMask or a browser-based wallet, it's recommended that you watch the video. - -{

Secure your wallet

} - -You'll be presented with the option to "Secure my wallet (recommended)" or "Remind me later (not recommended)". -It's strongly recommended to continue with the "Secure my wallet (recommended)" option. -This will prompt you to back up your wallet and might prevent you from losing access to your wallet down the line. - -![MetaMask security video page.](/img/builders/app-developers/tutorials/first-contract/mm-secure.png) - -{

Write down your secret recovery phrase

} - -After continuing with "Secure my wallet (recommended)", you'll be asked to write down a 12 word secret recovery phrase. -This phrase can be used to recover your wallet if you lose your password or the browser extension somehow becomes corrupted. -Write these words down somewhere safe and keep them secret. -For a development wallet, it's fine to keep the phrase in a password manager. -Just don't place too much importance in this wallet. - -![MetaMask recovery phrase page.](/img/builders/app-developers/tutorials/first-contract/mm-seed.png) - -{

Confirm your secret recovery phrase

} - -After writing down your secret recovery phrase, you'll be asked to confirm it. -This is to make sure you wrote it down correctly. -MetaMask will ask you to input a few of the words you wrote down. -Make sure to input them in the correct order. - -![MetaMask recovery confirmation page.](/img/builders/app-developers/tutorials/first-contract/mm-confirm.png) - -{

Complete the wallet creation process

} - -You're all done! -Read through the final page to get some more tips from MetaMask, then click "Got it!" when you're ready to continue. - -
- - -Want to explore wallets other than MetaMask? -There are many different kinds of wallets out there. -You can use [Ethereum.org's "Find a wallet" feature](https://ethereum.org/en/wallets/find-wallet/) to find one that works for you. - - -## Add OP Sepolia to MetaMask - -This tutorial will show you how to deploy a smart contract to OP Sepolia, the testnet for OP Mainnet. -Once you know how to deploy a smart contract to OP Sepolia, you'll be able to deploy a smart contract to OP Mainnet in exactly the same way. -In order to interact with OP Sepolia using MetaMask, you'll need to add it as a custom network. - - - -{

Open the OP Sepolia connection link

} - -Click [this link](https://chainid.link/?network=op-sepolia) to open the OP Sepolia connection link. -This link will show you the connection details for OP Sepolia and give you the option to add it to MetaMask. -Once you're ready to connect to OP Sepolia, click the "connect" button. - -![OP Sepolia connection website content.](/img/builders/app-developers/tutorials/first-contract/net-connect.png) - -{

Allow the site to add the network

} - -You'll be presented with a popup from MetaMask asking if you'd like to add the network. -Click "Approve" to add OP Sepolia to MetaMask. - -
-![MetaMask window with the network approval pane open.](/img/builders/app-developers/tutorials/first-contract/net-approve.png) -
- -{

Switch to the OP Sepolia network

} - -After you approve the network, MetaMask will automatically try to switch to the OP Sepolia network. -Click "Switch network" to continue. - -
-![MetaMask window with the network switching pane open.](/img/builders/app-developers/tutorials/first-contract/net-switch.png) -
- -
- -## Get ETH on OP Sepolia - -You'll need some ETH on OP Sepolia to pay for the [gas fees](https://ethereum.org/en/developers/docs/gas/) associated with deploying a smart contract. -You can use the [Optimism Superchain Faucet](https://console.optimism.io/faucet?utm_source=docs) to get some free ETH on OP Sepolia. - - -Having issues with the Optimism Superchain Faucet? -You can try using [other available OP Sepolia faucets](/builders/tools/build/faucets) instead. - - -## Check your wallet balance - -After you get some ETH on OP Sepolia, you can check your wallet balance in MetaMask. -Make sure that your balance has updated before continuing. -If you don't see any ETH in your wallet, double check that your MetaMask is connected to the OP Sepolia network. - -## Write your first contract - -The most popular smart contract development language today is [Solidity](https://docs.soliditylang.org/en/latest/). -In this tutorial, you'll be using a browser-based integrated development environment (IDE) called [Remix](https://remix.ethereum.org/). -Remix is a great tool for learning Solidity because it requires minimal setup and runs in your browser. - - - -{

Open Remix

} - -Head over to [remix.ethereum.org](https://remix.ethereum.org/) to open Remix. -You'll be presented with a welcome screen and a popup asking if you'd like to share usage data with Remix. -Accept or decline this request depending on your preferences. - -{

Step through the tutorial

} - -Remix has a small built-in tutorial that will walk you through the basics of the IDE. -Click the "Next" button to step through the tutorial. -Read through the tips to get a sense of the IDE. - -{

Create an empty contract file

} - -Click on the "File" icon in the left sidebar to create a new file. -Name the file "MyFirstContract.sol" and hit enter to create it. - -![Remix window displaying the empty MyFirstContract file.](/img/builders/app-developers/tutorials/first-contract/remix-empty.png) - -{

Write your first contract

} - -This tutorial will show you how to deploy a simple contract that has a storage variable you can read and write. -You'll be able to update this variable with a transaction and then retrieve the updated value. -This is just a simple example to get you started. -Solidity is a powerful language that can be used to write complex smart contracts, check out the [Next Steps](#next-steps) section below after you've finished this tutorial for some more advanced examples! - -Copy and paste the following code into the file you just created. -Remix will detect copy/pasted code and give you a warning about it. -This is meant to prevent you from accidentally running malicious code. -Always be careful when copy/pasting code from the internet! - -```solidity file=/public/tutorials/first-contract.sol#L1-L10 hash=a008d0629d499be56a6629495bc55910 -``` - -{

Compile your contract

} - -By default, Remix will automatically compile your contract when you save it. -You can also manually compile your contract by clicking the "Solidity Compiler" icon in the left sidebar and then clicking the "Compile" button. -It's usually easier to leave automatic compilation enabled. -You shouldn't see any compilation errors for this contract. - -![Remix window with the compilation tab highlighted.](/img/builders/app-developers/tutorials/first-contract/remix-compile.png) - -
- -## Deploy your contract - -Now that you've written your first contract, you can deploy it to OP Sepolia. -Deploying contracts with Remix is pretty straightforward. - - - -{

Open the Deploy tab

} - -Click on the "Deploy & run transactions" icon in the left sidebar to open the Deploy tab (it looks like an Ethereum logo with an arrow pointing to the right). -You'll see some deployment options and a list of contracts that are currently compiled. -Since you only have one contract, you should see a single contract called "MyFirstContract" in the list. - -![Remix window with the deployment tab highlighted.](/img/builders/app-developers/tutorials/first-contract/remix-deploytab.png) - -{

Change your environment

} - -By default, Remix will try to deploy your contract to a local, in-memory blockchain. -This is useful for testing, but you'll need to change your environment to deploy to OP Sepolia for this tutorial. -Click on the dropdown underneath the "Environment" heading and select "Injected Provider - MetaMask". - -![Remix window with the environment dropdown highlighted.](/img/builders/app-developers/tutorials/first-contract/remix-network.png) - -{

Accept the connection request

} - -Once you've selected the "Injected Provider - MetaMask" option, MetaMask will show you a popup asking if you'd like to connect to Remix. -Accept this request by clicking the "Connect" button. - -{

Deploy your contract

} - -You're now ready to deploy your contract! -Click the orange "Deploy" button to deploy your contract to OP Sepolia. -You'll be presented with another MetaMask popup asking you to confirm the transaction. -Click the "Confirm" button to continue. - -
-![MetaMask contract deployment approval popup.](/img/builders/app-developers/tutorials/first-contract/remix-deploy.png) -
- -{

Wait for your transaction to confirm

} - -OP Sepolia is relatively fast, so transactions should confirm within just a few seconds. -Remix will automatically detect when your transaction has confirmed and will show you your newly deployed contract under the "Deployed Contracts" heading within the Deploy tab. - -
- -## Interact with your contract - -Now that you've deployed your contract, you can interact with it. -Remix makes it easy to interact with your contract by providing a built-in user interface. -You can use this interface to call functions on your contract and read its state. - - - -{

Expand your contract

} - -Click on the arrow next to the name of your contract under the "Deployed Contracts" heading to expand it. -You should see a list of functions that you can call on your contract. - -![Remix window with the deployed contract area highlighted.](/img/builders/app-developers/tutorials/first-contract/remix-deployed.png) - -{

Call the setMessage function

} - -Now you'll update the message variable in your contract. -Type a message into the input box next to the orange "setMessage" button and click on the "setMessage" button. -Just like when you deployed your contract, you'll be presented with a MetaMask popup asking you to confirm the transaction. -Click the "Confirm" button to continue. - -![Remix window with the setMessage function button highlighted.](/img/builders/app-developers/tutorials/first-contract/remix-setmessage.png) - -{

Wait for your transaction to confirm

} - -Once again, Remix will automatically detect when your transaction has confirmed. -You'll see a green checkmark appear in the console at the bottom of the screen. - -{

Read the updated message variable

} - -Click on the "message" button to read the updated message variable. -You should see the message you set in the previous step appear underneath the "message" button. -Congrats, you've successfully deployed and interacted with your first smart contract on OP Sepolia! - -![Remix window with the message reading function button highlighted.](/img/builders/app-developers/tutorials/first-contract/remix-message.png) - -
- -## How your contract works - -Now that you've deployed your contract, you might be wondering how it works. -Let's take a closer look at the code you wrote. - -### License identifier - -The first line of most Solidity files is the license identifier. -This line is used to specify the license under which the code is released. -In this case, the code written is released under the [MIT license](https://opensource.org/licenses/MIT). - -```solidity file=/public/tutorials/first-contract.sol#L1 hash=8384d75c38c570f3edb87cf9f64f2ec2 -``` - -### Pragma directive - -The next line is a [pragma directive](https://docs.soliditylang.org/en/latest/layout-of-source-files.html#pragma). -This line tells the Solidity compiler which version of the Solidity language to use. -In this case, the code is written for Solidity version 0.8.0 or higher. - -```solidity file=/public/tutorials/first-contract.sol#L2 hash=70ebe002bc5488bb81baa0504de273c1 -``` - -### Contract definition - -The next line defines a contract called `MyFirstContract`. -A contract is a collection of code and data that is stored at a specific address on the blockchain. -You can think of a contract as a class in an object-oriented programming language. -The contract definition is followed by a pair of curly braces that contain the contract's code. - -```solidity file=/public/tutorials/first-contract.sol#L4 hash=8f3ace25e5f9ea06d8cb388eb3ab1775 -``` - -### Message variable - -The first thing you'll notice inside the contract definition is a variable called `message`. -This variable is declared as a `string`, which is a Solidity type that represents a string of characters. -The `public` keyword means that this variable can be read from outside the contract. - -```solidity file=/public/tutorials/first-contract.sol#L5 hash=42a1bdfe81e5b3bba6b99d3255ef4f2b -``` - -### Message update function - -The next thing you'll notice is a function called `setMessage`. -This function takes a single argument called `_message` of type `string`. -The `public` keyword means that this function can be called from outside the contract by anyone. -Since this function doesn't have any access control, anyone can update the `message` variable. - -```solidity file=/public/tutorials/first-contract.sol#L7-L9 hash=b7e5531c48425b183e794f9f251c5540 -``` - -## Next steps - -To learn more about Solidity, check out the [Solidity documentation](https://docs.soliditylang.org/en/latest/) for more information about the language itself. If you learn best by reading source code, check out [this annotated code for an ERC-20 token contract](https://ethereum.org/en/developers/tutorials/erc20-annotated-code/). - -Now that you know how to deploy a smart contract to OP Sepolia, you can deploy a smart contract to OP Mainnet in exactly the same way. -If you're up for a challenge, try [creating a token on Sepolia and OP Sepolia](./standard-bridge-standard-token) and then [using the Optimism SDK](./cross-dom-bridge-erc20) to bridge some tokens between the two networks. diff --git a/public/_redirects b/public/_redirects index 3eb5cb69c..536d0138a 100644 --- a/public/_redirects +++ b/public/_redirects @@ -104,4 +104,8 @@ /stack/operators/features/proxyd /builders/chain-operators/tools/proxyd /builders/notices/granite-changes https://github.com/ethereum-optimism/docs/blob/ef619668ae44276edecdfd657157254b9809e2d6/pages/builders/notices/granite-changes.mdx /builders/notices/fp-changes https://github.com/ethereum-optimism/docs/blob/ef619668ae44276edecdfd657157254b9809e2d6/pages/builders/notices/fp-changes.mdx -/chain/differences /stack/differences \ No newline at end of file +/chain/differences /stack/differences +/builders/app-developers/contracts/optimization /builders/app-developers/overview +/builders/app-developers/contracts/system-contracts /stack/smart-contracts +/builders/app-developers/contracts/compatibility /stack/differences +/builders/app-developers/tutorials/first-contract /builders/app-developers/overview \ No newline at end of file From 1601d038905b4e2fb16512407f146d8856685815 Mon Sep 17 00:00:00 2001 From: soyboy <85043086+sbvegan@users.noreply.github.com> Date: Wed, 6 Nov 2024 16:38:00 -0800 Subject: [PATCH 2/2] updating overview breadcrumb page --- pages/builders/app-developers/contracts.mdx | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/pages/builders/app-developers/contracts.mdx b/pages/builders/app-developers/contracts.mdx index f2836e72d..605fd529c 100644 --- a/pages/builders/app-developers/contracts.mdx +++ b/pages/builders/app-developers/contracts.mdx @@ -1,23 +1,15 @@ --- title: Contracts lang: en-US -description: >- - Information on Solidity compatibility, contract optimization, and system - contracts for OP Stack. +description: Information on the Superchain ERC-20 --- import { Card, Cards } from 'nextra/components' # Contracts -This section provides information on Solidity compatibility, contract optimization on OP Stack, and using OP Stack system contracts. You'll find guides and tutorials to help you understand and work with these topics. +This section provides information on the Superchain ERC-20. - - - - - -