From dd2f372488f384c8533205151a0ad82d385b2c76 Mon Sep 17 00:00:00 2001 From: krofax Date: Mon, 10 Feb 2025 19:48:38 +0100 Subject: [PATCH 1/3] remove viewing tut --- .../tutorials/sdk-view-txns.mdx | 176 ------------------ public/tutorials/sdk-view-txns.js | 52 ------ 2 files changed, 228 deletions(-) delete mode 100644 pages/app-developers/tutorials/sdk-view-txns.mdx delete mode 100644 public/tutorials/sdk-view-txns.js diff --git a/pages/app-developers/tutorials/sdk-view-txns.mdx b/pages/app-developers/tutorials/sdk-view-txns.mdx deleted file mode 100644 index d93b63610..000000000 --- a/pages/app-developers/tutorials/sdk-view-txns.mdx +++ /dev/null @@ -1,176 +0,0 @@ ---- -title: Viewing deposits and withdrawals by address -lang: en-US -description: Learn how to use the Optimism SDK to view all deposits and withdrawals triggered by a given address. ---- - -import { Callout, Steps } from 'nextra/components' -import { WipCallout } from '@/components/WipCallout' - - -# Viewing deposits and withdrawals by address - -In this tutorial, you'll learn how to use the [Optimism SDK](https://sdk.optimism.io) to view all of the [Standard Bridge](../bridging/standard-bridge) deposits and withdrawals triggered by a given address. - - -Check out the tutorial on [Bridging ERC-20 Tokens With the Optimism SDK](./cross-dom-bridge-erc20) to learn how to create deposits and withdrawals. - - -## Dependencies - -* [node](https://nodejs.org/en/) -* [pnpm](https://pnpm.io/installation) - -## Create a demo project - -You're going to use the Optimism SDK for this tutorial. -Since the Optimism SDK is a [Node.js](https://nodejs.org/en/) library, you'll need to create a Node.js project to use it. - - - -{

Make a Project Folder

} - -```bash -mkdir op-sample-project -cd op-sample-project -``` - -{

Initialize the Project

} - -```bash -pnpm init -``` - -{

Install the Optimism SDK

} - -```bash -pnpm add @eth-optimism/sdk -``` - -{

Install ethers.js

} - -```bash -pnpm add ethers@^5 -``` - -
- -## Add RPC URLs to your environment - -You'll be using the `getDepositsByAddress` and `getWithdrawalsByAddress` functions from the Optimism SDK during this tutorial. -These functions use event queries to retrieve the deposits and withdrawals made by a given address. -Since these functions use large event queries, you'll need to use an RPC provider like [Alchemy](https://alchemy.com) that supports indexed event queries. -Grab an L1 and L2 RPC URL for Sepolia and OP Sepolia, respectively. - -```bash -export L1_RPC_URL=... # Sepolia RPC URL -export L2_RPC_URL=... # OP Sepolia RPC URL -``` - - -The Optimism SDK may be updated in the future to use a different method of retrieving deposits and withdrawals under the hood that does not require indexed event queries. -This tutorial will be updated to reflect those changes if and when they occur. - - -## Start the Node REPL - -You're going to use the Node REPL to interact with the Optimism SDK. -To start the Node REPL run the following command in your terminal: - -```bash -node -``` - -This will bring up a Node REPL prompt that allows you to run javascript code. - -## Import dependencies - -You need to import some dependencies into your Node REPL session. - - - -{

Import the Optimism SDK

} - -```js file=/public/tutorials/sdk-view-txns.js#L3 hash=26b2fdb17dd6c8326a54ec51f0769528 -``` - -{

Import ethers.js

} - -```js file=/public/tutorials/sdk-view-txns.js#L4 hash=69a65ef97862612e4978b8563e6dbe3a -``` - -
- -## Set session variables - -You'll need a few variables throughout this tutorial. -Let's set those up now. - - - -{

Import RPC URLs

} - -```js file=/public/tutorials/sdk-view-txns.js#L10-L11 hash=02141d8cb077764665c61fc48e18ed04 -``` - -{

Set the address to query

} - -Here you'll be querying over an address that has already made some deposits and withdrawals. -You can replace this address with your own address if you'd like. - -```js file=/public/tutorials/sdk-view-txns.js#L14 hash=2d71bc03a4b3a3942fecdaf8a66f4a27 -``` - -{

Create the RPC providers

} - -```js file=/public/tutorials/sdk-view-txns.js#L16-L17 hash=e86efaea1d4adde679ca66911080dc28 -``` - -
- -## Create the CrossDomainMessenger - -The Optimism SDK exports a `CrossChainMessenger` class that makes it easy to interact with the Standard Bridge contracts. - -Create an instance of the `CrossChainMessenger` class: - -```js file=/public/tutorials/sdk-view-txns.js#L19-L24 hash=158c6888c82bdc2f07c37c3edb3a9a6a -``` - -## Query for deposits - -You'll first query for all of the deposits made by the target address. -The `CrossChainMessenger` has a convenient function called `getDepositsByAddress` that makes this easy. - - - -{

Grab all deposits

} - -```js file=/public/tutorials/sdk-view-txns.js#L27 hash=feaa2a2fb5fb75c58ace54aaad6cfac4 -``` - -{

Display the deposits

} - -```js file=/public/tutorials/sdk-view-txns.js#L30-L37 hash=116d4986989b6019d516cb5ee7960c07 -``` - -
- -## Query for withdrawals - -You'll next query for all of the withdrawals made by the target address. -The `CrossChainMessenger` has a convenient function called `getWithdrawalsByAddress` that makes this easy. - - - -{

Grab all withdrawals

} - -```js file=/public/tutorials/sdk-view-txns.js#L40 hash=264c31c31103dff9aeaec9640365faae -``` - -{

Display the withdrawals

} - -```js file=/public/tutorials/sdk-view-txns.js#L43-L50 hash=f47dbeb2048e5fdf2665e8f3e07bf6c8 -``` - -
diff --git a/public/tutorials/sdk-view-txns.js b/public/tutorials/sdk-view-txns.js deleted file mode 100644 index 24858023d..000000000 --- a/public/tutorials/sdk-view-txns.js +++ /dev/null @@ -1,52 +0,0 @@ -(async () => { - -const optimism = require("@eth-optimism/sdk") -const ethers = require("ethers") - -// Need to use Alchemy or something here because the getDepositsByAddress and -// getWithdrawalsByAddress functions use a large block range that the public RPC doesn't support -// because it uses Ankr. Maybe the SDK should be updated to use smaller block ranges depending -// on the RPC but that's a separate issue. -const l1RpcUrl = process.env.L1_RPC_URL -const l2RpcUrl = process.env.L2_RPC_URL - -// Docs CI wallet, will have deposits and withdrawals. -const address = '0x5A07785F07D8ba8a9e5323181fBDab51FE9a36c3' - -const l1Provider = new ethers.providers.StaticJsonRpcProvider(l1RpcUrl) -const l2Provider = new ethers.providers.StaticJsonRpcProvider(l2RpcUrl) - -const messenger = new optimism.CrossChainMessenger({ - l1ChainId: 11155111, // 11155111 for Sepolia, 1 for Ethereum - l2ChainId: 11155420, // 11155420 for OP Sepolia, 10 for OP Mainnet - l1SignerOrProvider: l1Provider, - l2SignerOrProvider: l2Provider, -}) - -console.log('Grabbing deposits...') -const deposits = await messenger.getDepositsByAddress(address) - -console.log('Grabbed deposits:') -for (const deposit of deposits) { - console.log('----------------------------------------------------') - console.log('From: ', deposit.from) - console.log('To: ', deposit.to) - console.log('L1 Token:', deposit.l1Token) - console.log('L2 Token:', deposit.l2Token) - console.log('Amount: ', deposit.amount.toString()) -} - -console.log('Grabbing withdrawals...') -const withdrawals = await messenger.getWithdrawalsByAddress(address) - -console.log('Grabbed withdrawals:') -for (const withdrawal of withdrawals) { - console.log('----------------------------------------------------') - console.log('From: ', withdrawal.from) - console.log('To: ', withdrawal.to) - console.log('L1 Token:', withdrawal.l1Token) - console.log('L2 Token:', withdrawal.l2Token) - console.log('Amount: ', withdrawal.amount.toString()) -} - -})() From f7bf2c69999c1856ba1ba6276a07b35ce05bbeb2 Mon Sep 17 00:00:00 2001 From: krofax Date: Mon, 10 Feb 2025 20:11:16 +0100 Subject: [PATCH 2/3] Removed every occurence of the tutorial --- pages/app-developers/overview.mdx | 1 - pages/app-developers/tutorials.mdx | 3 +-- pages/app-developers/tutorials/_meta.json | 1 - pages/app-developers/tutorials/sdk-trace-txns.mdx | 1 - 4 files changed, 1 insertion(+), 5 deletions(-) diff --git a/pages/app-developers/overview.mdx b/pages/app-developers/overview.mdx index 0b7f02c46..408aaf071 100644 --- a/pages/app-developers/overview.mdx +++ b/pages/app-developers/overview.mdx @@ -59,7 +59,6 @@ They'll help you get a head start when building your first Optimistic project. | [Bridging your Standard ERC-20 token using the Standard Bridge](tutorials/standard-bridge-standard-token) | Learn how to bridge your standard ERC-20 token to layer 2 using the standard bridge. | 🟡 Medium | | [Bridging your Custom ERC-20 token using the Standard Bridge](tutorials/standard-bridge-custom-token) | Learn how to bridge your custom ERC-20 token to layer 2 using the standard bridge. | 🟡 Medium | | [Tracing Deposits and Withdrawals with viem](tutorials/sdk-trace-txns) | Learn how to use viem to trace deposits and withdrawals. | 🟢 Easy | -| [Viewing Deposits and Withdrawals by address with viem](tutorials/sdk-view-txns) | Learn how to use viem to view deposits and withdrawals by address. | 🟢 Easy | | [Estimating Transaction Costs With the viem](tutorials/sdk-view-txns) | Learn how to use viem to estimate the cost of a transaction on OP Mainnet. | 🟢 Easy | | [Sending OP Mainnet Transactions from Ethereum](tutorials/send-tx-from-eth) | Learn how to send transactions to OP Mainnet from Ethereum. | 🟢 Easy | diff --git a/pages/app-developers/tutorials.mdx b/pages/app-developers/tutorials.mdx index 91bc57aad..b9bd36ff3 100644 --- a/pages/app-developers/tutorials.mdx +++ b/pages/app-developers/tutorials.mdx @@ -8,7 +8,7 @@ import { Card, Cards } from 'nextra/components' # Tutorials -This section provides information on bridging erc 20 tokens to op mainnet with viem, bridging eth to op mainnet with viem, communicating between op mainnet and ethereum in solidity, deploying your first contract on op mainnet, estimating transaction costs on op mainnet, tracing deposits and withdrawals, viewing deposits and withdrawals by address, triggering op mainnet transactions from ethereum, bridging your custom erc 20 token using the standard bridge and bridging your standard erc 20 token using the standard bridge. You'll find tutorial to help you understand and work with these topics. +This section provides information on bridging erc 20 tokens to op mainnet with viem, bridging eth to op mainnet with viem, communicating between op mainnet and ethereum in solidity, deploying your first contract on op mainnet, estimating transaction costs on op mainnet, tracing deposits and withdrawals, triggering op mainnet transactions from ethereum, bridging your custom erc 20 token using the standard bridge and bridging your standard erc 20 token using the standard bridge. You'll find tutorial to help you understand and work with these topics. @@ -16,7 +16,6 @@ This section provides information on bridging erc 20 tokens to op mainnet with v - diff --git a/pages/app-developers/tutorials/_meta.json b/pages/app-developers/tutorials/_meta.json index a1f44203f..ec07dcbf4 100644 --- a/pages/app-developers/tutorials/_meta.json +++ b/pages/app-developers/tutorials/_meta.json @@ -4,7 +4,6 @@ "cross-dom-bridge-erc20": "Bridging ERC-20 tokens with viem", "standard-bridge-custom-token": "Bridging your custom ERC-20 token to OP Mainnet", "standard-bridge-standard-token": "Bridging your standard ERC-20 token to OP Mainnet", - "sdk-view-txns": "Viewing deposits and withdrawals by address", "sdk-trace-txns": "Tracing deposits and withdrawals", "sdk-estimate-costs": "Estimating transaction costs", "send-tx-from-eth": "Triggering OP Mainnet transactions from Ethereum" diff --git a/pages/app-developers/tutorials/sdk-trace-txns.mdx b/pages/app-developers/tutorials/sdk-trace-txns.mdx index 0dfd8da99..3b16e237e 100644 --- a/pages/app-developers/tutorials/sdk-trace-txns.mdx +++ b/pages/app-developers/tutorials/sdk-trace-txns.mdx @@ -159,4 +159,3 @@ You can use viem's functions to trace a withdrawal. ## Next steps * Check out the tutorial on [bridging ERC-20 tokens with the Optimism SDK](./cross-dom-bridge-erc20) to learn how to create deposits and withdrawals. -* You can also check out the tutorial on [viewing deposits and withdrawals by address](./sdk-view-txns) to find deposits and withdrawals to trace. From 823812bfd8b4d562a0e8fa5259e4ce95ef793728 Mon Sep 17 00:00:00 2001 From: krofax Date: Mon, 10 Feb 2025 20:19:54 +0100 Subject: [PATCH 3/3] removed tutorial links --- pages/app-developers/tutorials.mdx | 1 - pages/app-developers/tutorials/transactions.mdx | 1 - pages/app-developers/tutorials/transactions/_meta.json | 1 - public/_redirects | 2 -- 4 files changed, 5 deletions(-) diff --git a/pages/app-developers/tutorials.mdx b/pages/app-developers/tutorials.mdx index 706f9d522..68c54bae8 100644 --- a/pages/app-developers/tutorials.mdx +++ b/pages/app-developers/tutorials.mdx @@ -24,7 +24,6 @@ If you're a bit more familiar with the OP Stack and Ethereum, you can try walkin } /> } /> - } /> } /> } /> diff --git a/pages/app-developers/tutorials/transactions.mdx b/pages/app-developers/tutorials/transactions.mdx index e87bc9928..d08e3de35 100644 --- a/pages/app-developers/tutorials/transactions.mdx +++ b/pages/app-developers/tutorials/transactions.mdx @@ -13,6 +13,5 @@ This is a collection of app developer tutorials focused on transactions. } /> } /> - } /> } /> diff --git a/pages/app-developers/tutorials/transactions/_meta.json b/pages/app-developers/tutorials/transactions/_meta.json index f07a50495..56184691a 100644 --- a/pages/app-developers/tutorials/transactions/_meta.json +++ b/pages/app-developers/tutorials/transactions/_meta.json @@ -1,5 +1,4 @@ { - "sdk-view-txns": "Viewing deposits and withdrawals by address", "sdk-trace-txns": "Tracing deposits and withdrawals", "sdk-estimate-costs": "Estimating transaction costs", "send-tx-from-eth": "Triggering OP Mainnet transactions from Ethereum" diff --git a/public/_redirects b/public/_redirects index 0b5932371..2c139b871 100644 --- a/public/_redirects +++ b/public/_redirects @@ -47,7 +47,6 @@ /builders/dapp-developers/tutorials/cross-dom-bridge-eth /app-developers/tutorials/bridging/cross-dom-bridge-eth /builders/dapp-developers/tutorials/cross-dom-bridge-erc20 /app-developers/tutorials/bridging/cross-dom-bridge-erc20 /builders/dapp-developers/tutorials/sdk-estimate-costs /app-developers/tutorials/transactions/sdk-estimate-costs -/builders/dapp-developers/tutorials/sdk-view-txns /app-developers/tutorials/transactions/sdk-view-txns /builders/dapp-developers/tutorials/sdk-trace-txns /app-developers/tutorials/transactions/sdk-trace-txns /builders/dapp-developers/tutorials/send-tx-from-eth /app-developers/tutorials/transactions/send-tx-from-eth /builders/dapp-developers/tutorials/cross-dom-solidity /app-developers/tutorials/bridging/cross-dom-solidity @@ -149,7 +148,6 @@ /app-developers/tutorials/cross-dom-bridge-eth /app-developers/tutorials/bridging/cross-dom-bridge-eth /app-developers/tutorials/cross-dom-bridge-erc20 /app-developers/tutorials/bridging/cross-dom-bridge-erc20 /app-developers/tutorials/sdk-estimate-costs /app-developers/tutorials/transactions/sdk-estimate-costs -/app-developers/tutorials/sdk-view-txns /app-developers/tutorials/transactions/sdk-view-txns /app-developers/tutorials/sdk-trace-txns /app-developers/tutorials/transactions/sdk-trace-txns /app-developers/tutorials/send-tx-from-eth /app-developers/tutorials/transactions/send-tx-from-eth /app-developers/tutorials/cross-dom-solidity /app-developers/tutorials/bridging/cross-dom-solidity