createPasskeyWalletClient
ClientCreate 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
| Option | Type | Required | Description |
|---|---|---|---|
providerUrl | string | Yes | URL of the 1auth provider |
clientId | string | Yes | Your application's client ID |
username | string | Yes | The authenticated user's username |
chain | Chain | Yes | The viem chain object |
transport | Transport | No | Custom 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