Skip to main content

@faremeter/wallet-evm

@faremeter/wallet-evm turns a raw EVM private key into a wallet compatible with @faremeter/payment-evm. It wraps viem primitives to expose typed signing helpers while validating inputs using @faremeter/types/evm.

Quick start

import { createLocalWallet } from "@faremeter/wallet-evm";
import { baseMainnet } from "./chains";
import { createPaymentHandler } from "@faremeter/payment-evm/exact";

const wallet = await createLocalWallet(baseMainnet, process.env.PRIVATE_KEY!);
const handler = createPaymentHandler(wallet);

API surface

createLocalWallet(chain, privateKey)

Returns a Promise<EvmWallet>:
  • chain: ChainInfo (id, rpcUrls) describing the target network.
  • privateKey: must be a 0x-prefixed 64-character hex string. The function throws early if validation fails.
The resulting wallet object contains:
  • chain: the same ChainInfo you passed in.
  • address: normalized Hex account address.
  • account: viem privateKeyToAccount(privateKey) result (exposes signTypedData, etc.).
  • client: viem WalletClient bound to the chain’s default RPC URL.
This shape matches the expectations of @faremeter/payment-evm/exact.createPaymentHandler and other viem-based utilities.

Usage patterns

  • Custom transports: After constructing the wallet you can replace wallet.client with a client built using your own transport (e.g., WebSocket) if needed.
  • Ledger support: For hardware-backed accounts use @faremeter/wallet-ledger.createLedgerEvmWallet, which returns an object with the same shape.
  • Network registry: Keep a central list of ChainInfo objects (chain id, name, RPC URL) and reuse them across wallets and facilitators to stay consistent.
  • @faremeter/payment-evm: consumes the wallet to sign EIP-3009 authorizations.
  • @faremeter/types/evm: provides the ChainInfo type and validation helpers used internally.
  • Source: GitHub › packages/wallet-evm