github.com/ethereum-optimism/optimism@v1.7.2/packages/sdk/test-next/testUtils/viemClients.ts (about)

     1  import {
     2    createTestClient,
     3    createPublicClient,
     4    createWalletClient,
     5    http,
     6  } from 'viem'
     7  import { goerli, optimismGoerli } from 'viem/chains'
     8  
     9  // we should instead use .env to determine chain so we can support alternate l1/l2 pairs
    10  const L1_CHAIN = goerli
    11  const L2_CHAIN = optimismGoerli
    12  const L1_RPC_URL = 'http://localhost:8545'
    13  const L2_RPC_URL = 'http://localhost:9545'
    14  
    15  const l1TestClient = createTestClient({
    16    mode: 'anvil',
    17    chain: L1_CHAIN,
    18    transport: http(L1_RPC_URL),
    19  })
    20  
    21  const l2TestClient = createTestClient({
    22    mode: 'anvil',
    23    chain: L2_CHAIN,
    24    transport: http(L2_RPC_URL),
    25  })
    26  
    27  const l1PublicClient = createPublicClient({
    28    chain: L1_CHAIN,
    29    transport: http(L1_RPC_URL),
    30  })
    31  
    32  const l2PublicClient = createPublicClient({
    33    chain: L2_CHAIN,
    34    transport: http(L2_RPC_URL),
    35  })
    36  
    37  const l1WalletClient = createWalletClient({
    38    chain: L1_CHAIN,
    39    transport: http(L1_RPC_URL),
    40  })
    41  
    42  const l2WalletClient = createWalletClient({
    43    chain: L2_CHAIN,
    44    transport: http(L2_RPC_URL),
    45  })
    46  
    47  export {
    48    l1TestClient,
    49    l2TestClient,
    50    l1PublicClient,
    51    l2PublicClient,
    52    l1WalletClient,
    53    l2WalletClient,
    54  }