feat: Add examples for contract deployment and export new functions (#4533)
## Problem solved
Short description of the bug fixed or feature added
<!-- start pr-codex -->
---
## PR-Codex overview
This PR focuses on adding new types and functions related to deploy transactions and contracts in the `thirdweb` package.
### Detailed summary
- Added `DeployTransactionType` and `DeployTransactionResult` types
- Added `getRequiredTransactionCount` function
- Updated exports for deploy functions
- Updated examples and comments for deploying contracts
> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`
<!-- end pr-codex -->
This commit is contained in:
@@ -75,6 +75,9 @@ export function prepareDirectDeployTransaction(
|
||||
* @param options - the deploy options
|
||||
* @returns - a promise that resolves to the deployed contract address
|
||||
* @example
|
||||
*
|
||||
* ## Deploying a regular contract from ABI and bytecode
|
||||
*
|
||||
* ```ts
|
||||
* import { deployContract } from "thirdweb/deployContract";
|
||||
*
|
||||
@@ -87,7 +90,25 @@ export function prepareDirectDeployTransaction(
|
||||
* param1: "value1",
|
||||
* param2: 123,
|
||||
* },
|
||||
* salt, // passing salt enables deterministic deploys
|
||||
* salt, // optional: salt enables deterministic deploys
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* ## Deploying a contract deterministically
|
||||
*
|
||||
* ```ts
|
||||
* 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
|
||||
* });
|
||||
* ```
|
||||
* @extension DEPLOY
|
||||
|
||||
@@ -19,6 +19,17 @@ export {
|
||||
deployERC1155Contract,
|
||||
} from "../extensions/prebuilts/deploy-erc1155.js";
|
||||
|
||||
export {
|
||||
deploySplitContract,
|
||||
type SplitContractParams,
|
||||
type DeploySplitContractOptions,
|
||||
} from "../extensions/prebuilts/deploy-split.js";
|
||||
|
||||
export {
|
||||
deployMarketplaceContract,
|
||||
type MarketplaceContractParams,
|
||||
} from "../extensions/prebuilts/deploy-marketplace.js";
|
||||
|
||||
export {
|
||||
deployPublishedContract,
|
||||
type DeployPublishedContractOptions,
|
||||
@@ -35,8 +46,4 @@ export {
|
||||
type PrepareDirectDeployTransactionOptions,
|
||||
} from "../contract/deployment/deploy-with-abi.js";
|
||||
export { computePublishedContractAddress } from "../utils/any-evm/compute-published-contract-address.js";
|
||||
export {
|
||||
deploySplitContract,
|
||||
type SplitContractParams,
|
||||
type DeploySplitContractOptions,
|
||||
} from "../extensions/prebuilts/deploy-split.js";
|
||||
export { getRequiredTransactionCount } from "../extensions/prebuilts/get-required-transactions.js";
|
||||
|
||||
@@ -39,6 +39,9 @@ export type DeployPublishedContractOptions = {
|
||||
* @param options - the deploy options
|
||||
* @returns a promise that resolves to the deployed contract address
|
||||
* @example
|
||||
*
|
||||
* ## Deploying a published contract
|
||||
*
|
||||
* ```ts
|
||||
* import { deployPublishedContract } from "thirdweb/deploys";
|
||||
*
|
||||
@@ -47,8 +50,30 @@ export type DeployPublishedContractOptions = {
|
||||
* chain,
|
||||
* account,
|
||||
* contractId: "MyPublishedContract",
|
||||
* contractParams: [...],
|
||||
* contractParams: {
|
||||
* param1: "value1",
|
||||
* param2: 123,
|
||||
* },
|
||||
* publisher: "0x...", // optional, defaults to the thirdweb deployer
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* ## Deploying a published contract deterministically
|
||||
*
|
||||
* ```ts
|
||||
* import { deployPublishedContract } from "thirdweb/deploys";
|
||||
*
|
||||
* const address = await deployedPublishedContract({
|
||||
* client,
|
||||
* chain,
|
||||
* account,
|
||||
* contractId: "MyPublishedContract",
|
||||
* contractParams: {
|
||||
* param1: "value1",
|
||||
* param2: 123,
|
||||
* },
|
||||
* publisher: "0x...",
|
||||
* salt: "your-salt", // this will deterministically deploy the contract at the same address on all chains
|
||||
* });
|
||||
* ```
|
||||
* @extension DEPLOY
|
||||
|
||||
@@ -6,15 +6,26 @@ import { getDeployedInfraContractFromMetadata } from "../../contract/deployment/
|
||||
import { computePublishedContractAddress } from "../../utils/any-evm/compute-published-contract-address.js";
|
||||
import type { FetchDeployMetadataResult } from "../../utils/any-evm/deploy-metadata.js";
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export type DeployTransactionType =
|
||||
| "infra"
|
||||
| "implementation"
|
||||
| "module"
|
||||
| "proxy";
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export type DeployTransactionResult = {
|
||||
type: DeployTransactionType;
|
||||
contractId: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export async function getRequiredTransactionCount(options: {
|
||||
chain: Chain;
|
||||
client: ThirdwebClient;
|
||||
|
||||
Reference in New Issue
Block a user