<VersionWarning version="0.1" />

# deployContract

deploys a contract to the network from a smart account, given bytecode & constructor arguments.

:::info
This action is only supported by some smart account types.
:::

## Usage

:::code-group
```ts [example.ts]
import { smartAccountClient, simpleSmartAccount } from "./smartAccountClient"
import { parseAbiItem, encodeFunctionData } from "viem"
import { pimlicoBundlerClient } from "./bundlerClient"
import { abi } from "./abi"

const hash = await smartAccountClient.deployContract({
    abi,
    bytecode: "0x606060405260008060146101..."
})
```

```ts [abi.ts]
export const abi = [
  ...
  {
    inputs: [],
    stateMutability: "nonpayable",
    type: "constructor",
  },
  ...
] as const;
```

```ts [smartAccountClient.ts]
import { ENTRYPOINT_ADDRESS_V07, createSmartAccountClient } from "permissionless"
import { privateKeyToSimpleSmartAccount } from "permissionless/accounts"
import { createPimlicoPaymasterClient } from "permissionless/clients/pimlico"
import { createPublicClient, http } from "viem"
import { sepolia } from "viem/chains"

export const publicClient = createPublicClient({
	transport: http("https://sepolia.rpc.thirdweb.com"),
})

// if using a paymaster
const paymasterClient = createPimlicoPaymasterClient({
	transport: http("https://api.pimlico.io/v2/sepolia/rpc?apikey=YOUR_PIMLICO_API_KEY"),
	entryPoint: ENTRYPOINT_ADDRESS_V07,
})

export const simpleSmartAccount = await privateKeyToSimpleSmartAccount(publicClient, {
	privateKey: "0xPRIVATE_KEY",
	factoryAddress: "0x91E60e0613810449d098b0b5Ec8b51A0FE8c8985", // simple version
	entryPoint: ENTRYPOINT_ADDRESS_V07,
})

export const smartAccountClient = createSmartAccountClient({
	account: simpleSmartAccount,
	entryPoint: ENTRYPOINT_ADDRESS_V07,
	chain: sepolia, // or whatever chain you are using
	bundlerTransport: http("https://api.pimlico.io/v2/sepolia/rpc?apikey=YOUR_PIMLICO_API_KEY"),
	middleware: {
		sponsorUserOperation: paymasterClient.sponsorUserOperation, // if using a paymaster
	},
})
```

```ts [bundlerClient.ts]
import { ENTRYPOINT_ADDRESS_V07, bundlerActions } from "permissionless"
import { pimlicoBundlerActions } from "permissionless/actions/pimlico"
import { createClient, http } from "viem"
import { sepolia } from "viem/chains"

export const pimlicoBundlerClient = createClient({
	chain: sepolia,
	transport: http("https://api.pimlico.io/v2/sepolia/rpc?apikey=YOUR_API_KEY_HERE"),
})
	.extend(bundlerActions(ENTRYPOINT_ADDRESS_V07))
	.extend(pimlicoBundlerActions(ENTRYPOINT_ADDRESS_V07))
```
:::

## Returns

* **Type:** `Hash`

The transaction hash of the mined userOperation

## Parameters

### abi

* **Type:** `Abi`

The contract's ABI.

### bytecode

* **Type:** `Hex`

The contract's bytecode.

### args (if required)

* **Type:** Inferred from ABI.

Constructor arguments to call upon deployment.

### account (optional)

* **Type:** `SmartAccount`

The Account to deploy the contract from.
