PageSourceSearch

https://docs.hazbase.com/assets/HazbaseFactory-DRfqYeAY.js

js hazbase.com collected 2026-10-05 06:32:38 UTC 4,780 bytes, 33 lines download raw bytes

1import{b as o,j as e,C as r,L as n}from"./index-BAAzACLV.js";const c=`import { deployViaFactory, type DeployViaFactoryOptions } from '@hazbase/factory';
2import { getAddress, type Signer } from 'ethers';
3
4type CloneRequest = {
5  signer: Signer;
6  chainId: number;
7  factoryAddress: string;
8  implementationOwner: string;
9  contractType: string;
10  fnSignature: string;
11  fnArgs: readonly unknown[];
12};
13
14// Call only after the implementation and its initializer policy are registered.
15export async function createRegisteredClone(request: CloneRequest) {
16  if (!request.signer.provider) throw new Error('A connected signer is required.');
17  const network = await request.signer.provider.getNetwork();
18  if (network.chainId !== BigInt(request.chainId)) throw new Error('Chain mismatch.');
19
20  const options = {
21    signer: request.signer,
22    chainId: request.chainId,
23    factoryAddress: getAddress(request.factoryAddress),
24    implementationOwner: getAddress(request.implementationOwner),
25    contractType: request.contractType,
26    fnSignature: request.fnSignature,
27    fnArgs: request.fnArgs,
28  } satisfies DeployViaFactoryOptions;
29
30  const result = await deployViaFactory(options);
31  return { address: result.proxy, transactionHash: result.txHash, receipt: result.receipt };
32}
33`;function l(){const{i18n:a}=o(),t=(s,i)=>a.language.startsWith("en")?i:s;return e.jsxs("article",{className:"dev-page",children:[e.jsx("div",{className:"dev-eyebrow",children:"DEPLOYMENT / FACTORY"}),e.jsx("h1",{children:t("登録済みの実装から、コントラクトを作成する","Create a contract from a registered implementation")}),e.jsx("p",{className:"dev-lead",children:t("Factory SDKは、登録済みの実装から新しいコントラクトを作成します。実装の種類と初期化条件を指定し、アプリケーションからデプロイを実行できます。","The Factory SDK creates a contract from a registered implementation. Specify the implementation type and initialization settings to deploy from your application.")}),e.jsxs("div",{className:"dev-meta",children:[e.jsx("span",{children:"@hazbase/factory 0.2.1"}),e.jsx("span",{children:"ethers 6.16.0"}),e.jsx("span",{children:"TypeScript"})]}),e.jsxs("section",{children:[e.jsx("h2",{children:t("実行前の準備","Prerequisites")}),e.jsx("p",{children:t("対象チェーン上のFactory、登録済み実装の所有者と種類、初期化関数のシグネチャと引数、実行権限を持つSignerを用意します。型名と初期化条件は、そのFactoryに登録されたものを指定します。","Provide the target Factory, registered implementation owner and type, initializer signature and arguments, and an authorized signer. The type and initializer must match that Factory registration.")}),e.jsx(r,{language:"bash",code:"npm install --save-exact @hazbase/[email protected] [email protected]"}),e.jsx(n,{className:"dev-link",to:"/start/day0",children:t("サンプルアプリから始める","Start with the sample application")})]}),e.jsxs("section",{children:[e.jsx("h2",{children:t("アプリケーションから呼び出す","Call from your application")}),e.jsx("p",{children:t("接続済みのSignerと登録情報をこの関数に渡すと、初期化の呼び出しデータを生成し、Factory経由でコントラクトを作成できます。サンプルの接続先と引数は、ご利用の環境に合わせて指定してください。","Pass a connected signer and registration details to this function to encode initialization data and create a contract through Factory. Set the connection and arguments for your environment.")}),e.jsx(r,{language:"typescript",code:c,filename:"factory-clone.ts"}),e.jsx("a",{className:"dev-link",href:"/examples/factory-clone.ts",download:!0,children:t("コードをダウンロード","Download the code")})]}),e.jsxs("section",{children:[e.jsx("h2",{children:t("結果を確認する","Verify the result")}),e.jsx("p",{children:t("addressは作成したプロキシ、transactionHashは作成トランザクション、receiptは確定した実行結果です。初期化後の名称・管理者・上限なども読み取り、渡した条件との一致を確認できます。","address identifies the new proxy, transactionHash identifies its creation transaction, and receipt records the mined result. Read the initialized name, administrator and cap to verify they match the request.")}),e.jsx(n,{className:"dev-link",to:"/reference/sdk/factory?symbol=DeployViaFactoryOptions",children:"DeployViaFactoryOptions"}),e.jsx("br",{}),e.jsx(n,{className:"dev-link",to:"/reference/sdk/factory?symbol=deployViaFactory",children:t("引数・戻り値の正式な仕様","Parameters and return types")})]})]})}export{l as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.