PrivateNote
(Work in progress) PrivateNote Contract Interface Documentation
Overview
PrivateNote is a non-custodial wallet contract that stores balances, manages stakes, and interacts with Pari Mutuel Pool (PMP) contracts (deployment, staking, cancellation, claiming).
It also supports coupons and withdrawals via RootPN contract — all while preserving privacy guarantees.
Each PrivateNote:
Owner-authorized actions are controlled by an ephemeral public key (
_ethemeral_pubkey).The contract uses a busy state (
_busy) to prevent concurrent PMP interactions.Stakes are processed in two phases: candidate → confirmed/reverted via PMP callbacks.
Some operations require
debt == 0and no active stakes.
Events
OwnerChanged
Emitted when the owner public key is updated.
event OwnerChanged(uint256 oldPubkey, uint256 newPubkey);oldPubkey- Previous public keynewPubkey- New public key
StakeConfirmed
Emitted after a stake is successfully accepted by a PMP.
stakeController- Address of the PMP contract that accepted the stakeoutcome- Outcome identifier the stake was placed onamount- Amount of tokens added to the stakebet_type— bet type0— clean bet (from balance)1— debt bet2— coupon bet
StakeCancelled
Emitted after a stake is cancelled and refunded.
stakeController- Address of the PMP contract that cancelled the stakeamount- Amount of tokens returned
FullSetStakeConfirmed
Emitted when a full-set stake is confirmed by PMP
stakeController— PMP addressamount— Confirmed stake amounts per outcome
FullSetStakeCancelled
Emitted when a full-set stake is cancelled and funds returned
stakeController— PMP addressvalue— Total returned token value to balance
ClaimAccepted
Emitted when a claim is resolved and payout is credited.
stakeController- Address of the PMP contractoutcome- Final resolved outcome. Empty if the event is not yet resolvedpayout- Amount of tokens paid to the wallet
PMPDeployed
Emitted when a new PMP contract is deployed.
event_id- Identifier of the PMP eventtoken_type- Token type used for stakingpmpAddress- Address of the deployed PMP contractoracleEventLists- Oracle event list contract addressesoracleFee- Oracle fee values corresponding to each oracle
Public & External Interface
changeOwner
changeOwnerChanges the (ephemeral) public key controlling the wallet.
Parameters:
new_pubkey— Public key of the new owner
Access Control:
Must be signed by the current public key
Effects:
Updates owner key
Emits
OwnerChanged
deployPMP
deployPMPDeploys a new PMP contract associated with this wallet
Parameters:
event_id— Identifier of the PMP eventoracleFee— Array of additional fees (in shell tokens) for each oracle. Must match the length ofnamesandindex.token_type— Token type used by the PMP contractnames— Array of oracle names used to compute oracle addresses.index— Array of oracle indexes used to compute OracleEventList addresses.
Deployment flow:
1. Validate input array lengths.
2. Compute oracle addresses from names.
3. Compute OracleEventList addresses using oracle code and indexes.
4. Aggregate oracle fees and include network fee.
5. Build PMP StateInit and compute deterministic PMP address.
6. Emit PMPDeployed event.
7. Deploy PMP contract with required currencies.
setStake
setStakePlaces a single-outcome stake on a PMP
Parameters:
event_id- PMP event identifieroracle_list_hash- Hash of the oracle list configuration associated with thePMPevent. Must match the oracle list used when thePMPcontract was deployed.token_type- Token type used for staking. Must correspond to a token balance available in the wallet.outcome- Identifier of the outcome being staked on. The meaning of the outcome is defined by thePMPcontract logic.amount- Amount of tokens to stake. Must be greater than zero and less than or equal to the available balance for the specified token type.use_coupon- Whether to use coupon for this stake If true, amount will be taken from available coupons instead of balance
Requirements
amount > 0If
use_coupon == true→ sufficient couponsElse → sufficient token balance
Wallet is not busy
Effects
Writes candidate stake
Deducts balance or coupons
Sets
_busyand_lastHashCalls
PMP.acceptStake(...)
setFullSetStake
setFullSetStakePlaces a full-set stake (amount per outcome)
Parameters:
event_id- PMP event identifieroracle_list_hash- Hash of the oracle list configuration associated with thePMPevent. Must match the oracle list used when thePMPcontract was deployedtoken_type- Token type used for staking. Must correspond to a token balance available in the walletamount- Array of stake amounts per outcome
Requirements
Wallet is not busy
amount.length > 0debt == 0Sufficient balance
If stake exists → lengths must match
Owner authorization
Effects
Sets
candidate_amount = sum(amount)Deducts balance
Sets
_busyand_lastHashCalls
PMP.acceptFullSetStake(...)
cancelStake
cancelStakeCancels an existing stake in PMP.
Parameters
event_id— Identifier of the PMP eventoracle_list_hash- Hash of the oracle list configuration associated with thePMPevent. Must match the oracle list hash of the existing stake.token_type- Token type used for the stake being cancelled. Must correspond to the token type of the existing stake entry.
Requirements
Wallet is not busy
Stake record exists
Owner authorization
Flow
Computes stake hash and PMP address
Sets
_busyand_lastHashCalls
PMP.cancelStake(...)
deleteStake
deleteStakeDeletes a local stake record (does not call PMP)
Parameters:
event_id- PMP event identifieroracle_list_hash- Hash of the oracle list configuration associated with the stake. Must match the oracle list hash used when the stake entry was created.token_type- Token type of the stake being deleted. Used to identify the correct local stake record.
Requirements
Wallet is not busy
Owner authorization
Effects
Removes the local stake record
claim
claimClaims winnings from a resolved PMP.
Parameters
event_id- PMP event identifier. Used to derive the event identifier and the address of the targetPMPcontract.oracle_list_hash- Hash of the oracle list configuration associated with thePMPevent. Must match the oracle list hash of the existing stake.token_type- Token type used for the stake. Determines which internal balance will receive the payout.
Requirements
Wallet is not busy
No pending candidate amount
Owner authorization
Effects
Sets
_busyand_lastHashCalls
PMP.claim(...)
generateCoupon
generateCouponGenerates a free coupon for a specified token type.
The function allows the wallet owner to receive a one-time free coupon.
The coupon value depends on the provided token_type and is internally determined by the contract.
Coupons can later be used to place stakes instead of using wallet balance.
Parameters
token_type- Token type for which the coupon should be generated
Requirements
debt == 0No active stakes
All balances are zero
No existing coupon
withdrawFullSet
withdrawFullSetWithdraws or cancels part of a full-set stake.
Parameters
event_id- PMP event IDoracle_list_hash- Hash of Oraclestoken_type- Token typeamount- Array of amounts per outcome to withdraw
Requirements
Wallet is not busy
Debt must be zero.
Stake record must exist
Array length must match existing stake
Effects
Sets
_busyand_lastHashCalls
PMP.withdrawFullSet(...)
withdrawTokens
withdrawTokensWithdraws tokens from the wallet via the RootPN.
Parameters
flags- Transfer flags passed to theRootPNcontract. Control message delivery behavior during the token transfer.dest_wallet_addr- Destination wallet address that will receive the withdrawn tokens.token_type- Type of token to withdraw. All available balance for this token type will be withdrawn.
Requirements
No active stakes
debt == 0Owner authorization
Behavior:
Transfers full balance of the given token type
Resets local balance to zero
View Functions
getPMPCode
getPMPCodeReturns salted PMP code and its hash.
getDetails
getDetailsReturns current wallet state:
Returns:
depositIdentifierHash- deposit identifier hashetherealPubkey- public keybalance- token balancespmpCodeHash-PMPcode hashprivateNoteCodeHash-PrivateNotecode hashbusyAddress- busy PMP address (if any)
getVersion
getVersionReturns version and contract identifier.
Returns:
semantic version string
Contract name:
"PrivetNote"
Last updated