Skip to content

aggregate ​

One-call AGGREGATE: build the proof from committed notes and send it in one shot, either via the user's wallet (via.kind === "wallet") or the relay service (via.kind === "relay"). The two-step buildAggregateRequest + .submit()/.relay() is available when you want to inspect the proof first.

If the aggregator's gas fees change between proving and submission and the proof is refused before anything reaches the chain, the proof is built once more with current fees and sent again.

Import ​

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

Usage ​

ts
const { receipt } = await aggregate({ inputNotes, ownerBjjPrivateKeyHex, notesTree,
  recipients: [{ amount: 5n, curvyId: "alice.curvy.name" }],
  via: { kind: "wallet", walletClient } });

Signature ​

ts
function aggregate(parameters: AggregateParameters): Promise<ChainSubmitResult | RelaySubmitReturnType>

Returns ​

Promise<ChainSubmitResult | RelaySubmitReturnType>

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 aggregate({
  inputNotes, 
  ownerBjjPrivateKeyHex,
  recipients,
  via,
});

ownerBjjPrivateKeyHex ​

  • Type: string
  • Required: yes

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

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

recipients ​

  • Type: AggregateRecipientInput[]
  • Required: yes

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

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

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 aggregate({
  inputNotes,
  ownerBjjPrivateKeyHex,
  recipients,
  changeRecipient, 
  via,
});

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 aggregate({
  inputNotes,
  ownerBjjPrivateKeyHex,
  recipients,
  feeRecipient, 
  via,
});

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 aggregate({
  inputNotes,
  ownerBjjPrivateKeyHex,
  recipients,
  operatorRecipient, 
  via,
});

operatorFee ​

  • Type: bigint
  • Required: no

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

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

notesTree ​

  • Type: MerkleTree
  • Required: no

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

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

supplied ​

  • Type: SuppliedInclusionProofs
  • Required: no

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

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

networkSlug ​

  • Type: string
  • Required: no

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

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

signal ​

  • Type: AbortSignal
  • Required: no

Cancel artifact loading and queued proof generation.

ts
const result = await aggregate({
  inputNotes,
  ownerBjjPrivateKeyHex,
  recipients,
  signal, 
  via,
});

config ​

  • Type: CurvyConfig
  • Required: no

Curvy config to use. Defaults to the ambient config.

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

via ​

  • Type: SubmitVia
  • Required: yes

Where to send the built proof: { kind: "wallet", walletClient } or { kind: "relay" }.

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

Errors ​

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

Source ​

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