部署合约
使用 deployContract() 将新的智能合约部署到任何支持的链上。Engine 支持基于模板的部署(ERC-20、ERC-721、ERC-1155、marketplace、staking、governance)和自定义字节码部署。
方法签名
client.deployContract(params: ContractDeployParams): Promise<ApiResponse<ContractDeployResult>>
ContractDeployParams
import type { ContractDeployParams, ContractType } from '@one_deploy/sdk';
interface ContractDeployParams {
type: ContractType; // 模板类型或 'custom'
chainId: number; // 目标链
name: string; // 人类可读的合约名称
constructorArgs?: Record<string, unknown>; // 命名的构造函数参数
bytecode?: string; // type 为 'custom' 时必填
abi?: Record<string, unknown>[]; // type 为 'custom' 时必填
metadata?: Record<string, unknown>; // Engine 存储的可选元数据
}
ContractType
ContractType 枚举决定 Engine 使用哪个模板:
type ContractType =
| 'erc20' // 同质化代币 (ERC-20)
| 'erc721' // 非同质化代币 (ERC-721)
| 'erc1155' // 多代币标准 (ERC-1155)
| 'custom' // 自定义字节码 -- 自行提供
| 'marketplace' // NFT 市场合约
| 'staking' // 代币质押 / 奖励分发
| 'governance'; // 链上治理(投票 + 提案)
ContractDeployResult
interface ContractDeployResult {
transactionHash: string;
contractAddress: string; // 预测地址(可能等待确认中)
chainId: number;
status: 'pending' | 'submitted';
}
备注
contractAddress 是确定性计算的,会立即返回。在部署交易确认之前,合约不可使用。请轮询 getTransactionStatus() 来确认。