|
| 1 | +# permissionless |
| 2 | + |
| 3 | +> **Version 0.3.5** | TypeScript SDK for ERC-4337 Account Abstraction, built on [viem](https://viem.sh) |
| 4 | +
|
| 5 | +`permissionless` is a utility library for working with ERC-4337 smart accounts, bundlers, and paymasters. It extends viem's account abstraction primitives with support for 12 smart account implementations, multiple bundler providers, ERC-7579 modular accounts, and EIP-7702 delegation. |
| 6 | + |
| 7 | +## Peer Dependencies |
| 8 | + |
| 9 | +| Package | Version | Required | |
| 10 | +|---------|---------|----------| |
| 11 | +| `viem` | `^2.44.4` | Yes | |
| 12 | +| `ox` | `^0.11.3` | No (optional, for WebAuthn/passkey features) | |
| 13 | + |
| 14 | +## Install |
| 15 | + |
| 16 | +```bash |
| 17 | +npm install permissionless viem |
| 18 | +``` |
| 19 | + |
| 20 | +## Quick Start |
| 21 | + |
| 22 | +```typescript |
| 23 | +import { createPublicClient, http } from "viem" |
| 24 | +import { sepolia } from "viem/chains" |
| 25 | +import { privateKeyToAccount } from "viem/accounts" |
| 26 | +import { toSimpleSmartAccount } from "permissionless/accounts" |
| 27 | +import { createSmartAccountClient } from "permissionless" |
| 28 | + |
| 29 | +// 1. Create an owner (the EOA that controls the smart account) |
| 30 | +const owner = privateKeyToAccount("0x...") |
| 31 | + |
| 32 | +// 2. Create a public client for on-chain reads |
| 33 | +const publicClient = createPublicClient({ |
| 34 | + chain: sepolia, |
| 35 | + transport: http("https://rpc.sepolia.org"), |
| 36 | +}) |
| 37 | + |
| 38 | +// 3. Create the smart account (computes counterfactual address) |
| 39 | +const account = await toSimpleSmartAccount({ |
| 40 | + client: publicClient, |
| 41 | + owner, |
| 42 | +}) |
| 43 | + |
| 44 | +// 4. Create a smart account client (wraps a bundler) |
| 45 | +const smartAccountClient = createSmartAccountClient({ |
| 46 | + account, |
| 47 | + chain: sepolia, |
| 48 | + bundlerTransport: http("https://bundler.example.com"), |
| 49 | +}) |
| 50 | + |
| 51 | +// 5. Send a transaction (creates, signs, and submits a UserOperation) |
| 52 | +const txHash = await smartAccountClient.sendTransaction({ |
| 53 | + to: "0xd8da6bf26964af9d7eed9e03e53415d37aa96045", |
| 54 | + value: 0n, |
| 55 | + data: "0x", |
| 56 | +}) |
| 57 | +``` |
| 58 | + |
| 59 | +## Documentation |
| 60 | + |
| 61 | +### Architecture |
| 62 | + |
| 63 | +- [Package Overview](./architecture/01-overview.md) -- module hierarchy, viem integration, decorator pattern |
| 64 | +- [Export Map](./architecture/02-export-map.md) -- complete inventory of every subpath export and symbol |
| 65 | +- [Build System](./architecture/03-build-system.md) -- TypeScript compilation, output formats, tooling |
| 66 | + |
| 67 | +### ERC-4337 Concepts |
| 68 | + |
| 69 | +- [ERC-4337 Overview](./concepts/01-erc4337-overview.md) -- primitives mapped to library abstractions |
| 70 | +- [EntryPoint Versions](./concepts/02-entrypoint-versions.md) -- 0.6 vs 0.7 vs 0.8 comparison |
| 71 | +- [Smart Account Lifecycle](./concepts/03-smart-account-lifecycle.md) -- end-to-end UserOperation flow |
| 72 | +- [EIP-7702 Delegation](./concepts/04-eip-7702.md) -- EOA code delegation support |
| 73 | + |
| 74 | +### Smart Accounts |
| 75 | + |
| 76 | +- [Accounts Overview](./accounts/README.md) -- common patterns, parameter reference, summary table |
| 77 | +- [SimpleSmartAccount](./accounts/simple-smart-account.md) |
| 78 | +- [SimpleSmartAccount (EIP-7702)](./accounts/simple-smart-account-7702.md) |
| 79 | +- [SafeSmartAccount](./accounts/safe-smart-account.md) |
| 80 | +- [KernelSmartAccount](./accounts/kernel-smart-account.md) |
| 81 | +- [EcdsaKernelSmartAccount](./accounts/ecdsa-kernel-smart-account.md) |
| 82 | +- [KernelSmartAccount (EIP-7702)](./accounts/kernel-smart-account-7702.md) |
| 83 | +- [LightSmartAccount](./accounts/light-smart-account.md) |
| 84 | +- [BiconomySmartAccount](./accounts/biconomy-smart-account.md) |
| 85 | +- [TrustSmartAccount](./accounts/trust-smart-account.md) |
| 86 | +- [EtherspotSmartAccount](./accounts/etherspot-smart-account.md) |
| 87 | +- [NexusSmartAccount](./accounts/nexus-smart-account.md) |
| 88 | +- [ThirdwebSmartAccount](./accounts/thirdweb-smart-account.md) |
| 89 | + |
| 90 | +### Clients |
| 91 | + |
| 92 | +- [Clients Overview](./clients/README.md) -- client types, decorator pattern |
| 93 | +- [SmartAccountClient](./clients/smart-account-client.md) -- `createSmartAccountClient` |
| 94 | +- [PimlicoClient](./clients/pimlico-client.md) -- `createPimlicoClient` + `pimlicoActions` |
| 95 | +- [PasskeyServerClient](./clients/passkey-server-client.md) -- `createPasskeyServerClient` |
| 96 | + |
| 97 | +### Actions |
| 98 | + |
| 99 | +- [Actions Overview](./actions/README.md) -- action system, standalone vs decorator usage |
| 100 | +- [Public Actions](./actions/public-actions.md) -- `getAccountNonce`, `getSenderAddress` |
| 101 | +- [Smart Account Actions](./actions/smart-account-actions.md) -- `sendTransaction`, `sendCalls`, `signMessage`, `signTypedData`, `writeContract` |
| 102 | +- [Pimlico Actions](./actions/pimlico-actions.md) -- gas price, sponsorship, token quotes |
| 103 | +- [ERC-7579 Actions](./actions/erc7579-actions.md) -- module install/uninstall/query |
| 104 | +- [Etherspot Actions](./actions/etherspot-actions.md) -- Etherspot bundler actions |
| 105 | +- [Passkey Server Actions](./actions/passkey-server-actions.md) -- WebAuthn registration/authentication |
| 106 | + |
| 107 | +### Utilities |
| 108 | + |
| 109 | +- [Utils Overview](./utils/README.md) -- utility categories |
| 110 | +- [Nonce Utils](./utils/nonce-utils.md) -- `encodeNonce`, `decodeNonce` |
| 111 | +- [UserOperation Utils](./utils/user-operation-utils.md) -- `getPackedUserOperation`, `getRequiredPrefund`, `deepHexlify` |
| 112 | +- [ERC-7579 Utils](./utils/erc7579-utils.md) -- `encode7579Calls`, `decode7579Calls`, `encodeInstallModule` |
| 113 | +- [ERC-20 Utils](./utils/erc20-utils.md) -- `erc20AllowanceOverride`, `erc20BalanceOverride` |
| 114 | +- [Account Utils](./utils/account-utils.md) -- `isSmartAccountDeployed`, `toOwner` |
| 115 | + |
| 116 | +### Types & Errors |
| 117 | + |
| 118 | +- [Types & Errors Overview](./types-and-errors/README.md) |
| 119 | +- [Errors](./types-and-errors/errors.md) -- `AccountNotFoundError`, `InvalidEntryPointError` |
| 120 | +- [RPC Schemas](./types-and-errors/rpc-schemas.md) -- `PimlicoRpcSchema`, `EtherspotBundlerRpcSchema` |
| 121 | + |
| 122 | +### Experimental |
| 123 | + |
| 124 | +- [Experimental Overview](./experimental/README.md) -- stability warning |
| 125 | +- [ERC-20 Paymaster](./experimental/erc20-paymaster.md) -- `prepareUserOperationForErc20Paymaster` |
| 126 | + |
| 127 | +### Testing |
| 128 | + |
| 129 | +- [Testing Infrastructure](./testing/01-architecture.md) -- existing test docs (6 files) |
| 130 | + |
| 131 | +## External Resources |
| 132 | + |
| 133 | +- [Pimlico Documentation](https://docs.pimlico.io/permissionless) -- hosted user guides and tutorials |
| 134 | +- [GitHub Repository](https://github.com/pimlicolabs/permissionless.js) |
| 135 | +- [viem Documentation](https://viem.sh) |
| 136 | +- [ERC-4337 Specification](https://eips.ethereum.org/EIPS/eip-4337) |
0 commit comments