deploySafe
Deploy a Safe smart wallet for a user using ERC-4337 account abstraction. Automatically checks if already deployed and updates user profile.
Signature
deploySafe(
userAddress: string,
chainId: SupportedChainId,
strategy?: Strategy,
createSessionKey?: boolean
): Promise<DeploySafeResponse>
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
userAddress | string | ✅ | User's EOA address |
chainId | SupportedChainId | ✅ | Target chain (8453, 42161, or 9745) |
strategy | Strategy | ❌ | Strategy selection: "conservative" (default) or "aggressive" |
createSessionKey | boolean | ❌ | If true, creates a session key immediately after deployment (default: false) |
Strategy Options:
"conservative"(default): Low-risk, stable yield strategy"aggressive": High-risk, high-reward strategy
Session Key: When createSessionKey is true, the session key is created in the same call, enabling automated yield optimization immediately. This saves an additional createSessionKey() call.
For changing the strategy after the wallet is deployed, see Updating Strategy After Deployment.
Returns
Deployment response with Safe address and transaction hash
Return Type
interface DeploySafeResponse {
success: boolean;
safeAddress: Address;
txHash: string;
status: "deployed" | "failed";
}
Examples
Deploy with Default Conservative Strategy
// Deploy with default conservative strategy
const result = await sdk.deploySafe("0xUser...", 42161);
if (result.success) {
console.log("Safe deployed at:", result.safeAddress);
console.log("Transaction:", result.txHash);
}
Deploy with Aggressive Strategy
// Deploy with aggressive strategy
const result = await sdk.deploySafe("0xUser...", 42161, "aggressive");
if (result.success) {
console.log("Safe deployed at:", result.safeAddress);
console.log("Transaction:", result.txHash);
}
Deploy with Session Key (Recommended)
// Deploy and create session key in one call
const result = await sdk.deploySafe("0xUser...", 8453, "conservative", true);
if (result.success) {
console.log("Safe deployed at:", result.safeAddress);
console.log("Session key created - ready for automated yield optimization!");
}