Struct SingleUseClaim
pub struct SingleUseClaim<Context>
{ /* private fields */ }
Implementations
impl SingleUseClaim<UtilityContext>
pub unconstrained fn has_claimed(self) -> bool
Returns whether an owner has claimed this single use claim.
impl<Context> SingleUseClaim<Context>
impl SingleUseClaim<&mut PrivateContext>
pub fn claim(self)
Records the fact that the owner in scope has claimed this single use claim.
This function succeeds at most once for a given owner. Any subsequent calls with same owner are guaranteed to
fail.
Note that, by itself, calling this function doesn't do anything other than prevent it being called again with the same owner. Its invocation is typically accompanied by other contract actions, e.g. minting tokens, casting a vote, etc.
Advanced
The implementation of this function emits a nullifier derived from the owner's nullifier hiding key and the
storage slot of the underlying state variable.
pub fn assert_claimed(self)
Asserts that the owner has already claimed this single use claim (i.e. that SingleUseClaim::claim has been
called).
Advanced
This function generates a kernel nullifier read request, so it can even assert the existence of pending claims,
i.e. when SingleUseClaim::claim was called in the same transaction as SingleUseClaim::assert_claimed.
Trait implementations
impl<Context> OwnedStateVariable<Context> for SingleUseClaim<Context>
pub fn new(context: Context, storage_slot: Field, owner: AztecAddress) -> Self
Private right to perform an action.
A private state variable type that represents a right each user can exercise at most once.
Because it is owned, you must wrap a
SingleUseClaiminside ancrate::state_vars::owned::Ownedstate variable when using it in storage.Example
The right to vote at most once can be implemented using
SingleUseClaimas a primitive.For more details on what owned means, see the documentation for the
OwnedStateVariabletrait.Cost
Exercising a claim (via the
SingleUseClaim::claimfunction) emits one nullifier.Privacy considerations
The
SingleUseClaim::claimfunction emits a public nullifier per owner: it's fully private, hidden behind the owner's app-siloed nullifier hiding key (akanhk).Public effects you emit alongside a claim (e.g. a public function call to update a tally) may still let observers infer who likely exercised the claim, so consider that when designing flows.