bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 75쪽 중 21쪽
PC address and routes fees through it, every private fee payment in the ecosystem shares the same public fee-payer tag and joins a single, much larger shared set.
This is the whole point of a fully private FPC. Because you don't have to deploy it on L2, there is no race to "be the deployer": the only thing that matters is that everyone agrees on the address.
## Recommended salt: `0`[](#recommended-salt-0 "Direct link to recommended-salt-0")
Two parties derive the same contract address if and only if they use the same compiled artifact and the same deployment salt. For any fully private FPC, using a common salt maximizes the shared privacy set. The community convention for the `private-fee-juice` `PrivateFPC` is `Fr.ZERO`.
This is a convention, not a protocol-enforced default. It is up to each developer to pass the salt when registering the contract with their PXE, just as they choose any other deployment parameter. Following the convention means your users' private fee payments join the same privacy set as every other app that follows it.
Version-specific addresses
The `PrivateFPC` address depends on the compiled contract bytecode. A different Aztec version produces different bytecode and therefore a **different address**. Sending Fee Juice to the wrong address means **unrecoverable loss**. Before using a derived address on a given network, verify the network runs the same Aztec version as the `private-fee-juice` SDK version you have installed.
## Example: pay fees with `PrivateFPC`[](#example-pay-fees-with-privatefpc "Direct link to example-pay-fees-with-privatefpc")
The SDK exports two payment methods plus a `registerPrivateContract` helper that registers the FPC with your PXE using the shared deployment salt, with no deployment transaction needed:
* `new FPCFeePaymentMethod(fpcAddress)`: for users who already have a private balance in the FPC. Wraps `PrivateFPC.pay_fee()`.
* `new PrivateMintAndPayFeePaymentMethod(fpcAddress, amount, bridgeSecret, bridgeSalt, leafIndex)`: for cold-start. Bundles `FeeJuice.claim` and `PrivateFPC.mint_and_pay_fee` into the setup phase of a single transaction.
For installation, the complete bridge-claim-mint-pay flow, required `send()` options (including `additionalScopes` and `gasSettings`), and a runnable end-to-end example, see the [SDK README](https://github.com/alejoamiras/ecosystem-tooling/blob/main/packages/private-fee-juice/src/ts/README.md) and the [integration test](https://github.com/alejoamiras/ecosystem-tooling/blob/main/packages/private-fee-juice/src/ts/test/private.test.ts).
Transaction behavior
| Scenario | Status | Execution result | Fee paid? |
| -------------- | --------------------------------- | ---------------- | -------------- |
| Private revert | `DROPPED` (not included in block) | N/A | No |
| Public revert | `PROPOSED` | `REVERTED` | Yes (FPC pays) |
| Success | `PROPOSED` | `SUCCESS` | Yes (FPC pays) |
## Reference implementation[](#reference-implementation "Direct link to Reference implementation")
The `private-fee-juice` package ships detailed documentation for this design and its security properties:
* [Private FPC Product Requirements](https://github.com/alejoamiras/ecosystem-tooling/blob/main/packages/private-fee-juice/docs/private-product-requirements.md): problem statement, requirements matrix, cryptographic design (secret derivation, nullifier reconstruction, double-spend prevention), and security properties
* [`PrivateFPC` Noir source](https://github.com/alejoamiras/ecosystem-tooling/blob/main/packages/private-fee-juice/src/nr/private_contract/src/main.nr): the contract itself, annotated with the full bridge-to-mint-to-pay flow
* [`src/ts/README.md`](https://github.com/alejoamiras/ecosystem-tooling/blob/main/packages/private-fee-juice/src/ts/README.md): SDK reference with every exported class and utility
* [Integration test `private.test.ts`](https://github.com/alejoamiras/ecosystem-tooling/blob/main/packages/private-fee-juice/src/ts/test/private.test.ts): canonical end-to-end example of the bridge, claim, mint, sponsor flow
## Next steps[](#next-steps "Direct link to Next steps")
* Learn about [fee concepts](/developers/testnet/docs/foundational-topics/fees.md) in detail
* Review the other [fee payment methods](/developers/testnet/docs/aztec-js/how_to_pay_fees.md) available in `aztec.js`
* Browse the [`private-fee-juice`](https://github.com/alejoamiras/ecosystem-tooling/tree/main/packages/private-fee-juice) package for the Noir source, TypeScript SDK, and integration examples
---
# TypeScript API Reference
This section provides API reference documentation for the Aztec TypeScript packages. These packages enable developers to build applications on Aztec, from simple contract interactions to complex privacy-preserving protocols.
## Package Categories[](#package-categories "Direct link to Package Categories")
### Client SDKs[](#client-sdks "Direct link to Client SDKs")
Packages for building Aztec applications:
| Package | Description |
| --------------------------- | --------------------------------------------------------------------------------------------------------------------- |
| **@aztec-labs/aztec.js** | Main SDK for building Aztec applications. Provides contract deployment, transaction creation, and account management. |
| **@aztec-labs/accounts** | Sample account contract implementations including ECDSA and Schnorr accounts. |
| **@aztec-labs/pxe** | Private eXecution Environment client library for orchestrating private transaction execution and proving. |
| **@aztec-labs/wallet-sdk** | Wallet SDK for browser and extension integrations. |
| **@aztec-labs/wallets** | Embedded wallet for browser and Node.js environments. |
| **@aztec-labs/entrypoints** | Transaction entrypoint implementations for account abstraction. |
### Core Libraries[](#core-libraries "Direct link to Core Libraries")
Foundational types and utilities used across the Aztec stack:
| Package | Description |
| -------------------------- | -------------------------------------------------------------------------------------- |
| **@aztec-labs/stdlib** | Protocol-level types including transactions, blocks, proofs, and kernel circuit types. |
| **@aztec-labs/foundation** | Low-level utilities including crypto primitives, serialization, and async helpers. |
| **@aztec-labs/constants** | Protocol constants shared between TypeScript and Noir circuits. |
note
Common types like `Fr`, `AztecAddress`, and `EthAddress` are re-exported through `@aztec-labs/aztec.js` subpaths (e.g., `@aztec-labs/aztec.js/fields`, `@aztec-labs/aztec.js/addresses`). Most developers won't need to import from `@aztec-labs/stdlib` directly.
## LLM-Optimized Documentation[](#llm-optimized-documentation "Direct link to LLM-Optimized Documentation")
For LLM consumption, we provide machine-readable documentation in multiple formats:
* **[llms.txt](/llms.txt)** - Full documentation optimized for LLM context
* [**LLM Summary**](/typescript-api/testnet/llm-summary.txt) - Human-readable API summary
### Markdown API Files[](#markdown-api-files "Direct link to Markdown API Files")
The following markdown files are available for LLM context inclusion at `/typescript-api/testnet/`:
| File | Description |
| ------------------------------------------------------------- | ----------------------------------------------- |
| [`llm-summary.txt`](/typescript-api/testnet/llm-summary.txt) | Human-readable summary with package overview |
| [`aztec.js.md`](/typescript-api/testnet/aztec.js.md) | Main SDK - contracts, transactions, accounts |
| [`accounts.md`](/typescript-api/testnet/accounts.md) | Account implementations (ECDSA, Schnorr) |
| [`pxe.md`](/typescript-api/testnet/pxe.md) | Private execution environment client |
| [`wallet-sdk.md`](/typescript-api/testnet/wallet-sdk.md) | Browser/extension wallet integration |
| [`wallets.md`](/typescript-api/testnet/wallets.md) | Embedded wallet for browser and Node.js |
| [`entrypoints.md`](/typescript-api/testnet/entrypoints.md) | Transaction entrypoints for account abstraction |
| [`stdlib.md`](/typescript-api/testnet/stdlib.md) | Protocol types (transactions, blocks, proofs) |
| [`foundation.md`](/typescript-api/testnet/foundation.md) | Low-level utilities (crypto, serialization) |
| [`constants.md`](/typescript-api/testnet/constants.md) | Protocol constants for circuits |
## Related Resources[](#related-resources "Direct link to Related Resources")
* [Aztec.js Getting Started](/developers/testnet/docs/tutorials/js_tutorials/aztecjs-getting-started.md)
* [GitHub: aztec-packages](https://github.com/aztec-labs-eng/aztec-node/tree/v6.0.0-rc.1/yarn-project)
---
# Overview
Aztec.nr is a Noir framework used to develop and test Aztec smart contracts. It contains both high-level abstractions (state variables, messages) and low-level protocol primitives, providing granular control to developers if they want custom contracts.
tip
If you are already familiar with writing Aztec smart contracts and Aztec.nr, visit the [API reference](/aztec-nr-api/testnet/).
## Motivation[](#motivation "Direct link to Motivation")
Noir *can* be used to write circuits, but Aztec contracts are more complex than this. They include multiple external functions, each of a different type: circuits for private functions, AVM bytecode for public functions, and brillig bytecode for utility functions. The circuits for private functions also need to interact with the protocol's kernel circuits in specific ways, so manually writing them, and then combining everything into a contract artifact is involved work. Aztec.nr takes care of all of this heavy lifting and makes writing contracts as simple as marking functions with the corresponding attributes e.g. `#[external("private")]`.
It allows safe and easy implementation of well understood design patterns, such as the multiple kinds of private state variables, meaning developers don't need to understand the low-levels of how the protocol works. These features are optional, however, advanced developers are not prevented from building their own custom solutions.
## Design principles[](#design-principles "Direct link to Design principles")
* Make it hard to shoot yourself in the foot by making it clear when something is unsafe.
* Dangerous actions should be easy to spot. e.g. ignoring return values or calling functions with the `_unsafe` prefix.
* This is achieved by having rails that intentionally trigger a developer's "WTF?" response, to ensure they understand what they're doing.
A good example of this is writing to private state variables. These functions return a `NoteMessage` struct, which results in a compiler error unless used. This is because writing to private state also requires sending an encrypted message with the new state to the people that need to access it - otherwise, because it is private, they will not even know the state changed.
```
storage.votes.insert(new_vote); // compiler error - unused NoteMessage return value
storage.votes.insert(new_vote).deliver(MessageDelivery::onchain_constrained()); // deliver the note message onchain
```
## Contract Development[](#contract-development "Direct link to Contract Development")
### Prerequisites[](#prerequisites "Direct link to Prerequisites")
* Install [Aztec Local Network and Tooling](/developers/testnet/getting_started_on_local_network.md)
* Install the [Noir VSCode Extension](/developers/testnet/docs/aztec-nr/installation.md) for syntax highlighting and error detection.
### Flow[](#flow "Direct link to Flow")
1. Write your contract and specify your contract dependencies. Create a new project with `aztec new my_project`, which scaffolds a workspace with two crates: a `my_project_contract` crate for your contract and a `my_project_test` crate for tests, with the `aztec` dependency already configured. If you need additional dependencies, add them to `my_project_contract/Nargo.toml`:
```
# my_project_contract/Nargo.toml
[dependencies]
aztec = { git="https://github.com/aztec-labs-eng/aztec-nr/", tag="v6.0.0-rc.1", directory="aztec" }
```
Update your `my_project_contract/src/main.nr` contract file to use the Aztec.nr macros for writing contracts.
setup
```
use aztec::macros::aztec;
#[aztec]
pub contract Counter {
```
> [Source code: docs/examples/contracts/counter\_contract/src/main.nr#L1-L6](https://github.com/aztec-labs-eng/aztec-node/blob/v6.0.0-rc.1/docs/examples/contracts/counter_contract/src/main.nr#L1-L6)
and import dependencies from the Aztec.nr library.
imports
```
use aztec::{
macros::{functions::{external, initializer}, storage::storage},
messages::delivery::MessageDelivery,
oracle::logging::debug_log_format,
protocol::{address::AztecAddress, traits::ToField},
state_vars::Owned,
};
use balance_set::BalanceSet;
```
> [Source code: docs/examples/contracts/counter\_contract/src/main.nr#L7-L16](https://github.com/aztec-labs-eng/aztec-node/blob/v6.0.0-rc.1/docs/examples/contracts/counter_contract/src/main.nr#L7-L16)
info
You can see a complete example of a simple counter contract written with Aztec.nr [here](https://github.com/aztec-labs-eng/aztec-node/blob/v6.0.0-rc.1/docs/examples/contracts/counter_contract/src/main.nr).
2. [Profile](/developers/testnet/docs/aztec-nr/framework-description/advanced/how_to_profile_transactions.md) the private functions in your contract to get a sense of how long generating client side proofs will take
3. Write unit tests [directly in Noir](/developers/testnet/docs/aztec-nr/testing_contracts.md) and end-to-end tests [with TypeScript](/developers/testnet/docs/aztec-js/how_to_test.md)
4. [Compile](/developers/testnet/docs/aztec-nr/compiling_contracts.md) your contract
5. [Deploy](/developers/testnet/docs/aztec-js/how_to_deploy_contract.md) your contract with Aztec.js
## Section Contents[](#section-contents "Direct link to Section Contents")
## [📄️Noir VSCode Extension](/developers/testnet/docs/aztec-nr/installation.md)
[Learn how to install and configure the Noir Language Server for a better development experience.](/developers/testnet/docs/aztec-nr/installation.md)
## [📄️Compiling Contracts](/developers/testnet/docs/aztec-nr/compiling_contracts.md)
[Compile your Aztec smart contracts into deployable artifacts using aztec command.](/developers/testnet/docs/aztec-nr/compiling_contracts.md)
## [📄️Contract Deployment Reference](/developers/testnet/docs/aztec-nr/contract_readiness_states.md)
[A practical guide to determine which deployment steps your Aztec contract needs and when functions become callable.](/developers/testnet/docs/aztec-nr/contract_readiness_states.md)
## [🗃Framework Description](/developers/testnet/docs/aztec-nr/framework-description/functions.md)
[18 items](/developers/testnet/docs/aztec-nr/framework-description/functions.md)
## [📄️Logging from Contracts](/developers/testnet/docs/aztec-nr/logging.md)
[Add log statements to your Aztec contracts and control log verbosity in tests and local networks.](/developers/testnet/docs/aztec-nr/logging.md)
## [📄️Debugging Aztec Code](/developers/testnet/docs/aztec-nr/debugging.md)
[This guide shows you how to debug issues in your Aztec contracts.](/developers/testnet/docs/aztec-nr/debugging.md)
## [📄️Testing Contracts](/developers/testnet/docs/aztec-nr/testing_contracts.md)
[Write and run tests for your Aztec smart contracts using Noir's TestEnvironment.](/developers/testnet/docs/aztec-nr/testing_contracts.md)
## [🗃Standards](/developers/testnet/docs/aztec-nr/standards.md)
[6 items](/developers/testnet/docs/aztec-nr/standards.md)
## [📄️Aztec.nr API Reference](/developers/testnet/docs/aztec-nr/api.md)
[Auto-generated API reference documentation for the Aztec.nr smart contract framework.](/developers/testnet/docs/aztec-nr/api.md)
---
# Aztec.nr API Reference
The Aztec.nr API reference documentation is auto-generated from the source code using `nargo doc`.
## View the API Documentation[](#view-the-api-documentation "Direct link to View the API Documentation")
[**Aztec.nr**](/aztec-nr-api/testnet/noir_aztec/index.html)
The API reference includes documentation for all public modules, functions, structs, and types in the aztec-nr workspace:
### Core Crates[](#core-crates "Direct link to Core Crates")
* [**noir\_aztec**](/aztec-nr-api/testnet/noir_aztec/index.html) - Core Aztec contract framework including:
<!-- -->
* [`context`](/aztec-nr-api/testnet/noir_aztec/context/index.html) - Private and public execution contexts
* [`state_vars`](/aztec-nr-api/testnet/noir_aztec/state_vars/index.html) - State variable types (PrivateMutable, PublicMutable, Map, etc.)
* [`note`](/aztec-nr-api/testnet/noir_aztec/note/index.html) - Note interfaces and utilities
* [`authwit`](/aztec-nr-api/testnet/noir_aztec/authwit/index.html) - Authentication witness support
* [`history`](/aztec-nr-api/testnet/noir_aztec/history/index.html) - Historical state proofs
* [`messages`](/aztec-nr-api/testnet/noir_aztec/messages/index.html) - Cross-chain messaging
* [`oracle`](/aztec-nr-api/testnet/noir_aztec/oracle/index.html) - Oracle interfaces
* [`macros`](/aztec-nr-api/testnet/noir_aztec/macros/index.html) - Contract macros and attributes
* [`hash`](/aztec-nr-api/testnet/noir_aztec/hash/index.html) - Hash functions and utilities
* [`keys`](/aztec-nr-api/testnet/noir_aztec/keys/index.html) - Key management utilities
* [`event`](/aztec-nr-api/testnet/noir_aztec/event/index.html) - Event emission and interfaces
* [`test`](/aztec-nr-api/testnet/noir_aztec/test/index.html) - Testing utilities
* [`utils`](/aztec-nr-api/testnet/noir_aztec/utils/index.html) - General utilities
### Note Types[](#note-types "Direct link to Note Types")
* [**address\_note**](/aztec-nr-api/testnet/address_note/index.html) - Note type for storing Aztec addresses
* [**field\_note**](/aztec-nr-api/testnet/field_note/index.html) - Note type for storing a single Field value
* [**uint\_note**](/aztec-nr-api/testnet/uint_note/index.html) - Note type for storing unsigned integers
### State Variables[](#state-variables "Direct link to State Variables")
* [**balance\_set**](/aztec-nr-api/testnet/balance_set/index.html) - State variable for managing private balances
### Utilities[](#utilities "Direct link to Utilities")
* [**compressed\_string**](/aztec-nr-api/testnet/compressed_string/index.html) - Compressed string utilities for efficient storage
---
# Compiling Contracts
This guide shows you how to compile your Aztec contracts into artifacts ready for deployment and interaction.
## Prerequisites[](#prerequisites "Direct link to Prerequisites")
* An Aztec contract written in Aztec.nr
* `aztec` installed
* Contract project with proper `Nargo.toml` configuration
## Compile your contract[](#compile-your-contract "Direct link to Compile your contract")
Compile your Noir contracts to generate JSON artifacts:
```
aztec compile
```
This outputs contract artifacts to the `target` folder.
## Use generated interfaces[](#use-generated-interfaces "Direct link to Use generated interfaces")
The compiler automatically generates type-safe interfaces for contract interaction.
### Import and use contract interfaces[](#import-and-use-contract-interfaces "Direct link to Import and use contract interfaces")
Use generated interfaces instead of manual function calls:
```
contract MyContract {
use token::Token;
#[external("private")]
fn transfer_tokens(token_address: AztecAddress, recipient: AztecAddress, amount: u128) {
// Use the generated Token interface to call another contract
self.call(Token::at(token_address).transfer(recipient, amount));
}
#[external("private")]
fn transfer_then_mint(token_address: AztecAddress, recipient: AztecAddress, amount: u128) {
// Private call executed immediately
self.call(Token::at(token_address).transfer(recipient, amount));
// Public call enqueued for later execution
self.enqueue(Token::at(token_address프로젝트로 돌아가기