| 1 | import { addEnsContracts } from "@ensdomains/ensjs"; |
| 2 | import { createPublicClient, createWalletClient, http } from "viem"; |
| 3 | import { mainnet } from "viem/chains"; |
| 4 | import { privateKeyToAccount } from "viem/accounts"; |
| 5 | |
| 6 | export const ensClient = createPublicClient({ |
| 7 | chain: addEnsContracts(mainnet), |
| 8 | transport: http(process.env.ETH_RPC_URL || "https://eth.drpc.org"), |
| 9 | }); |
| 10 | |
| 11 | export async function walletClient() { |
| 12 | const privateKey = process.env.ATLAS_PRIVATE_KEY; |
| 13 | |
| 14 | if (!privateKey) { |
| 15 | return null; |
| 16 | } |
| 17 | |
| 18 | const account = privateKeyToAccount(privateKey as `0x${string}`); |
| 19 | |
| 20 | return createWalletClient({ |
| 21 | account, |
| 22 | chain: addEnsContracts(mainnet), |
| 23 | transport: http(process.env.ETH_RPC_URL || "https://eth.drpc.org"), |
| 24 | }); |
| 25 | } |