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

# deployContract

> Function to deploy a smart contract from the connected Abstract Global Wallet.

The [AbstractClient](/abstract-global-wallet/agw-client/createAbstractClient)
includes a `deployContract` method that can be used to deploy a smart contract from the connected Abstract Global Wallet.
It extends the [deployContract](https://viem.sh/zksync/actions/deployContract) function from Viem to include options for
[contract deployment on Abstract](/how-abstract-works/evm-differences/contract-deployment).

## Usage

```tsx theme={null}
import { useAbstractClient } from "@abstract-foundation/agw-react";
import { erc20Abi } from "viem"; // example abi
import { abstractTestnet } from "viem/chains";

export default function DeployContract() {
    const { data: agwClient } = useAbstractClient();

    async function deployContract() {
        if (!agwClient) return;

        const hash = await agwClient.deployContract({
            abi: erc20Abi, // Your smart contract ABI
            account: agwClient.account,
            bytecode: "0x...", // Your smart contract bytecode
            chain: abstractTestnet,
            args: [], // Constructor arguments
        });
    }
}

```

## Parameters

<ResponseField name="abi" type="Abi" required>
  The ABI of the contract to deploy.
</ResponseField>

<ResponseField name="bytecode" type="string" required>
  The bytecode of the contract to deploy.
</ResponseField>

<ResponseField name="account" type="Account" required>
  The account to deploy the contract from. Use the `account` from the
  [AbstractClient](/abstract-global-wallet/agw-client/createAbstractClient) to
  use the Abstract Global Wallet.
</ResponseField>

<ResponseField name="chain" type="Chain" required>
  The chain to deploy the contract on. e.g. `abstractTestnet`.
</ResponseField>

<ResponseField name="args" type="Inferred from ABI">
  Constructor arguments to call upon deployment.

  <Expandable title="Example">
    ```tsx theme={null}
    import { deployContract } from "@abstract-foundation/agw-client";
    import { contractAbi, contractBytecode } from "./const";
    import { agwClient } from "./config";
    import { abstractTestnet } from "viem/chains";

    const hash = await deployContract({
      abi: contractAbi,
      bytecode: contractBytecode,
      chain: abstractTestnet,
      account: agwClient.account,
      args: [123, "0x1234567890123456789012345678901234567890", true],
    });
    ```
  </Expandable>
</ResponseField>

<ResponseField name="deploymentType" type="'create' | 'create2' | 'createAccount' | 'create2Account'">
  Specifies the type of contract deployment. Defaults to `create`.

  * `'create'`: Deploys the contract using the `CREATE` opcode.
  * `'create2'`: Deploys the contract using the `CREATE2` opcode.
  * `'createAccount'`: Deploys a [smart contract wallet](/how-abstract-works/native-account-abstraction/smart-contract-wallets)
    using the [ContractDeployer](/how-abstract-works/system-contracts/list-of-system-contracts#contractdeployer)’s
    `createAccount` function.
  * `'create2Account'`: Deploys a [smart contract wallet](/how-abstract-works/native-account-abstraction/smart-contract-wallets)
    using the [ContractDeployer](/how-abstract-works/system-contracts/list-of-system-contracts#contractdeployer)’s
    `create2Account` function.
</ResponseField>

<ResponseField name="factoryDeps" type="Hex[]">
  An array of bytecodes of contracts that are dependencies for the contract
  being deployed. This is used for deploying contracts that depend on other
  contracts that are not yet deployed on the network.

  Learn more on the [Contract deployment page](/how-abstract-works/evm-differences/contract-deployment).

  <Expandable title="Example">
    ```tsx theme={null}
    import { contractAbi, contractBytecode } from "./const";
    import { agwClient } from "./config";
    import { abstractTestnet } from "viem/chains";

    const hash = await agwClient.deployContract({
      abi: contractAbi,
      bytecode: contractBytecode,
      chain: abstractTestnet,
      account: agwClient.account,
      factoryDeps: ["0x123", "0x456"],
    });
    ```
  </Expandable>
</ResponseField>

<ResponseField name="salt" type="Hash">
  Specifies a unique identifier for the contract deployment.
</ResponseField>

<ResponseField name="gasPerPubdata" type="bigint">
  The amount of gas to pay per byte of data on Ethereum.
</ResponseField>

<ResponseField name="paymaster" type="Account | Address">
  Address of the
  [paymaster](/how-abstract-works/native-account-abstraction/paymasters) smart
  contract that will pay the gas fees of the deployment transaction.

  Must also provide a `paymasterInput` field.
</ResponseField>

<ResponseField name="paymasterInput" type="Hex">
  Input data to the **paymaster**.

  Must also provide a `paymaster` field.

  <Expandable title="Example">
    ```tsx theme={null}
    import { contractAbi, contractBytecode } from "./const";
    import { agwClient } from "./config";
    import { abstractTestnet } from "viem/chains";
    import { getGeneralPaymasterInput } from "viem/zksync";

    const hash = await agwClient.deployContract({
      abi: contractAbi,
      bytecode: contractBytecode,
      chain: abstractTestnet,
      account: agwClient.account,
      paymaster: "0x5407B5040dec3D339A9247f3654E59EEccbb6391",
      paymasterInput: getGeneralPaymasterInput({
        innerInput: "0x",
      }),
    });
    ```
  </Expandable>
</ResponseField>

## Returns

Returns the `Hex` hash of the transaction that deployed the contract.

Use [waitForTransactionReceipt](https://viem.sh/docs/actions/public/waitForTransactionReceipt) to get the transaction receipt from the hash.
