o1js
Version:
TypeScript framework for zk-SNARKs and zkApps
19 lines (14 loc) • 575 B
text/typescript
import { SmartContract, method, UInt64, AccountUpdate, PublicKey } from 'o1js';
export class Escrow extends SmartContract {
async deposit(user: PublicKey) {
// add your deposit logic circuit here
// that will adjust the amount
const payerUpdate = AccountUpdate.createSigned(user);
payerUpdate.send({ to: this.address, amount: UInt64.from(1000000) });
}
async withdraw(user: PublicKey) {
// add your withdrawal logic circuit here
// that will adjust the amount
this.send({ to: user, amount: UInt64.from(1000000) });
}
}