> ## Documentation Index
> Fetch the complete documentation index at: https://docs.rhinestone.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Bring your own account

> Attach an existing smart account to the Rhinestone SDK.

Use `initData` to attach a smart account created outside the current SDK instance. The account implementation, owner configuration, address, and deployment metadata must describe the same onchain account.

<Warning>
  This interface is experimental. Test the reconstructed address and signing path before using an existing account in production.
</Warning>

## Provide existing account metadata

For an account that may need deployment on another chain, supply its address, factory, factory calldata, and whether the Rhinestone Intent Executor was included in the original initialization:

```ts theme={null}
import { RhinestoneSDK } from '@rhinestone/sdk'
import type { Address, Hex } from 'viem'

const existingAccount: {
  address: Address
  factory: Address
  factoryData: Hex
} = await loadAccountDeploymentMetadata()

const rhinestone = new RhinestoneSDK({
  auth: {
    mode: 'apiKey',
    apiKey: process.env.RHINESTONE_API_KEY!,
  },
  bundler: {
    type: 'pimlico',
    apiKey: process.env.PIMLICO_API_KEY!,
  },
})

const account = await rhinestone.createAccount({
  account: { type: 'kernel', version: '3.3' },
  owners: {
    type: 'ecdsa',
    accounts: [owner],
    module: ownerValidatorAddress,
  },
  initData: {
    ...existingAccount,
    intentExecutorInstalled: false,
  },
})
```

Use the actual validator module installed on the account. Set `intentExecutorInstalled: true` only if you have verified that the original initialization installed the Rhinestone Intent Executor.

If the account is already deployed on every chain you will use and no factory data is needed, `initData: { address }` can pin the existing address.

## Reconstruct an SDK-created account

For an account originally derived by the current SDK family, let the experimental helper compute the metadata from the original configuration:

```ts theme={null}
import { experimental_getRhinestoneInitData } from '@rhinestone/sdk/utils'

const originalConfig = {
  account: { type: 'safe', version: '1.4.1' } as const,
  owners: { type: 'ecdsa', accounts: [owner] } as const,
}

const initData = experimental_getRhinestoneInitData(originalConfig)
const account = await rhinestone.createAccount({
  ...originalConfig,
  initData,
})
```

For a Rhinestone SDK v0 account, use `experimental_getV0InitData` from `@rhinestone/sdk/utils` with the account's original account, owner, module, and session configuration. Do not guess legacy module addresses.

## Deploy and set up each chain

For each chain you plan to use:

```ts theme={null}
if (!(await account.isDeployed(chain))) {
  await account.deploy(chain)
}

await account.setup(chain)
```

`deploy` deploys the account from its factory metadata. `setup` installs missing modules, including the Intent Executor when required. Existing-account deployment and setup can require ERC-4337, so configure a [bundler and optional paymaster](/wallets/custom-signer/configuration/erc-4337).

To sponsor intent fees after setup, follow [sponsorship setup](/transactions/sponsorship/set-up).
