# partner:verify-module-deployment — Ammora SDK 0.3.9

Derive child pins from a trusted factory's canonical deployment, using public RPC only.

[Read in Docs](https://docs.ammora.org/examples?command=partner%3Averify-module-deployment) · [Detailed guide](https://docs.ammora.org/guides/self-service) · [Local setup](https://docs.ammora.org/guides/example-setup) · [Approval and review boundaries](https://docs.ammora.org/guides/permissions)

## Context and execution

GIWA Sepolia 91342. Public SDK 0.3.9, Math 0.3.0. Source revision: `0f3a73158fa5d86ed9f24ae1b2320e351e0e91e6`.
Install the SDK in your app, or prepare the example project using the local setup guide for its npm commands. Review the entry source and guide for required arguments, roles and deployment selection. `AMMORA_SEND=0` does not turn send-only commands into previews. Never put CLI keys in a browser or resend an uncertain transaction.

Command: `npm run partner:verify-module-deployment -- <arguments from the source below>` (`tsx src/partner/self-service/deployment-pin.ts`). Omit `--` and arguments when the source accepts none.

## Entry file: `src/partner/self-service/deployment-pin.ts`

```typescript
/** Derive child pins from a trusted factory's canonical deployment, using public RPC only. */
import { readFileSync } from "node:fs";
import { createPublicClient, http, keccak256, parseEventLogs, type PublicClient } from "viem";
import { EXTENSION_FACTORY_ABI, EXTENSION_VAULT_ABI } from "@ammora-protocol/sdk/partner";
import { address, hash, cli, required, loadSelfServiceProfile, type SelfServiceProfile } from "./context.js";
import { parseSelfServiceModulePin } from "./extension.js";
const same = (a: string, b: string) => a.toLowerCase() === b.toLowerCase();
const requireThat = (condition: unknown, message: string): void => { if (!condition) throw new Error(message); };
export async function readSelfServiceDeploymentPin(profile: SelfServiceProfile, client: PublicClient, input: unknown) {
  if (!input || typeof input !== "object" || Array.isArray(input)) throw new Error("Expected known deployment identities");
  const p = input as Record<string, unknown>;
  if (Object.keys(p).sort().join() !== "configurationHash,module,transactionHash,vault") throw new Error("Only transactionHash/configurationHash/module/vault are accepted; this is receipt-only authority");
  const transactionHash = hash(p.transactionHash), configurationHash = hash(p.configurationHash), module = address(p.module), vault = address(p.vault);
  requireThat(await client.getChainId() === profile.chainId, "Wrong chain");
  requireThat(same((await client.getBlock({ blockNumber: 0n })).hash, profile.genesisHash), "Wrong genesis");
  const receipt = await client.getTransactionReceipt({ hash: transactionHash });
  requireThat(same(receipt.transactionHash, transactionHash), "Receipt does not match the known hash");
  requireThat(receipt.status === "success" && !receipt.logs.some(l => l.removed), "Not a successful observed deployment; reconcile this known hash, never automatically resend");
  requireThat(same((await client.getBlock({ blockNumber: receipt.blockNumber })).hash, receipt.blockHash), "Receipt is not canonical");
  requireThat((await client.getBlock()).number >= receipt.blockNumber + 12n, "Need13 observed confirmations; wait without resending");
  const factoryCode = await client.getBytecode({ address: profile.factory.address, blockNumber: receipt.blockNumber });
  requireThat(factoryCode && same(keccak256(factoryCode), profile.factory.runtimeHash), "Untrusted factory runtime");
  const created = parseEventLogs({ abi: EXTENSION_FACTORY_ABI, eventName: "Created", logs: receipt.logs, strict: true }).filter(e => same(e.address, profile.factory.address));
  const event = created[0]; if (created.length !== 1 || !event) throw new Error("Expected exactly one trusted factory Created event");
  requireThat(same(event.args.configurationHash, configurationHash) && same(event.args.module, module) && same(event.args.vault, vault), "Created identities differ from your known plan");
  const recorded = await client.readContract({ address: profile.factory.address, abi: EXTENSION_FACTORY_ABI, functionName: "deployment", args: [configurationHash], blockNumber: receipt.blockNumber });
  const moduleCode = await client.getBytecode({ address: module, blockNumber: receipt.blockNumber }), vaultCode = await client.getBytecode({ address: vault, blockNumber: receipt.blockNumber });
  if (!moduleCode || !vaultCode || moduleCode === "0x" || vaultCode === "0x") throw new Error("Missing child runtime");
  const moduleHash = keccak256(moduleCode), vaultHash = keccak256(vaultCode);
  requireThat(same(recorded[0], module) && same(recorded[1], moduleHash) && same(event.args.runtimeHash, moduleHash), "Factory mapping/event/runtime disagree");
  requireThat(same(await client.readContract({ address: vault, abi: EXTENSION_VAULT_ABI, functionName: "creditor", blockNumber: receipt.blockNumber }), module), "Vault creditor is not the created module");
  requireThat(same((await client.getBlock({ blockNumber: receipt.blockNumber })).hash, receipt.blockHash), "Canonical block changed during verification");
  return { pin: parseSelfServiceModulePin({ address: module, runtimeHash: moduleHash, vault: { address: vault, runtimeHash: vaultHash } }), transactionHash, configurationHash, blockNumber: receipt.blockNumber, blockHash: receipt.blockHash, observedConfirmationsAtLeast: 13, finalizedStatusClaimed: false, automaticSend: false, activationOrPayoutVerified: false };
}
cli(import.meta.url, async () => {
  const profile = loadSelfServiceProfile(required(2, "profile.json")), input = JSON.parse(readFileSync(required(3, "known-deployment.json"), "utf8"));
  const client = createPublicClient({ cacheTime: 0, transport: http("https://sepolia-rpc.giwa.io", { retryCount: 0, timeout: 30000 }) });
  return (await readSelfServiceDeploymentPin(profile, client, input)).pin;
});
```

## Supporting files

Keep relative paths intact. Local imports are listed recursively; JSON templates are choices to review, not approved inputs. Runtime-selected files and wallet/environment setup still follow the detailed guide.

- [src/partner/self-service/context.ts](https://docs.ammora.org/examples/source/src/partner/self-service/context.ts.txt)
- [src/partner/self-service/extension.ts](https://docs.ammora.org/examples/source/src/partner/self-service/extension.ts.txt)
- [src/partner/self-service/rpc.ts](https://docs.ammora.org/examples/source/src/partner/self-service/rpc.ts.txt)
- [fixtures/self-service-configuration-input.template.json](https://docs.ammora.org/examples/source/fixtures/self-service-configuration-input.template.json.txt)
- [fixtures/self-service-giwa.test.json](https://docs.ammora.org/examples/source/fixtures/self-service-giwa.test.json.txt)
- [fixtures/self-service-known-deployment.template.json](https://docs.ammora.org/examples/source/fixtures/self-service-known-deployment.template.json.txt)
- [fixtures/self-service-source-input.template.json](https://docs.ammora.org/examples/source/fixtures/self-service-source-input.template.json.txt)
- [fixtures/self-service-standard-terms.test.json](https://docs.ammora.org/examples/source/fixtures/self-service-standard-terms.test.json.txt)
- [fixtures/self-service-test-artifacts.json](https://docs.ammora.org/examples/source/fixtures/self-service-test-artifacts.json.txt)
- [fixtures/self-service-trade-input.template.json](https://docs.ammora.org/examples/source/fixtures/self-service-trade-input.template.json.txt)
- [package.json](https://docs.ammora.org/examples/source/package.json.txt)
- [package-lock.json](https://docs.ammora.org/examples/source/package-lock.json.txt)
- [tsconfig.json](https://docs.ammora.org/examples/source/tsconfig.json.txt)
- [.env.giwa.example](https://docs.ammora.org/examples/source/file.env.giwa.example.txt)
- [.nvmrc](https://docs.ammora.org/examples/source/file.nvmrc.txt)

## AI implementation checklist

Use the actual SDK exports and parameter types in the linked files. Start with reads and unsigned plans where supported. Use a connected wallet for browser signing. Preserve raw integer units, exact approvals, caller authority, deadlines and receipt reconciliation. Report local checks separately from live-chain verification.
