Skip to main content
The EVMWallet class extends the base Wallet class with EVM-specific functionality including raw transactions, message signing, and typed data signing.

Creating an EVM Wallet

from()

Create an EVMWallet instance from a base Wallet.
static from(wallet: Wallet<Chain>): EVMWallet
wallet
Wallet<Chain>
required
A wallet instance with an EVM address
evmWallet
EVMWallet
An EVMWallet instance with EVM-specific methods

Example

import { EVMWallet } from "@crossmint/wallets";

const wallet = await wallets.getOrCreateWallet({
  chain: "ethereum",
  signer: { type: "evm-keypair", privateKey: "0x..." }
});

const evmWallet = EVMWallet.from(wallet);

Transaction Methods

sendTransaction()

Send a raw EVM transaction. Supports three formats: raw transaction, ABI call, or encoded data.
public async sendTransaction<T extends EVMTransactionInput>(
  params: T
): Promise<Transaction<T["options"] extends PrepareOnly<true> ? true : false>>
params
EVMTransactionInput
required
Transaction parameters (multiple formats supported)
transaction
Transaction
The transaction result

Examples

import { parseEther } from "viem";

// Example 1: Send native ETH
const tx1 = await evmWallet.sendTransaction({
  to: "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb",
  value: parseEther("0.1"),
  data: "0x"
});

console.log("Transaction:", tx1.hash);

// Example 2: Call contract function with ABI
const erc20Abi = [
  {
    name: "transfer",
    type: "function",
    inputs: [
      { name: "to", type: "address" },
      { name: "amount", type: "uint256" }
    ],
    outputs: [{ name: "success", type: "bool" }]
  }
];

const tx2 = await evmWallet.sendTransaction({
  to: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC contract
  abi: erc20Abi,
  functionName: "transfer",
  args: [
    "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb",
    BigInt(1000000) // 1 USDC (6 decimals)
  ]
});

// Example 3: Send with encoded data
const tx3 = await evmWallet.sendTransaction({
  to: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
  data: "0xa9059cbb...", // Pre-encoded function call
  value: 0n
});

// Example 4: Prepare only (don't auto-approve)
const tx4 = await evmWallet.sendTransaction({
  to: "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb",
  value: parseEther("0.1"),
  data: "0x",
  options: { experimental_prepareOnly: true }
});

console.log("Transaction ID:", tx4.transactionId);
// Later: await evmWallet.approve({ transactionId: tx4.transactionId });

Signing Methods

signMessage()

Sign a message with the wallet’s private key (EIP-191 personal sign).
public async signMessage<T extends SignMessageInput>(
  params: T
): Promise<Signature<T["options"] extends PrepareOnly<true> ? true : false>>
params
SignMessageInput
required
signature
Signature
The signature result

Example

// Sign a message
const sig = await evmWallet.signMessage({
  message: "Hello, Web3!"
});

console.log("Signature:", sig.signature);
console.log("Signature ID:", sig.signatureId);

// Prepare only (don't auto-approve)
const sig2 = await evmWallet.signMessage({
  message: "Hello, Web3!",
  options: { experimental_prepareOnly: true }
});

console.log("Signature ID:", sig2.signatureId);
// Later: await evmWallet.approve({ signatureId: sig2.signatureId });

signTypedData()

Sign EIP-712 typed data for structured data signing.
public async signTypedData<T extends SignTypedDataInput>(
  params: T
): Promise<Signature<T["options"] extends PrepareOnly<true> ? true : false>>
params
SignTypedDataInput
required
signature
Signature
The signature result

Example

// EIP-712 typed data example
const signature = await evmWallet.signTypedData({
  domain: {
    name: "MyDapp",
    version: "1",
    chainId: 1,
    verifyingContract: "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb"
  },
  types: {
    Person: [
      { name: "name", type: "string" },
      { name: "wallet", type: "address" }
    ],
    Mail: [
      { name: "from", type: "Person" },
      { name: "to", type: "Person" },
      { name: "contents", type: "string" }
    ]
  },
  primaryType: "Mail",
  message: {
    from: {
      name: "Alice",
      wallet: "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb"
    },
    to: {
      name: "Bob",
      wallet: "0x8626f6940E2eb28930eFb4CeF49B2d1F2C9C1199"
    },
    contents: "Hello, Bob!"
  },
  chain: "ethereum"
});

console.log("Typed data signature:", signature.signature);

Utilities

getViemClient()

Get a Viem public client instance configured for this wallet’s chain.
public getViemClient(params?: {
  transport?: HttpTransport;
}): PublicClient
params
object
client
PublicClient
A Viem public client for reading blockchain data

Example

import { http } from "viem";

// Get default client
const client = evmWallet.getViemClient();

// Get block number
const blockNumber = await client.getBlockNumber();
console.log("Block number:", blockNumber);

// With custom transport
const customClient = evmWallet.getViemClient({
  transport: http("https://eth-mainnet.alchemyapi.io/v2/your-api-key")
});

// Read contract
const balance = await customClient.readContract({
  address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
  abi: erc20Abi,
  functionName: "balanceOf",
  args: [evmWallet.address]
});

Inherited Methods

EVMWallet inherits all methods from the base Wallet class:
  • balances() - Get token balances
  • send() - Send tokens
  • approve() - Approve transactions/signatures
  • addDelegatedSigner() - Add delegated signers
  • delegatedSigners() - List delegated signers
  • stagingFund() - Fund wallet (staging only)
  • All experimental methods

Build docs developers (and LLMs) love