base / base/account-sdk

createSmartAccount returns undefined factoryData for undeployed accounts

Open
#377 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
172
Forks
207
Avg merge
49m
Merged PRs (30d)
1

Description

### Summary

`createSmartAccount().getFactoryArgs()` currently returns `{ factory, factoryData }` even when `factoryData` is `undefined`:

```ts
async getFactoryArgs() {
if (factoryData) return { factory: factory.address, factoryData };
// TODO: support creating factory data
return { factory: factory.address, factoryData };
}
```

The two branches return the same value, so the `if` does not protect the undeployed-account path.

### Why this matters

`getFactoryArgs()` is used by viem's smart-account flow when the account is not deployed. For EntryPoint v0.6, downstream preparation builds `initCode` only when both `factory` and `factoryData` are present. If `factoryData` is `undefined`, the SDK can silently produce no deployment init code for an undeployed sender, leading to a later bundler/EntryPoint failure such as an account-not-deployed simulation error.

### Why deriving factoryData locally is not trivial

The Coinbase Smart Account factory uses:

```solidity
createAccount(bytes[] owners, uint256 nonce)
```

`createSmartAccount()` currently receives a single `owner` and `ownerIndex`, not the full owner set and nonce required to derive canonical factory data safely. Guessing this locally could produce factory data for the wrong deterministic account address.

### Expected behavior

If `factoryData` is required but not provided, `getFactoryArgs()` should fail early with a clear SDK error rather than returning `{ factoryData: undefined }` and letting the error surface later in bundler simulation.

### Suggested minimal fix

Add regression coverage for `getFactoryArgs()` and throw a clear error when `factoryData` is missing. The existing behavior should remain unchanged when `factoryData` is provided.

Contributor guide

Open the contributing guide

Research direction

Start at createSmartAccount().getFactoryArgs() and trace the existing regression-test setup for smart-account factory arguments. Add coverage for an undeployed account without factoryData and verify that it fails with a clear SDK error, while supplied factoryData preserves the current return value.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
blockchain
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.