# partner:quote-module — Ammora SDK 0.3.9

Read a live exact-input ERC20 quote; keep the returned client/plan together for your wallet.

[Read in Docs](https://docs.ammora.org/examples?command=partner%3Aquote-module) · [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:quote-module -- <arguments from the source below>` (`tsx src/partner/self-service/trade.ts`). Omit `--` and arguments when the source accepts none.

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

```typescript
/** Read a live exact-input ERC20 quote; keep the returned client/plan together for your wallet. */
import { readFileSync } from "node:fs";
import type { ExtensionIntentV2 } from "@ammora-protocol/sdk/partner";
import { address, cli, required, loadSelfServiceProfile, type SelfServiceProfile } from "./context.js";
import { openSelfServiceModule, parseSelfServiceModulePin, type SelfServiceModulePin } from "./extension.js";
export function parseSelfServiceTradeInput(value: unknown): Omit<ExtensionIntentV2, "ports"> {
  if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error("Expected explicit trade inputs");
  const p = value as Record<string, unknown>, fields = ["assetIn", "amountRaw", "minOutputRaw", "payer", "recipient", "refundTo", "executor", "nonce", "ttlSeconds"];
  if (Object.keys(p).sort().join() !== fields.sort().join()) throw new Error("Provide exact trade fields; no transaction override or wallet secret");
  const uint = (key: string, allowZero = false) => { const v = p[key]; if (typeof v !== "string" || !/^\d{1,78}$/.test(v)) throw new Error(`${key} must be a decimal integer string`); const n = BigInt(v); if ((!allowZero && n === 0n) || n >= 2n ** 256n) throw new Error(`${key} is outside the supported uint256 range`); return n; };
  const ttlSeconds = uint("ttlSeconds"); if (ttlSeconds > 300n) throw new Error("Use an explicit short TTL of at most300 seconds");
  return { assetIn: address(p.assetIn), amount: uint("amountRaw"), limit: uint("minOutputRaw"), payer: address(p.payer), recipient: address(p.recipient), refundTo: address(p.refundTo), executor: address(p.executor), nonce: uint("nonce", true), ttlSeconds, mode: "exact-input", nativeIn: false, nativeOut: false };
}
export async function quoteSelfServiceTrade(profile: SelfServiceProfile, module: SelfServiceModulePin, input: unknown) {
  const intent = parseSelfServiceTradeInput(input), { client, stats } = openSelfServiceModule(profile, module);
  const plan = await client.quote({ ...intent, ports: [module.address] });
  return { client, plan, stats };
}
cli(import.meta.url, async () => { const profile = loadSelfServiceProfile(required(2, "profile.json")), module = parseSelfServiceModulePin(JSON.parse(readFileSync(required(3, "module-pin.json"), "utf8"))), input = JSON.parse(readFileSync(required(4, "trade-input.json"), "utf8")); const { plan, stats } = await quoteSelfServiceTrade(profile, module, input); return { plan, stats: stats(), automaticSend: false, authority: "CLI output is a view. In an application retain the original returned client and genuine plan for sign/simulate; never reconstruct send authority from this JSON." }; });
```

## 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.
