summon-ts
TypeScript build of the
Summon compiler (via
wasm).
Usage
npm install summon-ts
import * as summon from "summon-ts";
async function main() {
await summon.init();
const { circuit, diagnostics } = summon.compile({
path: "/src/main.ts",
files: {
"/src/main.ts": `
export default (io: Summon.IO) {
const a = io.input('alice', 'a', summon.number());
const b = io.input('bob', 'b', summon.number());
io.outputPublic('res', a + b);
}
`,
},
});
console.log(circuit);
console.log(diagnostics);
}
main().catch(console.error);
When providing files to the API, you can also provide a readFile function
instead:
summon.compile({
path: "./path/to/main.ts",
readFile: (filePath) => fs.readFileSync(filePath),
});
Development
Build with npm run build. This will compile the wasm subproject and also
transpile typescript into javascript. Rust toolchain
required.
Test with npm test.
Example Projects