🔐1auth SDK Docs
Back to all components

createPasskeyWalletClient

Client

Create a viem-compatible WalletClient that uses passkeys for signing transactions.

import { createPasskeyWalletClient } from '@1auth/sdk'

Overview

createPasskeyWalletClient creates a viem-compatible WalletClient that uses passkeys for transaction signing. This allows you to use the 1auth SDK with existing viem-based applications.

Basic Usage

import { createPasskeyWalletClient } from '@1auth/sdk';
import { base } from 'viem/chains';

const walletClient = createPasskeyWalletClient({
  providerUrl: 'https://auth.example.com',
  clientId: 'my-dapp',
  username: 'user@example.com',
  chain: base,
});

// Use like any viem WalletClient
const hash = await walletClient.sendTransaction({
  to: '0x...',
  value: parseEther('0.1'),
});

Config Options

OptionTypeRequiredDescription
providerUrlstringYesURL of the 1auth provider
clientIdstringYesYour application's client ID
usernamestringYesThe authenticated user's username
chainChainYesThe viem chain object
transportTransportNoCustom viem transport

Viem Compatibility

The wallet client extends viem's WalletClient interface:

import { createPublicClient, http } from 'viem';
import { base } from 'viem/chains';

const publicClient = createPublicClient({
  chain: base,
  transport: http(),
});

const walletClient = createPasskeyWalletClient({
  providerUrl: 'https://auth.example.com',
  clientId: 'my-dapp',
  username: 'user@example.com',
  chain: base,
});

// Read + write operations
const balance = await publicClient.getBalance({ address: walletClient.account.address });
const hash = await walletClient.sendTransaction({ to: '0x...', value: balance / 2n });

Batch Transactions

Use sendCalls for batch transactions:

const results = await walletClient.sendCalls({
  calls: [
    { to: '0x...', data: '0x...' },
    { to: '0x...', data: '0x...' },
    { to: '0x...', data: '0x...' },
  ],
});

With wagmi

Use with wagmi's custom connector:

import { createConfig } from 'wagmi';
import { createPasskeyWalletClient } from '@1auth/sdk';

// Create a custom connector using the passkey wallet client
const config = createConfig({
  // ... wagmi config
});

Type Exports

import type {
  PasskeyWalletClient,
  PasskeyWalletClientConfig,
  TransactionCall,
  SendCallsParams,
} from '@1auth/sdk';

Account Address

The wallet client exposes the user's smart account address:

const walletClient = createPasskeyWalletClient({ ... });

console.log('Address:', walletClient.account.address);
// 0x... (user's smart account address)

Notes

  • The wallet client requires an authenticated user (username)
  • All transactions are signed using passkeys via the 1auth provider
  • Compatible with viem v2.x
  • Supports EIP-5792 batch calls via sendCalls