Skip to content

Commit 2821640

Browse files
authored
chore: Accumulated backports to v4-next (#22205)
BEGIN_COMMIT_OVERRIDE cherry-pick: feat: move event size check from declaration to private emission (#22168) fix: prevent oracle failure on tag computation for invalid recipient (#22163) feat: move event size check from declaration to private emission (#22168) [v4-next backport] (#22182) fix(cli-wallet): peek claim stack instead of popping for estimate-gas-only (#22196) fix: use Fr.fromString for CLI wallet claim params to handle decimal values (#22197) fix: indefinite retry for prover node and agent broker communication (#22202) END_COMMIT_OVERRIDE
2 parents 3b97770 + 936f4e9 commit 2821640

46 files changed

Lines changed: 542 additions & 370 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/docs-developers/docs/aztec-js/how_to_create_account.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,13 @@ See the [guide on fees](./how_to_pay_fees.md#sponsored-fee-payment-contracts) fo
4646

4747
### Using Fee Juice
4848

49-
If your account already has Fee Juice (for example, [bridged from L1](./how_to_pay_fees.md#bridge-fee-juice-from-l1)):
49+
If your account has Fee Juice from a [bridge from L1](./how_to_pay_fees.md#bridge-fee-juice-from-l1), you can claim it and deploy in one step using `FeeJuicePaymentMethodWithClaim`:
5050

51-
#include_code deploy_account_fee_juice /docs/examples/ts/aztecjs_connection/index.ts typescript
51+
#include_code bridge_fee_juice_claim /docs/examples/ts/aztecjs_connection/index.ts typescript
5252

53-
The `from: NO_FROM` signals that this transaction should be executed without account contract mediation. The wallet will directly execute it via a default entrypoint with no authorization
53+
If the account already has Fee Juice on L2 (for example, from a faucet or a previously claimed bridge), no special payment method is needed — just call `send({ from: NO_FROM })` and Fee Juice is used automatically.
54+
55+
The `from: NO_FROM` signals that this transaction should be executed without account contract mediation. The wallet will directly execute it via a default entrypoint with no authorization.
5456

5557
## Verify deployment
5658

docs/docs-developers/docs/aztec-js/how_to_pay_fees.md

Lines changed: 16 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,7 @@ When using `EmbeddedWallet`, gas is estimated automatically on every `send()` ca
4242

4343
Before sending a transaction, you can estimate the mana it will consume by simulating with `estimateGas: true`:
4444

45-
```typescript
46-
const { estimatedGas } = await contract.methods
47-
.myFunction(arg1, arg2)
48-
.simulate({
49-
from: sender.address,
50-
fee: { estimateGas: true, estimatedGasPadding: 0.1 },
51-
});
52-
```
45+
#include_code estimate_mana /docs/examples/ts/aztecjs_advanced/index.ts typescript
5346

5447
The `estimatedGas` object contains:
5548

@@ -62,13 +55,7 @@ The `estimatedGas` object contains:
6255

6356
To calculate the expected fee from estimated gas, use the `computeFee` method with current network fees:
6457

65-
```typescript
66-
// import { createAztecNodeClient } from '@aztec/aztec.js/node';
67-
// const aztecNode = createAztecNodeClient('http://localhost:8080');
68-
const currentFees = await aztecNode.getCurrentMinFees();
69-
const estimatedFee = estimatedGas.gasLimits.computeFee(currentFees).toBigInt();
70-
console.log("Estimated fee:", estimatedFee);
71-
```
58+
#include_code compute_fee_from_estimate /docs/examples/ts/aztecjs_advanced/index.ts typescript
7259

7360
:::tip
7461
The `estimatedGasPadding` parameter adds a safety margin to the estimate. A value of `0.1` adds 10% padding. Use higher padding for transactions with variable gas costs.
@@ -78,41 +65,19 @@ The `estimatedGasPadding` parameter adds a safety margin to the estimate. A valu
7865

7966
After a transaction is mined, you can retrieve the fee paid from the receipt:
8067

81-
```typescript
82-
const receipt = await contract.methods
83-
.myFunction(arg1, arg2)
84-
.send({ from: sender.address })
85-
.wait();
86-
87-
console.log("Transaction fee:", receipt.transactionFee);
88-
```
68+
#include_code get_fee_from_receipt /docs/examples/ts/aztecjs_advanced/index.ts typescript
8969

9070
The `transactionFee` field is a `bigint` representing the total fee paid in the fee token (Fee Juice). You can also check execution status:
9171

92-
```typescript
93-
if (receipt.hasExecutionSucceeded()) {
94-
console.log("Transaction succeeded in block:", receipt.blockNumber);
95-
console.log("Fee paid:", receipt.transactionFee);
96-
} else {
97-
console.log("Transaction failed:", receipt.error);
98-
}
99-
```
72+
#include_code check_receipt_status /docs/examples/ts/aztecjs_advanced/index.ts typescript
10073

10174
## Pay with Fee Juice
10275

10376
Fee Juice is the native fee token on Aztec.
10477

10578
If your account has Fee Juice (for example, from a faucet), is [deployed](./how_to_create_account.md), and is registered in your wallet, it will be used automatically to pay for the fee of the transaction:
10679

107-
```typescript
108-
// contract is a deployed contract instance; aliceAddress is from the connection guide
109-
const receipt = await contract.methods.myFunction(param1, param2).send({
110-
from: aliceAddress,
111-
// no fee payment method needed
112-
});
113-
114-
console.log("Transaction fee:", receipt.transactionFee);
115-
```
80+
#include_code pay_with_fee_juice /docs/examples/ts/aztecjs_advanced/index.ts typescript
11681

11782
## Use Fee Payment Contracts
11883

@@ -151,51 +116,15 @@ Fee Juice is non-transferable on L2, but you can bridge it from L1, claim it on
151116

152117
`aztec.js` provides helpers to simplify the process:
153118

154-
```typescript
155-
// essentially returns an extended wallet from Viem
156-
import { createExtendedL1Client } from "@aztec/ethereum";
157-
const walletClient = createExtendedL1Client(
158-
["https://your-ethereum-host"], // ex. http://localhost:8545 on the local network (yes it runs Anvil under the hood)
159-
privateKey, // the private key for some account, needs funds for gas!
160-
);
161-
162-
// a helper to interact with the L1 fee juice portal
163-
import { L1FeeJuicePortalManager } from "@aztec/aztec.js/ethereum";
164-
const portalManager = await L1FeeJuicePortalManager.new(
165-
node, // your Aztec node, ex. https://aztec-testnet-fullnode.zkv.xyz, or http://localhost:8080 for local network
166-
walletClient,
167-
logger, // a logger, ex. import { createLogger } from "@aztec/aztec.js"
168-
);
169-
```
119+
#include_code bridge_fee_juice_setup /docs/examples/ts/aztecjs_connection/index.ts typescript
170120

171121
Under the hood, `L1FeeJuicePortalManager` gets the L1 addresses from the node `node_getNodeInfo` endpoint. It then exposes an easy method `bridgeTokensPublic` which mints fee juice on L1 and sends it to an L2 address via the L1 portal:
172122

173-
```typescript
174-
// portalManager is from the L1FeeJuicePortalManager setup above
175-
// aliceAddress is an Aztec address from the connection guide
176-
const claim = await portalManager.bridgeTokensPublic(
177-
aliceAddress, // the L2 address
178-
1000000000000000000000n, // the amount to send to the L1 portal
179-
true, // whether to mint or not (set to false if your walletClient account already has fee juice!)
180-
);
181-
182-
console.log("Claim secret:", claim.claimSecret);
183-
console.log("Claim amount:", claim.claimAmount);
184-
```
123+
#include_code bridge_fee_juice_execute /docs/examples/ts/aztecjs_connection/index.ts typescript
185124

186125
After this transaction is minted on L1 and a few blocks pass, you can claim the message on L2 and use it directly to pay for fees:
187126

188-
```typescript
189-
import { FeeJuicePaymentMethodWithClaim } from "@aztec/aztec.js/fee";
190-
191-
// aliceAddress and claim are from the bridgeTokensPublic step above
192-
// contract is a deployed contract instance; gasSettings is from the gas settings section
193-
// Use the claim from bridgeTokensPublic to pay for a transaction
194-
const paymentMethod = new FeeJuicePaymentMethodWithClaim(aliceAddress, claim);
195-
const receipt = await contract.methods
196-
.myFunction()
197-
.send({ from: aliceAddress, fee: { gasSettings, paymentMethod } });
198-
```
127+
#include_code bridge_fee_juice_claim /docs/examples/ts/aztecjs_connection/index.ts typescript
199128

200129
## Configure gas settings
201130

@@ -214,45 +143,21 @@ The fee limit is calculated as `gasLimits × maxFeesPerGas` for each dimension.
214143

215144
Set custom gas limits by importing from `stdlib`:
216145

217-
```typescript
218-
import { GasSettings } from "@aztec/stdlib/gas";
219-
220-
// contract is a deployed contract instance
221-
// alice is from the connection guide
222-
// paymentMethod is from one of the payment method sections above
223-
const gasSettings = GasSettings.from({
224-
gasLimits: { daGas: 100000, l2Gas: 100000 },
225-
teardownGasLimits: { daGas: 10000, l2Gas: 10000 },
226-
maxFeesPerGas: { daGas: 10, l2Gas: 10 },
227-
maxPriorityFeesPerGas: { daGas: 1, l2Gas: 1 },
228-
});
229-
230-
const receipt = await contract.methods.myFunction().send({
231-
from: aliceAddress,
232-
fee: {
233-
paymentMethod,
234-
gasSettings,
235-
},
236-
});
237-
```
146+
#include_code custom_gas_settings /docs/examples/ts/aztecjs_advanced/index.ts typescript
147+
148+
Then pass the settings when sending:
149+
150+
#include_code send_with_gas_settings /docs/examples/ts/aztecjs_advanced/index.ts typescript
151+
152+
Note that `gasLimits` and `teardownGasLimits` use `daGas`/`l2Gas` field names, while `maxFeesPerGas` and `maxPriorityFeesPerGas` use `feePerDaGas`/`feePerL2Gas`.
238153

239154
### Use automatic gas estimation
240155

241156
:::note
242157
When using `EmbeddedWallet`, gas estimation happens automatically on every `send()` — you don't need to pass `estimateGas`. This option is useful for custom wallet implementations or when you want to estimate gas during a `simulate()` call.
243158
:::
244159

245-
```typescript
246-
// contract, aliceAddress, and paymentMethod are from the examples above
247-
const receipt = await contract.methods.myFunction().send({
248-
from: aliceAddress,
249-
fee: {
250-
paymentMethod,
251-
estimateGas: true,
252-
estimatedGasPadding: 0.2, // 20% padding
253-
},
254-
});
255-
```
160+
#include_code auto_gas_estimation /docs/examples/ts/aztecjs_advanced/index.ts typescript
256161

257162
:::tip
258163
Gas estimation runs a simulation first to determine actual gas usage, then adds padding for safety. This works with all payment methods, including FPCs.

docs/docs-developers/docs/aztec-js/how_to_read_data.md

Lines changed: 14 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,15 @@ The `simulate` method executes a contract function locally and returns its resul
2020

2121
#include_code simulate_function /docs/examples/ts/aztecjs_connection/index.ts typescript
2222

23-
The `from` option specifies which address context to use for the simulation. This is required for all simulations, though it only affects private function execution (public functions ignore this value).
24-
25-
### Basic simulation
26-
27-
#include_code simulate_function docs/examples/ts/aztecjs_connection/index.ts typescript
23+
The `from` option specifies which account context to use for the simulation. This is required for all simulations. For private functions, it determines which account's private state is accessed. For public functions, it sets the `msg_sender` context.
2824

2925
### Handling return values
3026

3127
For functions returning multiple values, destructure the result:
3228

3329
```typescript
3430
// contract and callerAddress are from the example above
35-
const [value1, value2] = await contract.methods
31+
const { result: [value1, value2] } = await contract.methods
3632
.get_multiple_values()
3733
.simulate({ from: callerAddress });
3834
```
@@ -41,38 +37,17 @@ const [value1, value2] = await contract.methods
4137

4238
Set `includeMetadata: true` to get additional information about the simulation:
4339

44-
```typescript
45-
// contract and callerAddress are from the examples above
46-
const result = await contract.methods
47-
.balance_of_public(address)
48-
.simulate({ from: callerAddress, includeMetadata: true });
49-
50-
// Result includes:
51-
// - result: the function return value
52-
// - stats: execution statistics (timing, circuit sizes)
53-
// - offchainEffects: any offchain effects emitted
54-
// - estimatedGas: gas limit estimates (gasLimits and teardownGasLimits)
55-
console.log("Balance:", result.result);
56-
console.log("L2 gas limit:", result.estimatedGas.gasLimits.l2Gas);
57-
console.log("DA gas limit:", result.estimatedGas.gasLimits.daGas);
58-
```
40+
#include_code simulate_with_metadata /docs/examples/ts/aztecjs_advanced/index.ts typescript
41+
42+
The result includes `result` (the function return value), `stats` (execution statistics), `offchainEffects`, and `estimatedGas` (with `gasLimits` and `teardownGasLimits`).
5943

6044
### Private function considerations
6145

6246
When simulating private functions, the caller must have access to any private state being read. The PXE only has visibility into notes belonging to registered accounts.
6347

64-
```typescript
65-
// contract and callerAddress are from the examples above
66-
// This works if callerAddress owns the notes
67-
const balance = await contract.methods
68-
.balance_of_private(callerAddress)
69-
.simulate({ from: callerAddress });
48+
#include_code simulate_private_access /docs/examples/ts/aztecjs_advanced/index.ts typescript
7049

71-
// This fails if callerAddress doesn't have access to otherAddress's notes
72-
const otherBalance = await contract.methods
73-
.balance_of_private(otherAddress)
74-
.simulate({ from: callerAddress }); // Error: cannot access private state
75-
```
50+
If the caller doesn't have access to another address's notes, the simulation will fail with an error.
7651

7752
:::warning
7853
Simulation runs locally without generating proofs. No correctness guarantees are provided on the result. See [Call Types](../foundational-topics/call_types.md#simulate) for more details.
@@ -95,20 +70,11 @@ Contracts emit data in two forms you can read:
9570

9671
Use `aztecNode.getPublicLogs()` to retrieve raw log data:
9772

98-
```typescript
99-
// aztecNode is from createAztecNodeClient() in the connection guide
100-
// receipt is from a transaction's send() call
101-
// Get logs for a specific transaction
102-
const logs = await aztecNode.getPublicLogs({ txHash: receipt.txHash });
103-
const rawFields = logs.logs[0].log.getEmittedFields(); // Fr[]
104-
105-
// Get logs for a block range
106-
const logFilter = {
107-
fromBlock: startBlock,
108-
toBlock: endBlock,
109-
};
110-
const publicLogs = (await aztecNode.getPublicLogs(logFilter)).logs;
111-
```
73+
#include_code read_public_logs /docs/examples/ts/aztecjs_advanced/index.ts typescript
74+
75+
You can also filter by transaction hash or block range:
76+
77+
#include_code read_logs_by_filter /docs/examples/ts/aztecjs_advanced/index.ts typescript
11278

11379
## Reading events
11480

@@ -118,9 +84,7 @@ Events provide typed access to contract emissions. The event metadata from your
11884

11985
Use the `getPublicEvents` helper to retrieve typed public events:
12086

121-
```typescript
122-
import { getPublicEvents } from "@aztec/aztec.js/events";
123-
```
87+
#include_code import_get_public_events /docs/examples/ts/aztecjs_advanced/index.ts typescript
12488

12589
#include_code get_public_events yarn-project/end-to-end/src/e2e_event_logs.test.ts typescript
12690

@@ -140,10 +104,7 @@ Each returned event includes both the decoded `event` data and `metadata` (block
140104

141105
Private events are stored in the PXE with privacy scoping. Use `wallet.getPrivateEvents()` to retrieve them:
142106

143-
```typescript
144-
import type { PrivateEventFilter } from "@aztec/aztec.js/wallet";
145-
import { BlockNumber } from "@aztec/foundation/branded-types";
146-
```
107+
#include_code import_private_event_types /docs/examples/ts/aztecjs_advanced/index.ts typescript
147108

148109
The `BlockNumber` type is a branded type that wraps raw numbers for type safety. Use it when setting `fromBlock` and `toBlock` in filters.
149110

docs/docs-developers/docs/aztec-js/how_to_send_transaction.md

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,11 @@ import { General } from '@site/src/components/Snippets/general_snippets';
2323

2424
After connecting to a contract:
2525

26-
```typescript
27-
import { Contract } from "@aztec/aztec.js";
28-
29-
// wallet is from the connection guide; contractAddress and artifact are from your deployed contract
30-
const contract = await Contract.at(contractAddress, artifact, wallet);
31-
```
26+
#include_code connect_to_contract /docs/examples/ts/aztecjs_advanced/index.ts typescript
3227

3328
Call a function and wait for it to be mined:
3429

35-
```typescript
36-
// contract is from the step above; alice is from the connection guide
37-
const receipt = await contract.methods
38-
.transfer(bobAddress, amount)
39-
.send({ from: aliceAddress });
40-
41-
console.log(`Transaction mined in block ${receipt.blockNumber}`);
42-
console.log(`Transaction fee: ${receipt.transactionFee}`);
43-
```
30+
#include_code basic_send_transaction /docs/examples/ts/aztecjs_advanced/index.ts typescript
4431

4532
The `from` field specifies which account sends the transaction. If that account has Fee Juice, it pays for the transaction automatically. For other fee payment options, see [paying fees](./how_to_pay_fees.md).
4633

@@ -53,9 +40,7 @@ When using `EmbeddedWallet`, calling `send()` triggers a **simulation** step bef
5340

5441
This means a simple `.send()` is all most apps need. You can adjust the gas padding if desired:
5542

56-
```typescript
57-
wallet.setEstimatedGasPadding(0.2); // 20% padding instead of the default 10%
58-
```
43+
#include_code set_gas_padding /docs/examples/ts/aztecjs_advanced/index.ts typescript
5944

6045
:::note
6146
Public authwits still need to be set explicitly before the transaction, as they require a separate onchain transaction. See [Using Authentication Witnesses](./how_to_use_authwit.md) for details.
@@ -85,7 +70,7 @@ After sending a transaction without waiting, you can query its receipt using the
8570

8671
The receipt includes:
8772

88-
- `status` - Transaction status (`success`, `reverted`, `dropped`, or `pending`)
73+
- `status` - Transaction status (`pending`, `proposed`, `checkpointed`, `proven`, `finalized`, or `dropped`)
8974
- `blockNumber` - Block where the transaction was included
9075
- `transactionFee` - Fee paid for the transaction
9176
- `error` - Error message if the transaction reverted

0 commit comments

Comments
 (0)