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.
Import
import { aggregate } from "@0xcurvy/curvy-sdk/actions";Usage
const { receipt } = await aggregate({ inputNotes, ownerBjjPrivateKeyHex,
recipients: [{ amount: 5n, curvyId: "alice.curvy.name" }],
protocolFeePerThousand: 3n, gasFee: 0n, via: { kind: "wallet", walletClient } });Signature
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.
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.
const result = await aggregate({
inputNotes,
ownerBjjPrivateKeyHex,
recipients,
via,
});recipients
- Type:
AggregateRecipientInput[] - Required: yes
Recipient outputs. The builder adds change and protocol-fee notes.
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.
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.
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.
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.
const result = await aggregate({
inputNotes,
ownerBjjPrivateKeyHex,
recipients,
operatorFee,
via,
});notesTree
- Type:
MerkleTree - Required: no
The committed notes tree (omit when supplied is set).
const result = await aggregate({
inputNotes,
ownerBjjPrivateKeyHex,
recipients,
notesTree,
via,
});supplied
- Type:
SuppliedInclusionProofs - Required: no
Lean-client alternative: pre-built inclusion proofs at one root.
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.
const result = await aggregate({
inputNotes,
ownerBjjPrivateKeyHex,
recipients,
networkSlug,
via,
});config
- Type:
CurvyConfig - Required: no
Curvy config to use. Defaults to the ambient config.
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" }.
const result = await aggregate({
inputNotes,
ownerBjjPrivateKeyHex,
recipients,
via,
});Errors
Errors from config resolution and the underlying SDK operation are propagated to the caller.
Related
- Interacting with assets guide
withdraw— One-call WITHDRAW: build the proof from committed notes and send it in one shot, via the user's wallet or the relay service.estimateAggregationCosts— Load the inputs needed to allocate an aggregation.