Configuration
The createConfig function initializes a HumanWallet configuration object that's used by all other core functions.
Function Signature
function createConfig(params: CreateConfigParams): Config
interface CreateConfigParams {
projectId: string
chain: Chain
}Parameters
projectId
- Type:
string - Description: Your ZeroDev project ID for accessing bundler and paymaster services
- Example:
"your-project-id"
chain
- Type:
Chain(from viem) - Description: The blockchain network to connect to
- Example:
sepolia,mainnet,polygon, etc.
Usage Example
import { createConfig } from "@humanwallet/core"
import { sepolia, mainnet, polygon } from "viem/chains"
// Sepolia testnet configuration
const sepoliaConfig = createConfig({
projectId: "your-project-id",
chain: sepolia,
})
// Mainnet configuration
const mainnetConfig = createConfig({
projectId: "your-project-id",
chain: mainnet,
})
// Polygon configuration
const polygonConfig = createConfig({
projectId: "your-project-id",
chain: polygon,
})Return Value
The function returns a configuration object with the following properties:
interface Config {
bundlerTransport: Transport // HTTP transport for bundler
paymasterTransport: Transport // HTTP transport for paymaster
publicClient: PublicClient // Viem public client for reading
chain: Chain // The specified blockchain
passkeyUrl: string // Passkey service URL
}Getting Your Project Configuration
To use HumanWallet, you'll need:
- Project ID: Get your project ID from your ZeroDev account
- Choose Network: Decide which blockchain network you want to support
Supported Networks
HumanWallet supports all major EVM-compatible networks:
- Ethereum Mainnet:
mainnet - Ethereum Sepolia:
sepolia - Polygon:
polygon - Polygon Mumbai:
mumbai - Arbitrum:
arbitrum - Optimism:
optimism
Configuration Best Practices
Environment Variables
Store sensitive configuration in environment variables:
// .env
VITE_PROJECT_ID = your_project_id
// config.ts
import { sepolia } from "viem/chains"
const projectId = import.meta.env.VITE_PROJECT_ID
const config = createConfig({
projectId,
chain: sepolia,
})Multiple Environment Support
const getConfig = (environment: "development" | "production") => {
const projectId = environment === "development" ? process.env.VITE_DEV_PROJECT_ID : process.env.VITE_PROD_PROJECT_ID
const chain = environment === "development" ? sepolia : mainnet
return createConfig({
projectId,
chain,
})
}Troubleshooting
Common Issues
Invalid Project IDError: Request failed with status 401- Verify your project ID is correct
- Ensure you're using the right environment (development/production)
Error: Chain ID mismatch- Ensure the chain ID in your URLs matches the
chainparameter - Double-check the chain ID reference above
Error: Invalid URL- Ensure URLs follow the exact format:
https://[service].example.com/api/v3/[project-id]/chain/[chain-id] - Remove any trailing slashes from URLs