Skip to content
Core SDK

Create a wallet

Create anonymous or username-addressable wallets with an allowlisted authenticator.

Create with a username

typescript
const created = await leaf.createWalletForUsername({
  username: "fern-labs",
  authenticatorAddr,
  authConfig,
});

console.log(created.wallet);
console.log(created.keyVault);
console.log(created.mnemonic); // show once, then remove from memory

Normalize usernames consistently before registration and lookup. The factory stores a username hash, not the plaintext username.

Build authenticator config

typescript
import { ethers } from "ethers";

const passwordHash = ethers.keccak256(
  ethers.toUtf8Bytes(password),
);

const authConfig = ethers.AbiCoder.defaultAbiCoder().encode(
  ["bytes32"],
  [passwordHash],
);

Creation gas

An EOA must pay wallet-creation gas. Production relayers need rate limits, funding alerts, abuse controls, and a policy for who may create wallets.