Usage with Proofs
"Talk is cheap, show me the code."
import {SDK} from 'hollowdb';
import {Prover, computeKey} from 'hollowdb-prover';
import {WarpFactory, JWKInterface} from 'warp-contracts';
import fs from 'fs';
// read wallet
const walletPath = __dirname + '/wallet-name.json';
const wallet = JSON.parse(
fs.readFileSync(walletPath).toString()
) as JWKInterface;
// instantiate SDK
const contractTxId = '<your-contract-txid>';
const sdk = new SDK(wallet, contractTxId, WarpFactory.forMainnet());
// instantiate the prover
const wasmCircuitPath = __dirname + '/circuit.wasm';
const proverKeyPath = __dirname + '/prover_key.zkey';
const prover = new Prover(wasmCircuitPath, proverKeyPath);
// compute your key from secret
const secret = BigInt("0xDEADBEEF");
const key = computeKey(secret);
// generate a proof for UPDATE
const currentValue = await sdk.get(key);
const nextValue = 'this is a new value!';
const {proof} = await prover.prove(secret, currentValue, nextValue);
// update
await sdk.update(key, nextValue, proof);Last updated