protocol-pg
protocol-pg copied to clipboard
Setup FFI scripts
Simple CLI script that uses a switch statement to run specific js functions and return to stdout so that we can create within solidity:
- Merkle roots and proofs
- Compute deterministic addresses
- 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;
}
})()