Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ Capsules provide per-contract non-volatile storage in the PXE. Data is stored lo
```rust
use aztec::oracle::capsules;

// Inside a contract function, use context.this_address() for contract_address
let contract_address: AztecAddress = context.this_address();
// Inside a contract function, use self.address for contract_address
let contract_address: AztecAddress = self.address();
let slot: Field = 1;

// Store data at a slot (overwrites existing data)
Expand Down
20 changes: 10 additions & 10 deletions docs/docs-developers/docs/aztec-nr/framework-description/globals.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,23 @@ The following fields are accessible via `context` methods:
The unique identifier for the Aztec network instance (not the Ethereum chain the rollup settles to).

```rust
context.chain_id();
self.context.chain_id();
```

### Version

The Aztec protocol version number. The genesis block has version 1.

```rust
context.version();
self.context.version();
```

### Gas Settings

The gas limits, max fees per gas, and inclusion fee set by the user for the transaction.

```rust
context.gas_settings();
self.context.gas_settings();
```

## Public Global Variables
Expand All @@ -59,27 +59,27 @@ Public functions have access to `chain_id()` and `version()` (same syntax as pri
The unix timestamp when the block is executed. Provided by the block proposer, so it may have slight variance. Always increases monotonically.

```rust
context.timestamp();
self.context.timestamp();
```

### Block Number

The sequential block identifier. Genesis block is 1, incrementing by 1 for each subsequent block.

```rust
context.block_number();
self.context.block_number();
```

### Gas Fees

The current L2 and DA gas prices for the block. You can access gas-related information via:

```rust
context.l2_gas_left(); // Remaining L2 gas
context.da_gas_left(); // Remaining DA gas
context.base_fee_per_l2_gas(); // L2 gas price
context.base_fee_per_da_gas(); // DA gas price
context.transaction_fee(); // Final tx fee (only available in teardown phase)
self.context.l2_gas_left(); // Remaining L2 gas
self.context.da_gas_left(); // Remaining DA gas
self.context.base_fee_per_l2_gas(); // L2 gas price
self.context.base_fee_per_da_gas(); // DA gas price
self.context.transaction_fee(); // Final tx fee (only available in teardown phase)
```

:::info Why do available globals differ between environments?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ impl NoteHash for CustomHashNote {
) -> Field {
// Standard nullifier using owner's nullifier secret key
let owner_npk_m = aztec::keys::getters::get_public_keys(owner).npk_m;
let secret = context.request_nsk_app(owner_npk_m.hash());
let secret = self.context.request_nsk_app(owner_npk_m.hash());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this change introduces a bug - inside compute_nullifier, context is a parameter passed to the function, not a member of self. the actual implementations use context.request_nsk_app(...) not self.context.request_nsk_app(...). see uint_note.nr:74 and nft_note.nr:68 for reference.

poseidon2_hash_with_separator(
[note_hash_for_nullification, secret],
DOM_SEP__NOTE_NULLIFIER,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,9 @@ You can cancel an authwit before it's used by emitting its nullifier directly. T

```rust
fn cancel_authwit(inner_hash: Field) {
let on_behalf_of = context.msg_sender();
let on_behalf_of = self.msg_sender();
let nullifier = compute_authwit_nullifier(on_behalf_of, inner_hash);
context.push_nullifier(nullifier);
self.context.push_nullifier(nullifier);
}
```

Expand Down