Package Exports
- tempwallet-sdk
Readme
@tempwallet/sdk β v0.1.0
Ephemeral Wallet SDK for Ethereum & EVM chains
Create temporary, single-use wallets with built-in safety (TTL, one-time semantics, sweep helpers, Safe builders).
Designed for one-time payments, demo sessions, disposable accounts, and secure checkout flows.β‘ No servers. No custody. No contracts. Just pure client-side helpers.
π― Why TempWallet SDK?
Developers often struggle when building short-lived wallet flows for payments, access, or testing:
- β Reusing normal wallets is insecure (private key exposure, replay risks)
- β Building sweeps & gas buffers from scratch is error-prone
- β Safe integrations require verbose boilerplate
- β Permit2 / EIP-712 signing flows are tedious to set up
π TempWallet SDK solves this by giving you:
- πͺͺ Ephemeral wallets β single-use semantics with TTL enforcement
- β½ Gas helpers β estimate, add margin, and sweep correctly with safety buffers
- π Error-proof API β typed errors for expired or reused wallets
- π‘ Safe builders β ready-to-use payloads for Safe Core SDK
- π§Ή Sweep utilities β clean up leftover ETH after payments
- πͺ Permit2 skeletons β plug-and-play flows for token approvals
Built on ethers v6. Type-safe. Tree-shakeable. Zero infra required.
π¦ Installation
npm install @tempwallet/sdk ethersRequires:
ethersv6.13.0+ (peer dependency)
π Quick Start
One-Time ETH Checkout
import { createTempWallet, buildSweepTx } from "@tempwallet/sdk";
import { parseEther } from "ethers";
// 1. Create a temporary wallet
const wallet = createTempWallet({ ttl: 3600, label: "checkout-session-123" });
console.log("Ephemeral address:", wallet.address);
// 2. Send ETH payment
const txHash = await wallet.sendTransaction({
providerUrl: process.env.RPC_URL!,
to: "0xRecipient",
value: parseEther("0.1"),
});
console.log("Payment sent:", txHash);
// 3. Sweep leftover funds (optional)
const sweepTx = await buildSweepTx({
fromAddress: wallet.address,
to: "0xMainWallet",
providerUrl: process.env.RPC_URL!,
gasLimitBuffer: parseEther("0.001"),
});π API Overview
createTempWallet(opts?)
Creates an ephemeral wallet with TTL & one-time semantics.
const wallet = createTempWallet({ ttl: 1800, label: "demo" });wallet.sendTransaction(input)
Sends a transaction with single-use enforcement.
Throws:
ExpiredSessionErrorif TTL passedAlreadyUsedErrorif reused
buildSweepTx(input)
Builds a sweep transaction to move all ETH safely with gas buffer.
estimateTotalCostWei(input) / estimateWithMarginWei(input, marginBps)
Gas cost calculators with optional safety margin.
buildSafePayment(params) / buildSafeSweep(params)
Ready-to-use payloads for Safe Core SDK.
buildPaymentURI(address, wei?)
Generates EIP-681 payment URIs (ethereum:0x...).
π₯ Real Use Cases
Crypto Checkout
Accept ETH payments with ephemeral wallets that auto-expire & sweep.Demo / Sandbox Accounts
Let users play in your dApp without touching their main wallet.Disposable Session Keys
Issue one-time wallets for gated content or temporary access.Safe Transactions
Build Safe-compatible payment payloads in 1 line.Permit2 Token Flows
Generate typed skeletons for Permit2 signatures.
β οΈ Typed Errors
import { ExpiredSessionError, AlreadyUsedError } from "@tempwallet/sdk";
try {
await wallet.sendTransaction(tx);
} catch (err) {
if (err instanceof ExpiredSessionError) {
console.log("Wallet expired β create new one");
}
}| Error | Trigger |
|---|---|
ExpiredSessionError |
TTL exceeded |
AlreadyUsedError |
Wallet reused |
NoBalanceToSweepError |
No ETH to sweep |
InsufficientAfterBufferError |
Not enough balance after gas buffer |
π Security Best Practices
β
Generate keys only client-side
β
Use secure storage (memory/session only for TTL)
β
Always sweep leftovers
β
Enforce TTL (default 1h)
β Never reuse ephemeral wallets
β Donβt use in production without sweep fallback
πΊ Roadmap
- [π§] ERC-20 & ERC-721 sweep helpers
- Batch transaction builder
- Auto RPC gas estimator
- Multi-chain presets (Optimism, Base, Polygon, Arbitrum)
- Recovery flows (optional seed phrase support)
π€ Contributing
Contributions welcome!
Check CONTRIBUTING.md.
π License
MIT β see LICENSE
πΈ Support
If this SDK saved you time or you like the philosophy of zero infra helpers, feel free to send a tip β€οΈ:
ETH / USDC: 0x687848FC782Dc20edCa4b535f27fB4b1B398a305
π Links
Ephemeral wallet SDK, temporary Ethereum wallet, one-time crypto payments, secure ETH checkout, Safe transaction builder, Permit2 helper, sweep ETH balance, gas estimation utils, client-side EVM flows.