Skip to content

offchain payments#15

Open
mverzilli wants to merge 24 commits intomainfrom
feat/p2p-offchain-transfers
Open

offchain payments#15
mverzilli wants to merge 24 commits intomainfrom
feat/p2p-offchain-transfers

Conversation

@mverzilli
Copy link
Copy Markdown
Contributor

@mverzilli mverzilli commented Apr 13, 2026

Shows how Aztec.nr's offchain delivery method to send notes without needing on-chain discovery.

If reviewer likes this I'll open a PR on aztec-packages to update the Token contract (vendored for now for simplicity)

Closes F-551

mverzilli and others added 22 commits April 9, 2026 15:52
- Upgrade @aztec/* npm packages to 4.2.0-nightly.20260409
- Upgrade Nargo.toml git tags to match
- Use portal: links for @gregojuice/* packages (local dev)
- Add deploy-subscription-fpc.ts script for local SubscriptionFPC deployment
- Updated local.json with deployed contract addresses and subscriptionFPC config

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copies the Aztec standard token contract into contracts/token/, removes
the test module, and adds a transfer_offchain method that delivers notes
via MessageDelivery.OFFCHAIN. Updates AMM and ProofOfPassword to depend
on this local fork instead of the upstream git reference.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Introduces SendProvider/useSend context following the existing swap context pattern, with a state machine covering idle/sending/generating_link/link_ready/error phases and namespaced action creators.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Handles offchain transfer execution, sender change note self-delivery,
and recipient message extraction for link encoding.
SendForm (token selector, address, amount), SendProgress, LinkDisplay
(copyable link + QR code), SentHistory, and SendContainer orchestrator.
ClaimPage (orchestrator with state machine), ClaimProgress,
and ClaimSuccess. Claim contract interaction to be wired in Task 10.
Detects /#/claim/ routes and renders ClaimPage. Adds Swap/Send
tabs to the main interface.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add sendOffchain and claimOffchainTransfer to ContractsContext.
Update SendContext with executeSend business logic.
Wire SendForm button and ClaimPage contract interaction.
- Add scripts/deploy-subscription-fpc.ts for deploying SubscriptionFPC to local
- Make registerDripContracts skip gracefully when SubscriptionFPC is not on-chain
- Add design spec and implementation plan docs

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Comment on lines +599 to +614
// Self-deliver sender's change note (manual until F-324 lands)
const senderMessages = offchainMessages.filter(
(msg: OffchainMessage) => msg.recipient.equals(fromAddress),
);
if (senderMessages.length > 0) {
await token.methods
.offchain_receive(
senderMessages.map((msg: OffchainMessage) => ({
ciphertext: msg.payload,
recipient: fromAddress,
tx_hash: receipt.txHash.hash,
anchor_block_timestamp: msg.anchorBlockTimestamp,
})),
)
.simulate({ from: fromAddress });
}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

if we end up deciding against F-324, this should maybe become a helper in Aztec.js ("receive offchain messages emitted to myself").

also, I'm an idiot and now we have divergent names between ts and noir (ciphertext -> payload, anchor_block_timestamp -> anchorBlockTimestamp) 🤦‍♂️

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It's not that bad, kebab_case vs. camelCase is very common in the noir/TS barrier. I'd align ciphertext/payload though.

@mverzilli mverzilli requested a review from Thunkar April 13, 2026 16:55

// Create an authwitness so the FPC can call transfer_in_private_deliver_offchain on the user's behalf.
// The caller from the token contract's perspective is the FPC.
const authWitness = await wallet.createAuthWit(fromAddress, { caller: fpcAddress, call });
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Wallets should do authwit resolution during pre-simulation. Avoid manual authwit creation since it results in another interaction for external wallets!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants