You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
chore(docs): Fix some stuff on fees, rm confusing storage example (#13501)
Updates fees to correctly show how to use them with a standalone PXE.
Addresses some feedback that the storage example was confusing (since
its acutally code that errors).
Copy file name to clipboardExpand all lines: docs/docs/developers/guides/js_apps/pay_fees.md
+27-9Lines changed: 27 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -125,23 +125,31 @@ import {
125
125
} from"@aztec/aztec.js";
126
126
```
127
127
128
-
The FPC contract must be registered in a users PXE before it can be used.
128
+
A FPC contract must be registered in a users PXE before it can be used. This will automatically happen if you deploy a FPC to your sandbox, but must be added manually if you are using a standalone PXE.
In this example, thanks to the FPC's `accepted_asset` being banana tokens, Alice only needs to hold this token and not fee juice. The asset that a FPC accepts for paying fees is determined when the FPC is deployed. The function being called happens to also be a transfer of banana tokens to Bob.
152
+
In this example, thanks to this FPC's `accepted_asset` being banana tokens, Alice only needs to hold this token and not fee juice. The asset that a FPC accepts for paying fees is determined when the FPC is deployed. The function being called happens to also be a transfer of banana tokens to Bob.
145
153
146
154
More on FPCs [here](https://github.com/AztecProtocol/aztec-packages/tree/#include_aztec_version/noir-projects/noir-contracts/contracts/fees/fpc_contract/src/main.nr)
147
155
@@ -154,6 +162,8 @@ The sandbox comes with a sponsored fee paying contract deployed, so this can be
154
162
To use sponsored FPCs in other environments, they will need to be deployed and funded with fee juice.
155
163
Using a SponsoredFPC payment method is as simple as importing it, registering it and passing it the PXE:
Then a transaction can specify this as the `paymentMethod` in the fee object.
178
-
You can see an example of how to get a deployed instance of the sponsored FPC in the sandbox [here](https://github.com/AztecProtocol/aztec-packages/blob/#include_aztec_version/yarn-project/aztec/src/sandbox/sponsored_fpc.ts#L15).
193
+
You can see an example implementation for `getSponsoredFPCInstance()`[here](https://github.com/AztecProtocol/aztec-packages/blob/360a5f628b4edaf1ea9b328d9e9231f60fdc81a0/yarn-project/aztec/src/sandbox/sponsored_fpc.ts#L5).
194
+
195
+
Once this is set up, a transaction can specify this as the `paymentMethod` in the fee object.
196
+
You can see an example of how to get a deployed instance of a sponsored FPC in the sandbox [here](https://github.com/AztecProtocol/aztec-packages/blob/#include_aztec_version/yarn-project/aztec/src/sandbox/sponsored_fpc.ts#L15).
179
197
For example, a contract can be deployed with an fpc as follows:
Copy file name to clipboardExpand all lines: docs/docs/developers/reference/smart_contract_reference/storage/index.md
+2-17Lines changed: 2 additions & 17 deletions
Original file line number
Diff line number
Diff line change
@@ -26,28 +26,13 @@ On this and the following pages in this section, you’ll learn:
26
26
27
27
Aztec contracts have three different modes of execution: private, public, and utility. How storage is accessed depends on the execution mode: for example, `PublicImmutable` can be read in all execution modes but only initialized in public, while `PrivateMutable` is entirely unavailable in public.
28
28
29
-
Aztec.nr prevents developers from calling functions unavailable in the current execution mode via the `context` variable that is injected into all contract functions. Its type indicates the current execution mode:
29
+
Aztec.nr prevents developers from calling functions unavailable in the current execution mode via the `Context` variable that is injected into all contract functions. Its type indicates the current execution mode:
30
30
31
31
-`&mut PrivateContext` for private execution
32
32
-`&mut PublicContext` for public execution
33
33
-`UtilityContext` for utility execution
34
34
35
-
All state variables are generic over this `Context` type, and expose different methods in each execution mode. In the example above, `PublicImmutable`'s `initialize` function is only available with a public execution context, and so the following code results in a compilation error:
36
-
37
-
```rust
38
-
#[storage]
39
-
structStorage {
40
-
variable:PublicImmutable<Field>,
41
-
}
42
-
43
-
#[private]
44
-
fnsome_private_function() {
45
-
storage.variable.initialize(0);
46
-
// ^ ERROR: Expected type PublicImmutable<_, &mut PublicContext>, found type PublicImmutable<Field, &mut PrivateContext>
47
-
}
48
-
```
49
-
50
-
The `Context` generic type parameter is not visible in the code above as it is automatically injected by the `#[storage]` macro, in order to reduce boilerplate. Similarly, all state variables in that struct (e.g. `PublicImmutable`) similarly have that same type parameter automatically passed to them.
35
+
All state variables are generic over this `Context` type, and expose different methods in each execution mode.
For the mechanisms to complete bridging between L1 and Aztec, we have to wait for 2 Aztec blocks to progress. This can be triggered manually by sending 2 transactions in the sandbox, or by waiting for 2 blocks on a public network. After this, an account should have its fee juice ready to use in transactions.
The FPC contract must be registered in a users PXE before it can be used.
165
+
A FPC contract must be registered in a users PXE before it can be used. This will automatically happen if you deploy a FPC to your sandbox, but must be added manually if you are using a standalone PXE.
In this example, thanks to the FPC's `accepted_asset` being banana tokens, Alice only needs to hold this token and not fee juice. The asset that a FPC accepts for paying fees is determined when the FPC is deployed. The function being called happens to also be a transfer of banana tokens to Bob.
193
+
In this example, thanks to this FPC's `accepted_asset` being banana tokens, Alice only needs to hold this token and not fee juice. The asset that a FPC accepts for paying fees is determined when the FPC is deployed. The function being called happens to also be a transfer of banana tokens to Bob.
194
194
195
195
More on FPCs [here](https://github.com/AztecProtocol/aztec-packages/tree/v0.85.0-alpha-testnet.0/noir-projects/noir-contracts/contracts/fees/fpc_contract/src/main.nr)
196
196
@@ -211,16 +211,20 @@ import { SponsoredFeePaymentMethod } from "@aztec/aztec.js/fee/testing";
0 commit comments