deployContract

Deploy a contract on a given chain

Example

Deploying a regular contract from ABI and bytecode

import { deployContract } from "thirdweb/deployContract";
const address = await deployContract({
client,
chain,
bytecode: "0x...",
abi: contractAbi,
constructorParams: {
param1: "value1",
param2: 123,
},
salt, // optional: salt enables deterministic deploys
});

Deploying a contract deterministically

import { deployContract } from "thirdweb/deployContract";
const address = await deployContract({
client,
chain,
bytecode: "0x...",
abi: contractAbi,
constructorParams: {
param1: "value1",
param2: 123,
},
salt, // passing a salt will enable deterministic deploys
});
function deployContract(
options: {
abi: Abi;
bytecode: `0x${string}`;
chain: Readonly<ChainOptions & { rpc: string }>;
client: ThirdwebClient;
constructorParams?: Record<string, unknown>;
} & { account: Account; salt?: string },
): Promise<string>;

Parameters

the deploy options

Type

let options: {
abi: Abi;
bytecode: `0x${string}`;
chain: Readonly<ChainOptions & { rpc: string }>;
client: ThirdwebClient;
constructorParams?: Record<string, unknown>;
} & { account: Account; salt?: string };

Returns

let returnType: Promise<string>;
  • a promise that resolves to the deployed contract address