Skip to content
Cive

deployContract

Deploys a contract to the network, given bytecode & constructor arguments.

import { Abi } from "./abi";
import { account, walletClient } from "./config";
 
const hash = await walletClient.deployContract({
  abi: Abi,
  account,
  bytecode: "0x608060405260405161083e38038061083e833981016040819052610...",
});

Deploying with Constructor Args

import { deployContract } from "cive";
import { Abi } from "./abi";
import { account, walletClient } from "./config";
 
const hash = await walletClient.deployContract({
  abi: Abi,
  account,
  args: [69420],
  bytecode: "0x608060405260405161083e38038061083e833981016040819052610...",
});

Returns

Hash

The Transaction hash.

abi

The contract's ABI.

import { privateKeyToAccount } from "cive/accounts";
export const account = privateKeyToAccount("0x...", {
  networkId: mainnet.id,
});
const hash = await walletClient.deployContract({
  abi: Abi, 
  account: account,
  bytecode: "0x608060405260405161083e38038061083e833981016040819052610...",
});

account

  • Type: Account

The Account to deploy the contract from.

Accepts Local Account (Private Key, etc).

import { privateKeyToAccount } from "cive/accounts";
export const account = privateKeyToAccount("0x...", {
  networkId: mainnet.id,
});
const hash = await walletClient.deployContract({
  abi: Abi,
  account: account, 
  bytecode: "0x608060405260405161083e38038061083e833981016040819052610...",
});

bytecode

The contract's bytecode.

import { privateKeyToAccount } from "cive/accounts";
export const account = privateKeyToAccount("0x...", {
  networkId: mainnet.id,
});
const hash = await walletClient.deployContract({
  abi: Abi,
  account: account,
  bytecode: "0x608060405260405161083e38038061083e833981016040819052610...", 
});

args

  • Type: Inferred from ABI.

Constructor arguments to call upon deployment.

import { privateKeyToAccount } from "cive/accounts";
export const account = privateKeyToAccount("0x...", {
  networkId: mainnet.id,
});
const hash = await walletClient.deployContract({
  abi: Abi,
  account: account,
  bytecode: "0x608060405260405161083e38038061083e833981016040819052610...",
  args: [69], 
});