aztec-typescript
Generate TypeScript client code for interacting with Aztec contracts. Use when building frontend integrations, creating contract clients, or setting up wallet connections.
When & Why to Use This Skill
This Claude skill automates the generation of type-safe TypeScript client code for Aztec smart contracts, streamlining the development of decentralized applications (dApps). It simplifies contract interactions, wallet setups, and transaction management, allowing developers to integrate blockchain functionality into their frontend applications efficiently and securely.
Use Cases
- Frontend dApp Development: Quickly generate type-safe bindings for Aztec contracts to ensure reliable and error-free interactions between the user interface and the blockchain.
- Wallet Integration: Establish secure and standardized wallet and node connection patterns for users to interact with Aztec-based applications.
- Automated Transaction Handling: Implement complex transaction flows, including fee payments and status monitoring, using pre-defined patterns to improve user experience.
- Contract Client Scaffolding: Rapidly create wrappers for smart contracts to facilitate testing and integration within a TypeScript environment, reducing manual boilerplate code.
| name | aztec-typescript |
|---|---|
| description | Generate TypeScript client code for interacting with Aztec contracts. Use when building frontend integrations, creating contract clients, or setting up wallet connections. |
| allowed-tools | Read, Grep, Glob, Edit, Write, Bash |
Aztec TypeScript Integration
Generate TypeScript code for interacting with Aztec contracts.
Subskills
- Contract Client - Type-safe contract interaction wrapper
- Wallet Setup - Wallet and node connection patterns
- Transaction Patterns - Common transaction patterns
Quick Start: Contract Interaction
import { MyContract } from "../artifacts/MyContract.js";
import { SponsoredFeePaymentMethod } from "@aztec/aztec.js/fee/testing";
import { TxStatus } from "@aztec/stdlib/tx";
// Get contract instance
const contract = MyContract.at(contractAddress, wallet);
// Call a method
const tx = await contract.methods.myMethod(arg1, arg2).send({
from: account.address,
fee: { paymentMethod }
}).wait({ timeout: 60000 });
if (tx.status === TxStatus.SUCCESS) {
console.log('Transaction successful');
}
Generated Artifacts
After running aztec codegen, you get TypeScript bindings:
// src/artifacts/MyContract.ts
import { MyContractContract } from "../artifacts/MyContract.js";
// Available methods
MyContractContract.deploy(wallet, ...args) // Deploy new contract
MyContractContract.at(address, wallet) // Connect to existing
contract.methods.myFunction(args) // Call contract method
Key Imports
// Contract and wallet
import { Wallet } from "@aztec/aztec.js/wallet";
import { AztecAddress } from "@aztec/stdlib/aztec-address";
// Transaction handling
import { TxStatus } from "@aztec/stdlib/tx";
import { TxReceipt } from "@aztec/stdlib/tx";
// Fee payment
import { SponsoredFeePaymentMethod } from "@aztec/aztec.js/fee/testing";
// Fields and types
import { Fr, GrumpkinScalar } from "@aztec/aztec.js/fields";
// Logging
import { Logger, createLogger } from "@aztec/aztec.js/log";
Transaction Flow
- Get contract instance (
at()ordeploy()) - Call method via
contract.methods.xxx() - Send with fee payment
.send({ from, fee }) - Wait for confirmation
.wait({ timeout }) - Check status
tx.status === TxStatus.SUCCESS