-
Notifications
You must be signed in to change notification settings - Fork 265
Tracing Deposits and Withdrawals #966
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from 6 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
1537cff
updated tracing transaction tutorial
krofax be41dab
Added file imports
krofax 4afd50f
Added next steps
krofax f03401c
update text
krofax 665c798
Update sdk-trace-txns.js
krofax 4a5abc0
updated file imports
krofax ecee772
updated lint issues
krofax 048cd4e
fix link
krofax f72e490
fix lint issues
krofax ac46357
updated file
krofax 7e4600e
Update pages/builders/app-developers/tutorials/sdk-trace-txns.mdx
krofax 1043a5d
Update pages/builders/app-developers/tutorials/sdk-trace-txns.mdx
krofax 840fa60
updated codebase
krofax 7257426
merge conflict
krofax 32bb82d
updated codebase
krofax fee614a
fix merged conflict
krofax a7f27f5
updated word.txt
krofax 02bd64d
updated file import paths
krofax 36fea13
updated the RPC URL
krofax 3a0a9bb
fix conflict
krofax 400306c
resolve file import issue
krofax File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,61 @@ | ||
(async () => { | ||
|
||
const optimism = require("@eth-optimism/sdk") | ||
const ethers = require("ethers") | ||
const { createPublicClient, http } = require('viem'); | ||
krofax marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
// 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 | ||
const l1RpcUrl = process.env.L1_RPC_URL; | ||
const l2RpcUrl = process.env.L2_RPC_URL; | ||
|
||
// Docs CI wallet, will have deposits and withdrawals. | ||
const deposit = '0x5896d6e4a47b465e0d925723bab838c62ef53468139a5e9ba501efd70f90cccb' | ||
const withdrawal = '0x18b8b4022b8d9e380fd89417a2e897adadf31e4f41ca17442870bf89ad024f42' | ||
const depositHash = '0x5896d6e4a47b465e0d925723bab838c62ef53468139a5e9ba501efd70f90cccb' | ||
const withdrawalHash = '0x18b8b4022b8d9e380fd89417a2e897adadf31e4f41ca17442870bf89ad024f42' | ||
krofax marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
const l1Provider = new ethers.providers.StaticJsonRpcProvider(l1RpcUrl) | ||
const l2Provider = new ethers.providers.StaticJsonRpcProvider(l2RpcUrl) | ||
const l1Client = createPublicClient({ | ||
chain: optimism, | ||
krofax marked this conversation as resolved.
Show resolved
Hide resolved
|
||
transport: http(l1RpcUrl), | ||
}); | ||
|
||
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, | ||
}) | ||
|
||
const l2Client = createPublicClient({ | ||
chain: optimismSepolia, | ||
krofax marked this conversation as resolved.
Show resolved
Hide resolved
|
||
transport: http(l2RpcUrl), | ||
}); | ||
|
||
console.log('Grabbing deposit status...') | ||
const depositStatus = await messenger.getMessageStatus(deposit) | ||
console.log(depositStatus) | ||
const depositStatus = await l2Client.getTransactionReceipt({ hash: depositHash }); | ||
console.log(depositStatus); | ||
|
||
console.log('Grabbing deposit receipt...') | ||
const depositReceipt = await messenger.getMessageReceipt(deposit) | ||
console.log(depositReceipt) | ||
const depositReceipt = await l2Client.getTransaction({ hash: depositHash }); | ||
console.log(depositReceipt); | ||
|
||
const depositLogs = depositReceipt.logs; | ||
depositLogs.forEach(log => { | ||
console.log(log); | ||
}); | ||
|
||
console.log('Grabbing deposit txn...') | ||
const depositTx = await l2Provider.getTransaction(depositReceipt.transactionReceipt.transactionHash) | ||
console.log(depositTx) | ||
const depositTransaction = await l2Client.getTransaction({ hash: depositHash }); | ||
console.log(depositTransaction); | ||
krofax marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
console.log('Grabbing withdrawal status...') | ||
const withdrawalStatus = await messenger.getMessageStatus(withdrawal) | ||
console.log(withdrawalStatus) | ||
const withdrawalStatus = await l1Client.getTransactionReceipt({ hash: withdrawalHash }); | ||
console.log(withdrawalStatus); | ||
|
||
console.log('Grabbing withdrawal receipt...') | ||
const withdrawalReceipt = await messenger.getMessageReceipt(withdrawal) | ||
console.log(withdrawalReceipt) | ||
const withdrawalReceipt = await l1Client.getTransaction({ hash: withdrawalHash }); | ||
console.log(withdrawalReceipt); | ||
|
||
const withdrawalLogs = withdrawalReceipt.logs; | ||
withdrawalLogs.forEach(log => { | ||
console.log(log); | ||
}); | ||
|
||
console.log('Grabbing withdrawal txn...') | ||
const withdrawalTx = await l1Provider.getTransaction(withdrawalReceipt.transactionReceipt.transactionHash) | ||
console.log(withdrawalTx) | ||
const withdrawalTransaction = await l1Client.getTransaction({ hash: withdrawalHash }); | ||
console.log(withdrawalTransaction); | ||
|
||
})() |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.