Deposits
This guide will demonstrate how to deposit (bridge) 1 Ether from Mainnet to Optimism (OP Mainnet).
Overview
Here is an end-to-end overview of how to execute a deposit transaction. We will break it down into Steps below.
import { getL2TransactionHashes } from 'viem/op-stack'
import { account, publicClientL1, publicClientL2, walletClientL1 } from './config'
// Build parameters for the transaction on the L2.
const request = await publicClientL2.buildDepositTransaction({
mint: parseEther('1')
to: account.address,
})
// Execute the deposit transaction on the L1.
const hash = await walletClientL1.depositTransacton(request)
// Wait for the L1 transaction to be processed.
const receipt = await publicClientL1.waitForTransactionReceipt({ hash })
// Get the L2 transaction hash from the L1 transaction receipt.
const [l2Hash] = getL2TransactionHashes(receipt)
// Wait for the L2 transaction to be processed.
const l2Receipt = await publicClientL2.waitForTransactionReceipt({
hash: l2Hash
})
import { getL2TransactionHashes } from 'viem/op-stack'
import { account, publicClientL1, publicClientL2, walletClientL1 } from './config'
// Build parameters for the transaction on the L2.
const request = await publicClientL2.buildDepositTransaction({
mint: parseEther('1')
to: account.address,
})
// Execute the deposit transaction on the L1.
const hash = await walletClientL1.depositTransacton(request)
// Wait for the L1 transaction to be processed.
const receipt = await publicClientL1.waitForTransactionReceipt({ hash })
// Get the L2 transaction hash from the L1 transaction receipt.
const [l2Hash] = getL2TransactionHashes(receipt)
// Wait for the L2 transaction to be processed.
const l2Receipt = await publicClientL2.waitForTransactionReceipt({
hash: l2Hash
})
import { createPublicClient, createWalletClient, custom, http } from 'viem'
import { mainnet, optimism } from 'viem/chains'
import { publicActionsL2, walletActionsL1 } from 'viem/op-stack'
// Retrieve Account from an EIP-1193 Provider.
export const [account] = await window.ethereum.request({
method: 'eth_requestAccounts'
})
export const publicClientL1 = createPublicClient({
chain: mainnet,
transport: http()
})
export const walletClientL1 = createWalletClient({
account,
chain: mainnet,
transport: custom(window.ethereum)
}).extend(walletActionsL1())
export const publicClientL2 = createPublicClient({
chain: optimism,
transport: http()
}).extend(publicActionsL2())
import { createPublicClient, createWalletClient, custom, http } from 'viem'
import { mainnet, optimism } from 'viem/chains'
import { publicActionsL2, walletActionsL1 } from 'viem/op-stack'
// Retrieve Account from an EIP-1193 Provider.
export const [account] = await window.ethereum.request({
method: 'eth_requestAccounts'
})
export const publicClientL1 = createPublicClient({
chain: mainnet,
transport: http()
})
export const walletClientL1 = createWalletClient({
account,
chain: mainnet,
transport: custom(window.ethereum)
}).extend(walletActionsL1())
export const publicClientL2 = createPublicClient({
chain: optimism,
transport: http()
}).extend(publicActionsL2())
import { createPublicClient, createWalletClient, http } from 'viem'
import { mainnet, optimism } from 'viem/chains'
import { publicActionsL2, walletActionsL1 } from 'viem/op-stack'
export const account = privateKeyToAccount('0x...')
export const publicClientL1 = createPublicClient({
chain: mainnet,
transport: http()
})
export const walletClientL1 = createWalletClient({
account,
chain: mainnet,
transport: http()
}).extend(walletActionsL1())
export const publicClientL2 = createPublicClient({
chain: optimism,
transport: http()
}).extend(publicActionsL2())
import { createPublicClient, createWalletClient, http } from 'viem'
import { mainnet, optimism } from 'viem/chains'
import { publicActionsL2, walletActionsL1 } from 'viem/op-stack'
export const account = privateKeyToAccount('0x...')
export const publicClientL1 = createPublicClient({
chain: mainnet,
transport: http()
})
export const walletClientL1 = createWalletClient({
account,
chain: mainnet,
transport: http()
}).extend(walletActionsL1())
export const publicClientL2 = createPublicClient({
chain: optimism,
transport: http()
}).extend(publicActionsL2())
Steps
1. Set up Viem Clients
First, we will set up our Viem Clients for the Mainnet and Optimism chains, including the necessary extensions for the OP Stack.
We will place these in a config.ts
file.
INFO
The example belows how to set up a Client for either a JSON-RPC Account (Browser Extension, WalletConnect, etc) or Local Account (Private Key)
// Import Viem modules.
import { createPublicClient, createWalletClient, custom, http } from 'viem'
import { mainnet, optimism } from 'viem/chains'
import { publicActionsL2, walletActionsL1 } from 'viem/op-stack'
// Retrieve Account from an EIP-1193 Provider.
export const [account] = await window.ethereum.request({
method: 'eth_requestAccounts'
})
export const publicClientL1 = createPublicClient({
chain: mainnet,
transport: http()
})
export const walletClientL1 = createWalletClient({
account,
chain: mainnet,
transport: custom(window.ethereum)
}).extend(walletActionsL1())
export const publicClientL2 = createPublicClient({
chain: optimism,
transport: http()
}).extend(publicActionsL2())
// Import Viem modules.
import { createPublicClient, createWalletClient, custom, http } from 'viem'
import { mainnet, optimism } from 'viem/chains'
import { publicActionsL2, walletActionsL1 } from 'viem/op-stack'
// Retrieve Account from an EIP-1193 Provider.
export const [account] = await window.ethereum.request({
method: 'eth_requestAccounts'
})
export const publicClientL1 = createPublicClient({
chain: mainnet,
transport: http()
})
export const walletClientL1 = createWalletClient({
account,
chain: mainnet,
transport: custom(window.ethereum)
}).extend(walletActionsL1())
export const publicClientL2 = createPublicClient({
chain: optimism,
transport: http()
}).extend(publicActionsL2())
// Import Viem modules.
import { createPublicClient, createWalletClient, http } from 'viem'
import { mainnet, optimism } from 'viem/chains'
import { publicActionsL2, walletActionsL1 } from 'viem/op-stack'
export const account = privateKeyToAccount('0x...')
export const publicClientL1 = createPublicClient({
chain: mainnet,
transport: http()
})
export const walletClientL1 = createWalletClient({
account,
chain: mainnet,
transport: http()
}).extend(walletActionsL1())
export const publicClientL2 = createPublicClient({
chain: optimism,
transport: http()
}).extend(publicActionsL2())
// Import Viem modules.
import { createPublicClient, createWalletClient, http } from 'viem'
import { mainnet, optimism } from 'viem/chains'
import { publicActionsL2, walletActionsL1 } from 'viem/op-stack'
export const account = privateKeyToAccount('0x...')
export const publicClientL1 = createPublicClient({
chain: mainnet,
transport: http()
})
export const walletClientL1 = createWalletClient({
account,
chain: mainnet,
transport: http()
}).extend(walletActionsL1())
export const publicClientL2 = createPublicClient({
chain: optimism,
transport: http()
}).extend(publicActionsL2())
2. Build the Deposit Transaction
Next, we will build the deposit transaction on the Optimism (L2) chain using the Clients that we created in the previous step.
In the example below, we want to deposit 1 Ether (via mint
) onto the Optimism chain, to ourselves (account.address
).
INFO
The mint
value is the value to deposit (mint) on the Optimism (L2) chain. It is debited from the account's Mainnet (L1) balance.
You can also use someone else's address as the to
value if you wanted to.
// Import Viem Clients.
import { publicClientL2 } from './config'
// Build parameters for the transaction on the L2.
const request = await publicClientL2.buildDepositTransaction({
mint: parseEther('1')
to: account.address,
})
// Import Viem Clients.
import { publicClientL2 } from './config'
// Build parameters for the transaction on the L2.
const request = await publicClientL2.buildDepositTransaction({
mint: parseEther('1')
to: account.address,
})
// Import Viem modules.
import { createPublicClient, createWalletClient, custom, http } from 'viem'
import { mainnet, optimism } from 'viem/chains'
import { publicActionsL2, walletActionsL1 } from 'viem/op-stack'
// Retrieve Account from an EIP-1193 Provider.
export const [account] = await window.ethereum.request({
method: 'eth_requestAccounts'
})
export const publicClientL1 = createPublicClient({
chain: mainnet,
transport: http()
})
export const walletClientL1 = createWalletClient({
account,
chain: mainnet,
transport: custom(window.ethereum)
}).extend(walletActionsL1())
export const publicClientL2 = createPublicClient({
chain: optimism,
transport: http()
}).extend(publicActionsL2())
// Import Viem modules.
import { createPublicClient, createWalletClient, custom, http } from 'viem'
import { mainnet, optimism } from 'viem/chains'
import { publicActionsL2, walletActionsL1 } from 'viem/op-stack'
// Retrieve Account from an EIP-1193 Provider.
export const [account] = await window.ethereum.request({
method: 'eth_requestAccounts'
})
export const publicClientL1 = createPublicClient({
chain: mainnet,
transport: http()
})
export const walletClientL1 = createWalletClient({
account,
chain: mainnet,
transport: custom(window.ethereum)
}).extend(walletActionsL1())
export const publicClientL2 = createPublicClient({
chain: optimism,
transport: http()
}).extend(publicActionsL2())
// Import Viem modules.
import { createPublicClient, createWalletClient, http } from 'viem'
import { mainnet, optimism } from 'viem/chains'
import { publicActionsL2, walletActionsL1 } from 'viem/op-stack'
export const account = privateKeyToAccount('0x...')
export const publicClientL1 = createPublicClient({
chain: mainnet,
transport: http()
})
export const walletClientL1 = createWalletClient({
account,
chain: mainnet,
transport: http()
}).extend(walletActionsL1())
export const publicClientL2 = createPublicClient({
chain: optimism,
transport: http()
}).extend(publicActionsL2())
// Import Viem modules.
import { createPublicClient, createWalletClient, http } from 'viem'
import { mainnet, optimism } from 'viem/chains'
import { publicActionsL2, walletActionsL1 } from 'viem/op-stack'
export const account = privateKeyToAccount('0x...')
export const publicClientL1 = createPublicClient({
chain: mainnet,
transport: http()
})
export const walletClientL1 = createWalletClient({
account,
chain: mainnet,
transport: http()
}).extend(walletActionsL1())
export const publicClientL2 = createPublicClient({
chain: optimism,
transport: http()
}).extend(publicActionsL2())
3. Execute the Deposit Transaction
After that, we will execute the deposit transaction on the Mainnet (L1) chain.
// Import Viem Clients.
import { account, publicClientL2, walletClientL1 } from './config'
// Build parameters for the transaction on the L2.
const request = await publicClientL2.buildDepositTransaction({
mint: parseEther('1')
to: account.address,
})
// Execute the deposit transaction on the L1.
const hash = await walletClientL1.depositTransacton(request)
// Import Viem Clients.
import { account, publicClientL2, walletClientL1 } from './config'
// Build parameters for the transaction on the L2.
const request = await publicClientL2.buildDepositTransaction({
mint: parseEther('1')
to: account.address,
})
// Execute the deposit transaction on the L1.
const hash = await walletClientL1.depositTransacton(request)
// Import Viem modules.
import { createPublicClient, createWalletClient, custom, http } from 'viem'
import { mainnet, optimism } from 'viem/chains'
import { publicActionsL2, walletActionsL1 } from 'viem/op-stack'
// Retrieve Account from an EIP-1193 Provider.
export const [account] = await window.ethereum.request({
method: 'eth_requestAccounts'
})
export const clientL1 = createClient({
account,
chain: mainnet,
transport: fallback([custom(window.ethereum), http()])
})
.extend(publicActions)
.extend(walletActionsL1())
export const clientL2 = createClient({
chain: optimism,
transport: http()
})
.extend(publicActions)
.extend(publicActionsL2())
// Import Viem modules.
import { createPublicClient, createWalletClient, custom, http } from 'viem'
import { mainnet, optimism } from 'viem/chains'
import { publicActionsL2, walletActionsL1 } from 'viem/op-stack'
// Retrieve Account from an EIP-1193 Provider.
export const [account] = await window.ethereum.request({
method: 'eth_requestAccounts'
})
export const clientL1 = createClient({
account,
chain: mainnet,
transport: fallback([custom(window.ethereum), http()])
})
.extend(publicActions)
.extend(walletActionsL1())
export const clientL2 = createClient({
chain: optimism,
transport: http()
})
.extend(publicActions)
.extend(publicActionsL2())
// Import Viem modules.
import { createPublicClient, createWalletClient, http } from 'viem'
import { mainnet, optimism } from 'viem/chains'
import { publicActionsL2, walletActionsL1 } from 'viem/op-stack'
export const account = privateKeyToAccount('0x...')
export const publicClientL1 = createPublicClient({
chain: mainnet,
transport: http()
})
export const walletClientL1 = createWalletClient({
account,
chain: mainnet,
transport: http()
}).extend(walletActionsL1())
export const publicClientL2 = createPublicClient({
chain: optimism,
transport: http()
}).extend(publicActionsL2())
// Import Viem modules.
import { createPublicClient, createWalletClient, http } from 'viem'
import { mainnet, optimism } from 'viem/chains'
import { publicActionsL2, walletActionsL1 } from 'viem/op-stack'
export const account = privateKeyToAccount('0x...')
export const publicClientL1 = createPublicClient({
chain: mainnet,
transport: http()
})
export const walletClientL1 = createWalletClient({
account,
chain: mainnet,
transport: http()
}).extend(walletActionsL1())
export const publicClientL2 = createPublicClient({
chain: optimism,
transport: http()
}).extend(publicActionsL2())
4. Wait for Transaction to be Processed
Once we have broadcast the transaction to the Mainnet (L1) chain, we need to wait for it to be processed on a block so we can extract the transaction receipt. We will need the transaction receipt to extract the transaction on the Optimism (L2) chain.
INFO
When the transaction has been processed, the mint
value (1 Ether) will be debited from the account's Mainnet (L1) balance.
// Import Viem Clients.
import {
account,
publicClientL1,
publicClientL2,
walletClientL1
} from './config'
// Build parameters for the transaction on the L2.
const request = await publicClientL2.buildDepositTransaction({
mint: parseEther('1')
to: account.address,
})
// Execute the deposit transaction on the L1.
const hash = await walletClientL1.depositTransacton(request)
// Wait for the L1 transaction to be processed.
const receipt = await publicClientL1.waitForTransactionReceipt({ hash })
// Import Viem Clients.
import {
account,
publicClientL1,
publicClientL2,
walletClientL1
} from './config'
// Build parameters for the transaction on the L2.
const request = await publicClientL2.buildDepositTransaction({
mint: parseEther('1')
to: account.address,
})
// Execute the deposit transaction on the L1.
const hash = await walletClientL1.depositTransacton(request)
// Wait for the L1 transaction to be processed.
const receipt = await publicClientL1.waitForTransactionReceipt({ hash })
// Import Viem modules.
import { createPublicClient, createWalletClient, custom, http } from 'viem'
import { mainnet, optimism } from 'viem/chains'
import { publicActionsL2, walletActionsL1 } from 'viem/op-stack'
// Retrieve Account from an EIP-1193 Provider.
export const [account] = await window.ethereum.request({
method: 'eth_requestAccounts'
})
export const clientL1 = createClient({
account,
chain: mainnet,
transport: fallback([custom(window.ethereum), http()])
})
.extend(publicActions)
.extend(walletActionsL1())
export const clientL2 = createClient({
chain: optimism,
transport: http()
})
.extend(publicActions)
.extend(publicActionsL2())
// Import Viem modules.
import { createPublicClient, createWalletClient, custom, http } from 'viem'
import { mainnet, optimism } from 'viem/chains'
import { publicActionsL2, walletActionsL1 } from 'viem/op-stack'
// Retrieve Account from an EIP-1193 Provider.
export const [account] = await window.ethereum.request({
method: 'eth_requestAccounts'
})
export const clientL1 = createClient({
account,
chain: mainnet,
transport: fallback([custom(window.ethereum), http()])
})
.extend(publicActions)
.extend(walletActionsL1())
export const clientL2 = createClient({
chain: optimism,
transport: http()
})
.extend(publicActions)
.extend(publicActionsL2())
// Import Viem modules.
import { createPublicClient, createWalletClient, http } from 'viem'
import { mainnet, optimism } from 'viem/chains'
import { publicActionsL2, walletActionsL1 } from 'viem/op-stack'
export const account = privateKeyToAccount('0x...')
export const publicClientL1 = createPublicClient({
chain: mainnet,
transport: http()
})
export const walletClientL1 = createWalletClient({
account,
chain: mainnet,
transport: http()
}).extend(walletActionsL1())
export const publicClientL2 = createPublicClient({
chain: optimism,
transport: http()
}).extend(publicActionsL2())
// Import Viem modules.
import { createPublicClient, createWalletClient, http } from 'viem'
import { mainnet, optimism } from 'viem/chains'
import { publicActionsL2, walletActionsL1 } from 'viem/op-stack'
export const account = privateKeyToAccount('0x...')
export const publicClientL1 = createPublicClient({
chain: mainnet,
transport: http()
})
export const walletClientL1 = createWalletClient({
account,
chain: mainnet,
transport: http()
}).extend(walletActionsL1())
export const publicClientL2 = createPublicClient({
chain: optimism,
transport: http()
}).extend(publicActionsL2())
5. Compute the L2 Transaction Hash
Once we have the transaction receipt from the Mainnet (L1) chain, we can extract the Optimism (L2) transaction hash from the logs in the transaction receipt.
// Import Viem Clients.
import {
account,
publicClientL1,
publicClientL2,
walletClientL1
} from './config'
// Build parameters for the transaction on the L2.
const request = await publicClientL2.buildDepositTransaction({
mint: parseEther('1')
to: account.address,
})
// Execute the deposit transaction on the L1.
const hash = await walletClientL1.depositTransacton(request)
// Wait for the L1 transaction to be processed.
const receipt = await publicClientL1.waitForTransactionReceipt({ hash })
// Get the L2 transaction hash from the L1 transaction receipt.
const [l2Hash] = getL2TransactionHashes(receipt)
// Import Viem Clients.
import {
account,
publicClientL1,
publicClientL2,
walletClientL1
} from './config'
// Build parameters for the transaction on the L2.
const request = await publicClientL2.buildDepositTransaction({
mint: parseEther('1')
to: account.address,
})
// Execute the deposit transaction on the L1.
const hash = await walletClientL1.depositTransacton(request)
// Wait for the L1 transaction to be processed.
const receipt = await publicClientL1.waitForTransactionReceipt({ hash })
// Get the L2 transaction hash from the L1 transaction receipt.
const [l2Hash] = getL2TransactionHashes(receipt)
// Import Viem modules.
import { createPublicClient, createWalletClient, custom, http } from 'viem'
import { mainnet, optimism } from 'viem/chains'
import { publicActionsL2, walletActionsL1 } from 'viem/op-stack'
// Retrieve Account from an EIP-1193 Provider.
export const [account] = await window.ethereum.request({
method: 'eth_requestAccounts'
})
export const clientL1 = createClient({
account,
chain: mainnet,
transport: fallback([custom(window.ethereum), http()])
})
.extend(publicActions)
.extend(walletActionsL1())
export const clientL2 = createClient({
chain: optimism,
transport: http()
})
.extend(publicActions)
.extend(publicActionsL2())
// Import Viem modules.
import { createPublicClient, createWalletClient, custom, http } from 'viem'
import { mainnet, optimism } from 'viem/chains'
import { publicActionsL2, walletActionsL1 } from 'viem/op-stack'
// Retrieve Account from an EIP-1193 Provider.
export const [account] = await window.ethereum.request({
method: 'eth_requestAccounts'
})
export const clientL1 = createClient({
account,
chain: mainnet,
transport: fallback([custom(window.ethereum), http()])
})
.extend(publicActions)
.extend(walletActionsL1())
export const clientL2 = createClient({
chain: optimism,
transport: http()
})
.extend(publicActions)
.extend(publicActionsL2())
// Import Viem modules.
import { createPublicClient, createWalletClient, http } from 'viem'
import { mainnet, optimism } from 'viem/chains'
import { publicActionsL2, walletActionsL1 } from 'viem/op-stack'
export const account = privateKeyToAccount('0x...')
export const publicClientL1 = createPublicClient({
chain: mainnet,
transport: http()
})
export const walletClientL1 = createWalletClient({
account,
chain: mainnet,
transport: http()
}).extend(walletActionsL1())
export const publicClientL2 = createPublicClient({
chain: optimism,
transport: http()
}).extend(publicActionsL2())
// Import Viem modules.
import { createPublicClient, createWalletClient, http } from 'viem'
import { mainnet, optimism } from 'viem/chains'
import { publicActionsL2, walletActionsL1 } from 'viem/op-stack'
export const account = privateKeyToAccount('0x...')
export const publicClientL1 = createPublicClient({
chain: mainnet,
transport: http()
})
export const walletClientL1 = createWalletClient({
account,
chain: mainnet,
transport: http()
}).extend(walletActionsL1())
export const publicClientL2 = createPublicClient({
chain: optimism,
transport: http()
}).extend(publicActionsL2())
6. Wait for Transaction to be Processed
Now that we have the Optimism (L2) transaction hash, we can wait for the transaction to be processed on the Optimism (L2) chain.
Once the waitForTransactionReceipt
call resolves, the transaction has been processed and you should now be credited with 1 Ether on the Optimism (L2) chain 🥳.
// Import Viem Clients.
import {
account,
publicClientL1,
publicClientL2,
walletClientL1
} from './config'
// Build parameters for the transaction on the L2.
const request = await publicClientL2.buildDepositTransaction({
mint: parseEther('1')
to: account.address,
})
// Execute the deposit transaction on the L1.
const hash = await walletClientL1.depositTransacton(request)
// Wait for the L1 transaction to be processed.
const receipt = await publicClientL1.waitForTransactionReceipt({ hash })
// Get the L2 transaction hash from the L1 transaction receipt.
const [l2Hash] = getL2TransactionHashes(receipt)
// Wait for the L2 transaction to be processed.
const l2Receipt = await publicClientL2.waitForTransactionReceipt({
hash: l2Hash
})
// Import Viem Clients.
import {
account,
publicClientL1,
publicClientL2,
walletClientL1
} from './config'
// Build parameters for the transaction on the L2.
const request = await publicClientL2.buildDepositTransaction({
mint: parseEther('1')
to: account.address,
})
// Execute the deposit transaction on the L1.
const hash = await walletClientL1.depositTransacton(request)
// Wait for the L1 transaction to be processed.
const receipt = await publicClientL1.waitForTransactionReceipt({ hash })
// Get the L2 transaction hash from the L1 transaction receipt.
const [l2Hash] = getL2TransactionHashes(receipt)
// Wait for the L2 transaction to be processed.
const l2Receipt = await publicClientL2.waitForTransactionReceipt({
hash: l2Hash
})
// Import Viem modules.
import { createPublicClient, createWalletClient, custom, http } from 'viem'
import { mainnet, optimism } from 'viem/chains'
import { publicActionsL2, walletActionsL1 } from 'viem/op-stack'
// Retrieve Account from an EIP-1193 Provider.
export const [account] = await window.ethereum.request({
method: 'eth_requestAccounts'
})
export const clientL1 = createClient({
account,
chain: mainnet,
transport: fallback([custom(window.ethereum), http()])
})
.extend(publicActions)
.extend(walletActionsL1())
export const clientL2 = createClient({
chain: optimism,
transport: http()
})
.extend(publicActions)
.extend(publicActionsL2())
// Import Viem modules.
import { createPublicClient, createWalletClient, custom, http } from 'viem'
import { mainnet, optimism } from 'viem/chains'
import { publicActionsL2, walletActionsL1 } from 'viem/op-stack'
// Retrieve Account from an EIP-1193 Provider.
export const [account] = await window.ethereum.request({
method: 'eth_requestAccounts'
})
export const clientL1 = createClient({
account,
chain: mainnet,
transport: fallback([custom(window.ethereum), http()])
})
.extend(publicActions)
.extend(walletActionsL1())
export const clientL2 = createClient({
chain: optimism,
transport: http()
})
.extend(publicActions)
.extend(publicActionsL2())
// Import Viem modules.
import { createPublicClient, createWalletClient, http } from 'viem'
import { mainnet, optimism } from 'viem/chains'
import { publicActionsL2, walletActionsL1 } from 'viem/op-stack'
export const account = privateKeyToAccount('0x...')
export const publicClientL1 = createPublicClient({
chain: mainnet,
transport: http()
})
export const walletClientL1 = createWalletClient({
account,
chain: mainnet,
transport: http()
}).extend(walletActionsL1())
export const publicClientL2 = createPublicClient({
chain: optimism,
transport: http()
}).extend(publicActionsL2())
// Import Viem modules.
import { createPublicClient, createWalletClient, http } from 'viem'
import { mainnet, optimism } from 'viem/chains'
import { publicActionsL2, walletActionsL1 } from 'viem/op-stack'
export const account = privateKeyToAccount('0x...')
export const publicClientL1 = createPublicClient({
chain: mainnet,
transport: http()
})
export const walletClientL1 = createWalletClient({
account,
chain: mainnet,
transport: http()
}).extend(walletActionsL1())
export const publicClientL2 = createPublicClient({
chain: optimism,
transport: http()
}).extend(publicActionsL2())