protocol-pg icon indicating copy to clipboard operation
protocol-pg copied to clipboard

Setup FFI scripts

Open AdvaithD opened this issue 2 years ago • 0 comments

Simple CLI script that uses a switch statement to run specific js functions and return to stdout so that we can create within solidity:

  1. Merkle roots and proofs
  2. Compute deterministic addresses
  3. Generate signatures and hashes

Sample boilerplate

#!/usr/bin/env ts-node

import { ... } from "lib.ts";
(() => {
  const type = process.argv[2]
  switch (type) {
    case "merkleRoot": {
      const account1 = process.argv[3]
      const account2 = process.argv[4]
      const merkleRoot = computeRoot([account1, account2])

      process.stdout.write(merkleRoot)
      break
    }
    case "merkle-drop-proof": {
      const merkleProof = "";
      process.stdout.write(merkleProof)
      break;
    }
    default:
      break;
  }
})()

AdvaithD avatar Dec 28 '22 03:12 AdvaithD