[DOCS] Suggestion to Add Example for Custom Chains in [Bridging ETH to OP Mainnet with Viem-Supported Networks]
I suggest adding the following example to the Supported Networks section to help users more easily adapt it to their own custom chains.
By modifying the code below with the appropriate values for their own test networks, users can quickly configure and integrate their custom OP Stack chains.
const { defineChain } = require('viem');
const { chainConfig } = require('viem/op-stack')
const sourceId = 11_155_111 // sepolia
const optimismSepolia = /*#__PURE__*/ defineChain({
...chainConfig,
id: 11155420,
name: 'OP Sepolia',
nativeCurrency: { name: 'Sepolia Ether', symbol: 'ETH', decimals: 18 },
rpcUrls: {
default: {
http: ['https://sepolia.optimism.io'],
},
},
blockExplorers: {
default: {
name: 'Blockscout',
url: 'https://optimism-sepolia.blockscout.com',
apiUrl: 'https://optimism-sepolia.blockscout.com/api',
},
},
contracts: {
...chainConfig.contracts,
disputeGameFactory: {
[sourceId]: {
address: '0x05F9613aDB30026FFd634f38e5C4dFd30a197Fa1',
},
},
l2OutputOracle: {
[sourceId]: {
address: '0x90E9c4f8a994a250F6aEfd61CAFb4F2e895D458F',
},
},
multicall3: {
address: '0xca11bde05977b3631167028862be2a173976ca11',
blockCreated: 1620204,
},
portal: {
[sourceId]: {
address: '0x16Fc5058F25648194471939df75CF27A2fdC48BC',
},
},
l1StandardBridge: {
[sourceId]: {
address: '0xFBb0621E0B23b5478B630BD55a5f21f67730B0F1',
},
},
},
testnet: true,
sourceId,
})
This code is from the chains/definitions/optimismSepolia.ts file in the viem package, with slight modifications.
Hi @opfocus , thanks for this suggestion! I'll look into it early next week and get it implemented soon once approved!
I encountered an error while executing the following step,
Maybe publicClientL1.buildInitiateWithdrawal should be used here[tested].
I noticed that there seems to be no introduction to the buildWithdrawalTransaction function in the viem documentation
const withdrawalArgs = await publicClientL2.buildWithdrawalTransaction({
^
TypeError: publicClientL2.buildWithdrawalTransaction is not a function
at file:///D:/crosss-dom/index.js:20:45
at ModuleJob.run (node:internal/modules/esm/module_job:218:25)
at async ModuleLoader.import (node:internal/modules/esm/loader:329:24)
at async loadESM (node:internal/process/esm_loader:34:7)
at async handleMainPromise (node:internal/modules/run_main:113:12)
I encountered an error while executing the following step, Maybe
publicClientL1.buildInitiateWithdrawalshould be used here[tested]. I noticed that there seems to be no introduction to thebuildWithdrawalTransactionfunction in theviemdocumentationconst withdrawalArgs = await publicClientL2.buildWithdrawalTransaction({ ^ TypeError: publicClientL2.buildWithdrawalTransaction is not a function at file:///D:/crosss-dom/index.js:20:45 at ModuleJob.run (node:internal/modules/esm/module_job:218:25) at async ModuleLoader.import (node:internal/modules/esm/loader:329:24) at async loadESM (node:internal/process/esm_loader:34:7) at async handleMainPromise (node:internal/modules/run_main:113:12)
Hello @opfocus , thanks for pointing this, i'll look into this and update accordingly.
Updated this tutorial