Generate a TypeScript deployment script for an Aztec contract
Generates a TypeScript deployment script for an Aztec contract with wallet setup, fee payment, and credential logging.
/plugin marketplace add critesjosh/aztec-claude-plugin/plugin install critesjosh-aztec@critesjosh/aztec-claude-pluginGenerate a deployment script for the Aztec contract named "$ARGUMENTS".
If no contract name is provided, ask for one
Look for the contract artifact in src/artifacts/ or target/
Generate a deployment script in scripts/deploy_$ARGUMENTS.ts that includes:
setupWallet()The script should:
config/config.tsAdd corresponding npm scripts to package.json:
deploy-$ARGUMENTS for local networkdeploy-$ARGUMENTS::devnet for devnetimport { ContractNameContract } from "../src/artifacts/ContractName.js";
import { Logger, createLogger } from "@aztec/aztec.js/log";
import { SponsoredFeePaymentMethod } from "@aztec/aztec.js/fee/testing";
import { setupWallet } from "../src/utils/setup_wallet.js";
import { getSponsoredFPCInstance } from "../src/utils/sponsored_fpc.js";
import { SponsoredFPCContract } from "@aztec/noir-contracts.js/SponsoredFPC";
import { Fr, GrumpkinScalar } from "@aztec/aztec.js/fields";
import { AztecAddress } from "@aztec/stdlib/aztec-address";
import { getTimeouts } from "../config/config.js";
async function main() {
const logger = createLogger('aztec:deploy:contractname');
logger.info('Starting deployment...');
// Setup wallet
const wallet = await setupWallet();
// Setup sponsored fee payment
const sponsoredFPC = await getSponsoredFPCInstance();
await wallet.registerContract(sponsoredFPC, SponsoredFPCContract.artifact);
const paymentMethod = new SponsoredFeePaymentMethod(sponsoredFPC.address);
// Create and deploy account
const secretKey = Fr.random();
const signingKey = GrumpkinScalar.random();
const salt = Fr.random();
logger.info('Save these credentials:');
logger.info(`SECRET=${secretKey.toString()}`);
logger.info(`SIGNING_KEY=${signingKey.toString()}`);
logger.info(`SALT=${salt.toString()}`);
const account = await wallet.createSchnorrAccount(secretKey, salt, signingKey);
await (await account.getDeployMethod()).send({
from: AztecAddress.ZERO,
fee: { paymentMethod }
}).wait({ timeout: getTimeouts().deployTimeout });
logger.info(`Account deployed at: ${account.address}`);
// Deploy contract
const contract = await ContractNameContract.deploy(wallet, account.address).send({
from: account.address,
fee: { paymentMethod }
}).deployed({ timeout: getTimeouts().deployTimeout });
logger.info(`Contract deployed at: ${contract.address}`);
}
main().catch((error) => {
console.error('Deployment failed:', error);
process.exit(1);
});