Skip to content

buildAggregateRequest

Build a submit-ready aggregation proof from committed notes. Contract fees and circuit parameters are read for the selected network; proving runs locally.

Import

ts
import { buildAggregateRequest } from "@0xcurvy/curvy-sdk/actions";

Usage

ts
const req = await buildAggregateRequest({ inputNotes, ownerBjjPrivateKeyHex,
  recipients: [{ amount: 5n, curvyId: "alice.curvy.name" }] });
await req.submit({ walletClient });   // or: await req.relay();

Signature

ts
function buildAggregateRequest(parameters: BuildAggregateRequestParameters): Promise<SubmittableSubmission>

Returns

Promise<SubmittableSubmission>

The action resolves or returns the value shown in the signature.

Parameters

inputNotes

  • Type: Note[]
  • Required: yes

One to maxInputs committed notes with the same token and owner.

ts
const result = await buildAggregateRequest({
  inputNotes, 
  ownerBjjPrivateKeyHex,
  recipients,
});

ownerBjjPrivateKeyHex

  • Type: string
  • Required: yes

BabyJubjub private key (hex) that owns the input notes and signs the aggregation.

ts
const result = await buildAggregateRequest({
  inputNotes,
  ownerBjjPrivateKeyHex, 
  recipients,
});

recipients

  • Type: AggregateRecipientInput[]
  • Required: yes

Recipient outputs. The builder adds change and protocol-fee notes.

ts
const result = await buildAggregateRequest({
  inputNotes,
  ownerBjjPrivateKeyHex,
  recipients, 
});

changeRecipient

  • Type: CurvyPublicKeys
  • Required: no

Sender keys used to make a non-zero change note discoverable. Required when the inputs can exceed recipients plus fees.

ts
const result = await buildAggregateRequest({
  inputNotes,
  ownerBjjPrivateKeyHex,
  recipients,
  changeRecipient, 
});

feeRecipient

  • Type: CurvyPublicKeys
  • Required: no

Protocol fee-collector keys. Defaults to protocol metadata and must match the deployed aggregator when the fee is non-zero.

ts
const result = await buildAggregateRequest({
  inputNotes,
  ownerBjjPrivateKeyHex,
  recipients,
  feeRecipient, 
});

operatorRecipient

  • Type: CurvyPublicKeys
  • Required: no

Relay operator keys. Together with operatorFee, adds a discoverable gas reimbursement output and consumes one output slot.

ts
const result = await buildAggregateRequest({
  inputNotes,
  ownerBjjPrivateKeyHex,
  recipients,
  operatorRecipient, 
});

operatorFee

  • Type: bigint
  • Required: no

The gas-reimbursement amount (token base units) for the operatorRecipient note.

ts
const result = await buildAggregateRequest({
  inputNotes,
  ownerBjjPrivateKeyHex,
  recipients,
  operatorFee, 
});

notesTree

  • Type: MerkleTree
  • Required: no

The committed notes tree (omit when supplied is set).

ts
const result = await buildAggregateRequest({
  inputNotes,
  ownerBjjPrivateKeyHex,
  recipients,
  notesTree, 
});

supplied

  • Type: SuppliedInclusionProofs
  • Required: no

Lean-client alternative: pre-built inclusion proofs at one root.

ts
const result = await buildAggregateRequest({
  inputNotes,
  ownerBjjPrivateKeyHex,
  recipients,
  supplied, 
});

networkSlug

  • Type: string
  • Required: no

Network whose deployed aggregator/circuit to target; defaults to the active network.

ts
const result = await buildAggregateRequest({
  inputNotes,
  ownerBjjPrivateKeyHex,
  recipients,
  networkSlug, 
});

config

  • Type: CurvyConfig
  • Required: no

Curvy config to use. Defaults to the ambient config.

ts
const result = await buildAggregateRequest({
  inputNotes,
  ownerBjjPrivateKeyHex,
  recipients,
  config, 
});

Errors

Errors from config resolution and the underlying SDK operation are propagated to the caller.

  • Interacting with assets guide
  • proveAggregation — Prove an aggregation: resolve the network's aggregation circuit artifacts (from its CircuitConfig), flatten the supplied witness, and run it through the config's prover (default Rust/arkworks).
  • submitToChain — Submit a built aggregator proof on-chain with the caller's wallet client.
  • relaySubmission — Relay a built proof via the SDK's relay service — no EVM wallet, no gas.
  • waitForRelay — Poll a relayed submission to the requested lifecycle milestone.

Source

packages/@0xcurvy/sdk/src/actions/aggregator/buildAggregateRequest.ts