UNPKG

zkapp-cli

Version:

CLI to create zkApps (zero-knowledge apps) for Mina Protocol

44 lines 1.93 kB
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; import { Field, SmartContract, state, State, method } from 'o1js'; import { AddProgramProof } from './AddZkProgram.js'; /** * Basic Example * See https://docs.minaprotocol.com/zkapps for more info. * * The Add contract verifies a ZkProgram proof and updates a 'num' state variable. * When the 'settleState' method is called, the Add contract verifies a * proof from the 'AddZkProgram' and saves the 'num' value to the contract state. * * This file is safe to delete and replace with your own contract. */ export class Add extends SmartContract { constructor() { super(...arguments); this.num = State(); } async settleState(proof) { proof.verify(); this.num.requireEquals(proof.publicInput); const addProgramState = proof.publicOutput; this.num.set(addProgramState); } } __decorate([ state(Field), __metadata("design:type", Object) ], Add.prototype, "num", void 0); __decorate([ method, __metadata("design:type", Function), __metadata("design:paramtypes", [AddProgramProof]), __metadata("design:returntype", Promise) ], Add.prototype, "settleState", null); //# sourceMappingURL=Add.js.map