# Deploy accounts on behalf of users

Ready allows dapps to deploy accounts on behalf of users, enhancing user experience by simplifying the onboarding process.

## Step 1: Install StarknetKit

You'll need [StarknetKit](broken://pages/JDEIa4GXFCVFIqOz9R9s)

* Version 2.2.7 or newer
* required in order to get the deployment data for an account
* can be installed with:

```javascript
pnpm add starknetkit
```

## Step 2: Retrieve the deployment data

Using this [SNIP](https://community.starknet.io/t/snip-deployment-interface-between-dapps-and-wallets/101923), your dapp can retrieve the deployment data required to deploy the user’s account.

When connecting with starknetkit, use the `wallet` object returned by `connect` .

If an account is already deployed, this will throw an exception (so it will need to be managed on client side)

```javascript
const { wallet, connectorData } = res; 
const deploymentData = await wallet.request({ 
type: "wallet_deploymentData",
 })
```

`deploymentData`  is an object of type:

```typescript
type DeployAccountContractPayload = {
    classHash: string;
    constructorCalldata?: RawArgs;
    addressSalt?: BigNumberish;
    contractAddress?: string;
};
```

## Step 3: Deploy on behalf of the user

Option 1: Now that you have the user's deployment data, you can deploy the account

Option 2: You can use AVNU’s paymaster feature to deploy the account at the same time as a paymaster transaction.  See [iteration flow](https://doc.avnu.fi/starknet-paymaster/guides-and-examples#interation-flow).

### Option 1 detailed workflow:&#x20;

1. Create a relayer in your code:

```typescript
const provider = new RpcProvider({
    nodeUrl: "https://free-rpc.nethermind.io/sepolia-juno/rpc/v0_7",
  });

  const relayer = new Account(
    provider,
    process.env.REACT_APP_ADDRESS,
    process.env.REACT_APP_PK
  );
```

2. Configure transaction params

```typescript
const fees = await account.estimateAccountDeployFee(deployPayload, {version: "0x03"});
const deployDetails = {
  maxFee: fees.suggestedMaxFee, 
  resourceBounds: fees.resourceBounds,
  version: "0x03",
};
```

3. Execute the deployment transaction using `account.deployContract`&#x20;

```typescript
const tx = await account.deployContract({
    unique: false,
    classHash: deployPayload.classHash,
    constructorCalldata: deployPayload.constructorCalldata,
    salt: deployPayload.addressSalt,
    }, deployDetails)  
```

That's it, the account contract should be deployed.&#x20;


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.ready.co/aa-use-cases/deploy-accounts-on-behalf-of-users.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
