A collection of Fee Payment Contracts (FPCs) for Aztec that enable transaction fee sponsorship strategies.
This repository provides a production-ready Metered FPC implementation:
| Contract | Description |
|---|---|
| Metered | Tracks internal balances and deducts max gas cost |
├── src/
│ ├── nr/ # Noir smart contracts
│ │ ├── counter_contract/ # Test utility contract
│ │ └── metered_contract/ # Metered FPC
│ └── ts/ # TypeScript package
│ ├── artifacts/ # Generated contract bindings
│ ├── fee-payment-methods/ # Fee payment method classes
│ ├── utils/ # Utilities (gas, deploy)
│ └── test/ # Integration tests
├── target/ # Compiled contract artifacts
└── benchmarks/ # Performance benchmarks
- Aztec Sandbox v3.0.0 or later
- Node.js 22+
- Yarn 1.22+
yarn install# Compile Noir contracts
nargo compile --silence-warnings
# Post-process with Aztec tooling
aztec compile
# Generate TypeScript bindings
aztec codegen target --outdir src/ts/artifactsStart the Aztec sandbox:
yarn start:sandboxRun tests:
yarn testThe Metered FPC test file validates:
- ✅ SUCCESS: Transaction succeeds, FPC pays fees
- ❌ Private revert: Transaction is invalid (not included)
⚠️ Public revert: FPC still pays fees (APP_LOGIC_REVERTED)
See src/ts/README.md for detailed documentation on using the published NPM package.
yarn add @defi-wonderland/aztec-fee-paymentQuick example:
import {
MeteredContract,
MeteredFeePaymentMethod,
deployMeteredContract,
} from '@defi-wonderland/aztec-fee-payment';
// Deploy and fund the FPC
const fpc = await deployMeteredContract(wallet);
// Mint balance for user
await fpc.methods.mint(userAddress, 1_000_000_000_000n).send().wait();
// Use it for transactions
await myContract.methods.doSomething()
.send({ fee: { paymentMethod: new MeteredFeePaymentMethod(fpc.address) } })
.wait();yarn benchmarkMIT